You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jul 31, 2026. It is now read-only.
CodeQL flagged a risky pattern where raw file HTML was parsed directly with DOMParser.parseFromString, which can reinterpret untrusted input as executable HTML and reintroduce XSS vectors.
The app needs to keep interactive previews (opt-in) while preserving strong sanitization for default previews to avoid executing repository scripts in the app context.
Description
Stop parsing raw fileContent directly; run DOMPurify.sanitize first and parse the sanitized HTML for the normal (static) preview using DOMParser.
Add an explicitly sanitized interactive source document that allows script tags only when interactiveHtmlPreview is enabled, and use that sanitized doc for cloneInteractiveScripts so scripts are only cloned from an already-sanitized source.
Continue to forbid inline event handler attributes and keep normal preview mode with script removed and the iframe sandboxed, with interactive mode opt-in and separately hardened.
Testing
Ran npm run build, which completed successfully and the frontend build passed.
Attempted cargo check --manifest-path src-tauri/Cargo.toml, which failed in this environment due to a missing system dependency (glib-2.0 / pkg-config), so full Rust validation requires CI or a host with that system package available.
Manual inspections verified the sanitization path and that interactive cloning is gated by the sanitized interactive document.
The PR properly addresses the CodeQL flagged XSS vulnerability:
Removed vulnerable code: The line const sourceDoc = new DOMParser().parseFromString(fileContent, "text/html") was parsing untrusted HTML content directly without sanitization
Added proper sanitization: Creates interactiveSourceDoc with DOMPurify sanitization, allowing script tags only for interactive previews
Interactive mode: Scripts allowed via ADD_TAGS, but inline event handlers (on* attributes) are still stripped by the post-processing loop at lines 1203-1209
CSP is applied via injectPreviewCsp()
Safe conditional logic: Changed from if (interactiveHtmlPreview) to if (interactiveHtmlPreview && interactiveSourceDoc) to ensure the source document exists before use
Note
The PR description mentions cargo check failed due to missing system dependencies (glib-2.0 / pkg-config). This is an environmental issue requiring CI or a host with the necessary packages, not a code issue.
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 freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
None yet
1 participant
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.
Motivation
DOMParser.parseFromString, which can reinterpret untrusted input as executable HTML and reintroduce XSS vectors.Description
fileContentdirectly; runDOMPurify.sanitizefirst and parse the sanitized HTML for the normal (static) preview usingDOMParser.scripttags only wheninteractiveHtmlPreviewis enabled, and use that sanitized doc forcloneInteractiveScriptsso scripts are only cloned from an already-sanitized source.scriptremoved and the iframe sandboxed, with interactive mode opt-in and separately hardened.Testing
npm run build, which completed successfully and the frontend build passed.cargo check --manifest-path src-tauri/Cargo.toml, which failed in this environment due to a missing system dependency (glib-2.0/pkg-config), so full Rust validation requires CI or a host with that system package available.Codex Task