Closed aydinnyunus closed 7 months ago
Good catch, thank you.
This is not an issue, the app and model name are pre-filtered to be a slug. Malicious strings would not reach the code you've hinted above. https://github.com/lincolnloop/django-dynamic-raw-id/blob/main/dynamic_raw_id/urls.py#L9
I've simplified that error message nonetheless.
Hi,
I saw the app_name but I did not find the model_name is predefined so I created the issue. Thanks for the quick fix.
Description:
The code snippet provided is from a Django application where the dynamic_raw_id view attempts to retrieve a model dynamically based on the provided
app_name
andmodel_name
parameters. If the model does not exist, it returns a 400 Bad Request response with an optional error message.https://github.com/lincolnloop/django-dynamic-raw-id/blob/main/dynamic_raw_id/views.py#L41
Impact:
This code is vulnerable to a Cross-Site Scripting (XSS) attack due to the potential injection of user-controlled data into the error message. Specifically, if an attacker provides a malicious app_name or model_name, they could craft a payload that, when executed in the context of an HTML page, could lead to the execution of arbitrary JavaScript code.