fix(docs): prevent DOM XSS in LinkedIn graph demo - #2276
Open
Beverly621 wants to merge 1 commit into
Open
Beverly621 wants to merge 1 commit into
Beverly621 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
Fixes #2251.
The LinkedIn Data Discovery graph view now renders crawled and uploaded fields with DOM APIs instead of interpolating them into
innerHTML. Chat markdown is sanitized with DOMPurify, streamed text is appended as text nodes, and URL-bearing fields are limited to HTTP(S) before assignment.The OpenAI key storage behavior is intentionally unchanged because it is outside this issue.
Maintainer feedback coverage
innerHTMLrendering withcreateElement,textContent, andreplaceChildrenDOMPurify.sanitize(marked.parse(text))<br>elementsprofile_urlbefore assignmentsafeHttpUrl()and limited to HTTP(S)avatar_urlbefore assignmentsafeHttpUrl()with a trusted fallback avatar URLescapeHtml()or equivalent regex escaping is usedlocalStorageand API-key handling are intentionally unchangeddevelopp.id, which is also assigned to a profile link in sink 3, is passed through the samesafeHttpUrl()validation. This remains within the reported issue scope.List of files changed and why
docs/apps/linkdin/templates/graph_view_template.html— remove the five reported DOM XSS paths while preserving the existing UI and behavior.tests/test_issue_2251_linkdin_xss.py— cover DOM rendering, markdown sanitization, streaming text, and URL-scheme validation.How Has This Been Tested?
pytest -q tests/test_issue_2251_linkdin_xss.py(9 passed)ruff format --check tests/test_issue_2251_linkdin_xss.pyruff check tests/test_issue_2251_linkdin_xss.pynode --checkgit diff --checkChecklist: