Audit all calls to mark_safe() to ensure any user-provided data is escaped #9886

Closed
opened 2025-12-29 21:24:01 +01:00 by adam · 0 comments
Owner

Originally created by @jeremystretch on GitHub (Jun 24, 2024).

Originally assigned to: @jeremystretch on GitHub.

Proposed Changes

There are many places we use Django's mark_safe() utility to bypass HTML escaping (typically within template tags and filters). Any user-sourced data within the string being marked as safe must be manually passed through escape().

Justification

Ensures consistent sanitization of user input.

Originally created by @jeremystretch on GitHub (Jun 24, 2024). Originally assigned to: @jeremystretch on GitHub. ### Proposed Changes There are many places we use Django's [`mark_safe()`](https://docs.djangoproject.com/en/5.0/ref/utils/#django.utils.safestring.mark_safe) utility to bypass HTML escaping (typically within template tags and filters). Any user-sourced data within the string being marked as safe must be manually passed through [`escape()`](https://docs.djangoproject.com/en/5.0/ref/utils/#django.utils.html.escape). ### Justification Ensures consistent sanitization of user input.
adam added the status: acceptedtype: housekeeping labels 2025-12-29 21:24:01 +01:00
adam closed this issue 2025-12-29 21:24:01 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#9886