fix: Fix reflected XSS in blog search and emit search#1111
Open
RaminNietzsche wants to merge 1 commit into
Open
fix: Fix reflected XSS in blog search and emit search#1111RaminNietzsche wants to merge 1 commit into
RaminNietzsche wants to merge 1 commit into
Conversation
…tringify Signed-off-by: ramin.najarbashi <ramin.najarbashi@gmail.com>
|
Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run. |
Author
|
@ceph/ceph-website |
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 reflected XSS in blog search and replaces hand-built JSON templates
that could break the search index when post titles contain quotes or special
characters.
Problems
1. Reflected XSS via
?q=parameterThe raw search query from
urlParams.get('q')was interpolated into HTMLand assigned via
innerHTMLwithout escaping. A crafted URL could executearbitrary JavaScript in the visitor's browser.
2. Fragile search JSON generation
search-raw.htmlandsearch-output.htmlbuilt JSON by string concatenation.Post titles or content with
"or control characters produced invalid JSON,causing
scripts/search-index.jsto fail at build time.3. Broken fetch mode (same as #1091)
mode: 'no-cors'on same-origin fetch calls returned opaque responses,making
.json()fail on every search query.Changes
src/js/search-output.js: addescapeHtml(), usesafeQueryin output;remove
no-cors/credentials: 'include'from fetchsearch-raw.html/search-output.htmlwith.11ty.jstemplatesthat emit JSON via
JSON.stringify(){locale}-blog-post)Overlap with upstream
This overlaps with open PR #1091 (XSS + fetch fix in

search-output.js).This PR adds safe JSON generation, which #1091 does not cover.