Fix XSS and crash bugs in admin UI#4
Open
yannmh wants to merge 1 commit into
Open
Conversation
- settings-api.js: escape x_forwarded_for before injecting into HTML; an attacker-controllable X-Forwarded-For header could otherwise be rendered as HTML in the admin sessions table. - utils.js: render API error messages with .text() instead of .html() in the "add to list" alert modal to prevent injection via response.message. - settings-teleporter.js: guard against a missing/malformed Content-Disposition header when downloading the teleporter archive; previously .match(...)[1] would throw and break the download. Run-on: Niteshift Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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
Three critical bug fixes surfaced by an audit of the admin web UI JS:
X-Forwarded-For(scripts/js/settings-api.js:118) — the value was interpolated into HTML via.html()with no escaping. An attacker able to set theX-Forwarded-Forheader on a session could render arbitrary HTML/JS inside the API sessions table. Fixed by wrapping withutils.escapeHtml.scripts/js/utils.js:339) —alCustomErr.html(response.message)rendered the API's error string as HTML in the "add to list" modal. Switched to.text().scripts/js/settings-teleporter.js:93) —xhr.getResponseHeader("Content-Disposition").match(...)[1]threw when the header was missing or didn't match the regex, breaking the download. Added null/undefined guards and a fallback filename.Test plan
<img src=x onerror=alert(1)>renders as text, not HTML.🤖 Generated with Claude Code
🌒 Run on Niteshift: View Task