Escape user input in publish review to prevent XSS#43
Merged
Conversation
|
🚀 Preview deployed to Cloudflare Pages
|
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.
Vulnerability
renderReview()insrc/pages/publish.astrobuilt the review table by interpolating form-state values directly intoinnerHTML. Only the row labels (k) were passed throughesc(); the user-controlled values (v) — App ID, description, backend URL, header values, method names/paths, vendor name/URL, capabilities, signer name, etc. — were inserted raw.Any value containing markup (e.g.
<img src=x onerror=...>) executes when the publisher reaches the review step — a self-XSS on the publish flow.Fix
Escape every user-controlled value with the existing
esc()helper at row-construction time, while preserving the intentional markup:Methodsrow keeps its<br>separators, but each method string is escaped individually before joining.esc('')is falsy, so the sharedv||'<span…>—</span>'fallback still renders the placeholder.HTTP API, the·vendor separator) are unaffected; visual output is identical.Verification
npm run build(astro build) — 190 pages built,publish.astrocompiles cleanly, no breakage.