Repository navigation
fix(report): escape site-controlled text in the Markdown report (squirrelscan/repo#3522) - #1186
Conversation
|
Review of the diff only. I could not run the tests: dependencies are not installed in my sandbox. The approach is sound. A shared escape module, a real CommonMark parser in the tests, a test that checks the exploit works on unescaped input, and the
|
a9b44e9 to
0079749
Compare
|
Review of #1186 (Markdown escaping for crawled text). I read the diff only and did not run the tests. The shared helper is a clear improvement. It is easier to reason about than the old per-sink escapes. The escape set, the destination encoding, the
Tests: the new No critical or high findings. |
|
Solid fix: one shared escaping module, and the tests parse the output with a real CommonMark renderer and include a guard proving the repro injects when left raw. I found no blocking problems. Notes below; I did not run the tests, only read the diff.
|
…ts, item rows, partial reason, URL line, tech version (squirrelscan/repo#3522) One shared helper module (output/markdown-escape.ts) escapes link labels and plain values, percent-encodes link destinations, links only http(s) and root-relative URLs, and fences code spans past any backtick run. A stored report's generator version prints on the scan line only when it is version-shaped. Signed-off-by: Nik Cubrilovic <[email protected]>
…ile, tech name and alt; leading block markers; entity-shaped & in destinations (squirrelscan/repo#3522 review) Signed-off-by: Nik Cubrilovic <[email protected]>
…'s property cell is a pipe-safe code span (squirrelscan/repo#3522 review round 2) Signed-off-by: Nik Cubrilovic <[email protected]>
…ookalike instead of backslash-escaping it (CodeQL js/incomplete-sanitization; squirrelscan/repo#3522) A backslash before a pipe inside a code span does not survive a value that already holds a backslash: 'a\|b' still split its GFM table cell. Each | is now shown as U+00A6, so no backslash is inserted at all. Signed-off-by: Nik Cubrilovic <[email protected]>
b3b9643 to
c5790af
Compare
|
Review of the Markdown escaping change. I read the diff but did not run the tests or the linters. The approach is sound. The escaping sits in one module,
Test coverage is good. It covers the repro, the sinks, the line-break and HTML-block cases, and the helper unit tests. The suite should still be run once with the revert-the-fix check from AGENTS.md, which the Docs: none. Skill: none. |
…eses, !, bare &) (#1203) The escaping from #1186 also wrote backslashes into plain sentences (recommended: 30-60 became \(recommended: 30-60\)). Every link, image and reference definition needs an unescaped [, and [ ] stay escaped, so ( ) ! cannot form anything. Still escaped: backslash, [ ], backtick, <, |, entity-shaped &, leading block markers. Hostile-input tests unchanged and green. Refs repo#3522. Docs: none. Skill: no change.
Fixes the main-branch half of squirrelscan/repo#3522: text the audited site controls reached the Markdown report (
squirrel report --format markdown,squirrel audit -f markdown) unescaped. A page URL such ashttps://example.com/a](https://evil.example/x)(new URL().pathnamekeeps] ( ) ! [) closed the page-list link early and added a link and a remote image to the report a reader opens.One shared helper
packages/report/src/output/markdown-escape.ts:escapeMarkdownText: link labels and plain values.\ [ ] ( ) !+ "" +< > & |`.# - + * _ ~ =,1.), so a label after-cannot open a heading, rule, fence or nested list.*,_and~are otherwise left alone: they only emphasise, and URL paths full of underscores are read raw by agents.escapeMarkdownCell: the same escapes for a table cell, with line breaks as<br>, as before. It replaces the old localescapeMarkdownTableCell.escapeMarkdownDestination: link destinations.\ ( ) < > [ ]+ "" +`, whitespace and control characters.&.!(inert in a destination, and%21is not the same URL under RFC 3986) and plain query&separators.markdownLink(label, url): links only an http(s) URL or a root-relative path. Ajavascript:,data:or//hostURL in a stored report stays plain text.markdownCodeSpan: fences past the longest backtick run inside the value.escapeHtmlText: values inside raw HTML (<summary>,alt).Sinks fixed
from:source pages;<details><summary>, and in the "not listed" line;**URL:**line;altand version.entityCell(the Entities section and the entity diff) now escapes brackets,!,<and backticks as well as the pipe. The conflicting property goes in a safe code span.0.0.137,0.0.137-beta.1still print).Not in this PR
fixRollupLine,siteResourceFixLine) exist only onsplit/926-b-report(feat(report,rules): link sections, component-aware findings, fix rollups, Page structure (3/3 of #926) #1181), not on main. Agreed with the feat(report,rules): link sections, component-aware findings, fix rollups, Page structure (3/3 of #926) #1181 owner: feat(report,rules): link sections, component-aware findings, fix rollups, Page structure (3/3 of #926) #1181 is held (order feat(classifier): bundled page classifier, link sections on parsed links, sqlite migrations 37/38 (1/3 of #926) #1179, feat(rules): schema/expected-type, breadcrumb reads classified links (2/3 of #926) #1180, feat(report,rules): link sections, component-aware findings, fix rollups, Page structure (3/3 of #926) #1181), so this PR is expected to land first. The feat(report,rules): link sections, component-aware findings, fix rollups, Page structure (3/3 of #926) #1181 rebase then routes its new sinks (the fix-rollup and site-resource outputs, page list, item rows andescapeItemLabel) throughmarkdown-escape.ts, with a hostile-URL test per sink. If feat(report,rules): link sections, component-aware findings, fix rollups, Page structure (3/3 of #926) #1181 lands first instead, I rebase this PR onto it and do that wiring here.Tests
packages/report/tests/markdown-crawled-text-3522.test.ts, 17 tests.Bun.markdown.html), and asserts nohreforsrcpoints at the attacker host.example.comandevil.exampleonly.Ran 28 report test files and 4 CLI test files that render Markdown, entities or the scan line: 0 fail.
tsgo --noEmitis clean inpackages/reportandapps/cli.Independent review (Sonnet, high effort), three rounds:
<summary>, the logoalt) could end the HTML block. Fixed in the third commit:escapeHtmlTextnow flattens line breaks. The entity diff's property cell also became a pipe-safe code span (entityCodeCell).Fixed after review (CodeQL
js/incomplete-sanitization):entityCodeCellshowed a pipe as\|, which a value already holding a backslash defeated (a\|bstill split the cell). It now shows each|as¦(U+00A6) inside the code span, with no backslash inserted, and a test asserts the row keeps its two cells.The commits after the first also widened the CHANGELOG entry to cover the added sinks.
CHANGELOG.md: Security entry under[Unreleased].Docs: none needed (output escaping only; no flag or format changes). Skill: no change needed.