Fix stored XSS in urldisplay and iconify template filters#344
Merged
Fix stored XSS in urldisplay and iconify template filters#344
Conversation
The urldisplay filter interpolated untrusted location/referrer values directly into single-quoted href and title attributes without escaping. An attacker could submit a location like "http://x' onfocus='...' autofocus='" via the unauthenticated ingress endpoint, breaking out of the attribute and executing arbitrary JavaScript when an admin viewed the dashboard. The iconify filter had the same flaw: urlparse().netloc preserves quote characters, and the netloc was inserted raw into a double-quoted src attribute. Both are fixed by applying escape() to the interpolated values, matching the existing escape(display_url) pattern already present on the same line.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes an unauthenticated stored XSS vulnerability in the dashboard. Attacker-controlled
locationandreferrervalues submitted via the public ingress endpoint were rendered into HTML attributes without escaping, allowing JavaScript execution in the admin's session.Root cause
urldisplay(helpers.py:193) — interpolated the raw URL into single-quotedhref='{url}'andtitle='{url}'attributes. A payload likehttp://x' onfocus='...' autofocus='passed thestartswith("http")check, then closed thehrefattribute early and injected new attributes.iconify(helpers.py:184) — called byurldisplaywith the same tainted input.urlparse().netlocpreserves quote characters, and the netloc was inserted raw into a double-quotedsrc="..."attribute.Fix
Apply
escape()to the three unescaped interpolation points. This matches the existingescape(display_url)pattern already present on the same line. Django'sescape()converts'→'and"→", preventing attribute break-out in both contexts.Affected pages
/dashboard/service/<uuid>/(location and referrer tables)/dashboard/service/<uuid>/locations/