Skip to content

Fix script tag breakout in generated HTML reports - #3

Merged
pgom merged 3 commits into
uphold:masterfrom
mertcano:mertcano-patch-1
Nov 5, 2026
Merged

pgom merged 3 commits into
uphold:masterfrom
mertcano:mertcano-patch-1

Conversation

@mertcano

@mertcano mertcano commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Summary of Changes

Resolves F19 (High) and F20 (High) from the Uphold Workspace Security Audit:

  • HTML Breakout / Stored XSS Prevention (F19 & F20):
    • Updated build_perf_map.mjs and build_lcp_map.mjs to escape </script> closing tags before injecting JSON payloads into template script elements.
    • Neutralizes DOM-based script execution vectors originating from untrusted target repository filenames and traced Chrome resource URLs.
    • Aligns HTML map generation with the defensive escaping already present in build_run_report.mjs.

Verification

  • npm test passes cleanly (6/6 self-tests, 6/6 invariant validations).
  • End-to-end artifact generation confirms inputs containing </script> are serialized as <\/script> within HTML <script> tags.

@mertcano

mertcano commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

Done! I've updated both files to use LF line endings. Thanks for catching that.

@xavi-999 xavi-999 changed the title fix(security): sanitize embedded JSON payloads against script-tag breakout in generated HTML artifacts Fix script tag breakout in generated HTML reports Nov 3, 2026
xavi-999
xavi-999 previously approved these changes Nov 3, 2026
@mertcano

mertcano commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

Since xavi-999 made the last push to this branch, GitHub blocks them from being the sole approver. Could another maintainer please review and approve this PR, and trigger the pending workflow? Thanks!

mertcano and others added 3 commits November 5, 2026 11:34
### Summary of Changes
Resolves **F19 (High)** and **F20 (High)** from the Uphold Workspace Security Audit:

- **HTML Breakout / Stored XSS Prevention (F19 & F20):**
  - Updated `build_perf_map.mjs` and `build_lcp_map.mjs` to escape `</script>` closing tags before injecting JSON payloads into template script elements.
  - Neutralizes DOM-based script execution vectors originating from untrusted target repository filenames and traced Chrome resource URLs.
  - Aligns HTML map generation with the defensive escaping already present in `build_run_report.mjs`.

### Verification
- `npm test` passes cleanly (6/6 self-tests, 6/6 invariant validations).
- End-to-end artifact generation confirms inputs containing `</script>` are serialized as `<\/script>` within HTML `<script>` tags.
Escape every `<` as `<` in all three builders, which also covers
the `<!--<script` sequence and run_report's weaker `</script>` regex.
Convert build_lcp_map.mjs to LF, add a hostile payload check to
check_invariants.mjs and update the CLAUDE.md convention.
@pgom
pgom merged commit dd2dad0 into uphold:master Nov 5, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants