Reflected XSS without CSP bypass in Socorro via controllable parsed.path in views.highlight_url
- Fixed in 23 hours
- Paid in 5 days
- Disclosed after 23 hours
Summary
Bug 1389217 introduced syntax highlighting of generated source files in Socorro. The view function takes the url query parameter and validates it such that only files under http[s]://gecko-generated-sources.s3.amazonaws.com will be fetched and highlighted with Pygments.
For example:
https://crash-stats.mozilla.org/sources/highlight/?url=https://gecko-generated-sources.s3.amazonaws.com/7a1db5dfd0061d0e0bcca227effb419a20439aef4f6c4e9cd391a9f136c6283e89043d62e63e7edbd63ad81c339c401092bcfeff80f74f9cae8217e072f0c6f3/x86_64-pc-windows-msvc/release/build/swgl-59e3a0e09f56f4ea/out/brush_solid_DEBUG_OVERDRAW.h
I was unable to bypass the validation or traverse anywhere meaningful (the only allowed host is a dedicated S3 bucket) but did find an interesting behaviour giving us control of the parsed.path that is passed to the title option of Pygments' HtmlFormatter which is ultimately returned unescaped:
def highlight_url(request):
# ...
url = request.GET.get("url")
# ...
parsed = urlparse(url)
# ...
filename = parsed.path.split("/")[-1]
# ...
formatter = HtmlFormatter(
full=True, title=parsed.path, linenos="table", lineanchors="L", hl_lines=lines
)
return http.HttpResponse(
highlight(resp.text, lexer, formatter), content_type="text/html"
)
Browsing to the following URL will trigger a CSP error (unless you disabled CSP using a WebExtension or intercept proxy, in which case you will observe an alert dialog with the value of document.domain):
https://crash-stats.mozilla.org/sources/highlight/?url=https://gecko-generated-sources.s3.amazonaws.com/7a1db5dfd0061d0e0bcca227effb419a20439aef4f6c4e9cd391a9f136c6283e89043d62e63e7edbd63ad81c339c401092bcfeff80f74f9cae8217e072f0c6f3/x86_64-pc-windows-msvc/release/build/swgl-59e3a0e09f56f4ea/\%3Ch1%3ECheck%20DevTools%3Csvg%20onload=confirm(document.domain)%3E\out/../out/brush_solid_DEBUG_OVERDRAW.h
Environment
- Confirmed on: crash-stats.allizom.org, crash-stats.mozilla.org
- Browser: Firefox Nightly 108.0a1 (2022-10-27)
Impact
An attacker can execute arbitrary JavaScript in the context of another user on Socorro to exfiltrate Protected Data and perform actions as that user provided that CSP is unsupported or disabled in the browser. The impact is otherwise limited to HTML and CSS injection.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
What is known
A low-severity XSS bug in General. Mozilla made it public on 3 November 2022.
About XSS
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.