Repository navigation
Sanitize rawHtml on ingest to prevent stored XSS (matches fetch-url r… - #1
Open
Iseekdopamine wants to merge 1 commit into
Open
Iseekdopamine wants to merge 1 commit into
Iseekdopamine wants to merge 1 commit into
Conversation
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
Stored XSS in
/api/documents/ingestlets a reviewer-level account fully compromise an admin account, with no admin action needed beyond opening the affected document.Root cause
POST /api/documents/ingestsavesrawHtmldirectly with no sanitization. The URL-fetch route (/api/documents/fetch-url) already sanitizes withsanitizeHtml(..., SANITIZE_OPTIONS)— the ingest route was just missing the same call.Proof of concept
pwned_adminappeared in User Management with role Administrator, created purely by the admin viewing the document (screenshot available on request).Fix
One-line change: run the existing
sanitizeHtml(rawHtml, SANITIZE_OPTIONS)in the ingest route too, same asfetch-urlalready does.Tested: the XSS payload no longer executes after this change, and normal HTML ingestion (headings, paragraphs, images) still renders and generates Q&A correctly.
Separate minor issue (not fixed in this PR)
The README lists both seeded accounts' passwords as

password123, but the actual defaults indb.mjsareAdmin@2026!andReviewer@2026!. Worth a quick doc fix separately.