Fix HIGH-level code scanning alerts: DOM XSS and unvalidated URL redirect#480
Fix HIGH-level code scanning alerts: DOM XSS and unvalidated URL redirect#480
Conversation
…rect Agent-Logs-Url: https://github.com/fabiocaccamo/django-admin-interface/sessions/76a9ef21-8d00-42b3-a8ae-598bd0bb4f21 Co-authored-by: fabiocaccamo <1035294+fabiocaccamo@users.noreply.github.com>
…-filter.js Agent-Logs-Url: https://github.com/fabiocaccamo/django-admin-interface/sessions/76a9ef21-8d00-42b3-a8ae-598bd0bb4f21 Co-authored-by: fabiocaccamo <1035294+fabiocaccamo@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #480 +/- ##
=======================================
Coverage 97.48% 97.48%
=======================================
Files 40 40
Lines 438 438
=======================================
Hits 427 427
Misses 11 11
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR addresses two HIGH-severity CodeQL findings in the admin UI JavaScript by removing an innerHTML-based DOM XSS sink and adding client-side validation before performing a window.location navigation.
Changes:
- Refactors related-modal iframe creation to avoid HTML string concatenation and jQuery HTML parsing of interpolated content.
- Adds a URL allowlist guard before assigning to
window.locationfrom dropdown filter selections.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
admin_interface/static/admin_interface/related-modal/related-modal.js |
Builds the modal + iframe via element creation/attribute setting rather than concatenated HTML to remove the DOM XSS sink. |
admin_interface/static/admin_interface/dropdown-filter/dropdown-filter.js |
Adds a prefix-based allowlist check intended to prevent unsafe client-side redirects. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…n-filter.js Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Two HIGH-severity CodeQL alerts in client-side JavaScript: DOM-based XSS via HTML string concatenation and an unvalidated URL redirect via
window.locationassignment.related-modal.js— DOM XSS (js/xss-through-dom)$()constructor (which usesinnerHTML) with explicit DOM API calls that set attributes directly, eliminating the XSS sink.dropdown-filter.js— Unvalidated URL redirect (js/client-side-unvalidated-url-redirection)window.locationassignment to blockjavascript:and protocol-relative (//evil.com) URLs. Django admin filter values are always query strings (?...) or path-relative (/...), so this is lossless.Checklist before requesting a review