Repository navigation
fix(security, parser): prevent Marp script XSS and frontmatter line offset collision - #106
Merged
Merged
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
Addresses adversarial audit findings regarding Marp script extraction XSS vulnerability and Quick Edit frontmatter line offset collisions:
Marp Script Sanitization & XSS Prevention (
src/markdown/marpRenderer.ts):data-marp-auto-scaling,marpitSVGPolyfill,marp-auto-scaling) to be extracted intoscripts/marpJs.<script>tags inside Marp Markdown content from being extracted and executed in the Webview.Quick Edit Line Offset Collision Prevention (
src/markdownDiff.ts):getLineOffset(original, content), if frontmatter is present at the beginning of the file, search starts past the frontmatter block (fmMatch[0].length).desc: TargetBodyWord) and body text from colliding and generating erroneousdata-lineattributes.Security & Parser Unit Tests (
src/test/unit/security.test.ts):prevents XSS via user-supplied <script> in Marp documents: Verifies user<script>tags are not extracted intomarpJsand are safely escaped in webview HTML.prevents frontmatter offset collision with body content: Verifiesdata-linecorrectly maps to the body line index rather than colliding with frontmatter keys/values.Verification
tsc -p ./): 0 errorsnode esbuild.js --sourcemap): passedeslint src): 0 errorsmocha "./out/test/unit/**/*.test.js"): 294 passing