Repository navigation
fix: markdown renderer autolink neutralization bypass via HTML character references - #339
Conversation
Spec artifacts for fixing the markdown renderer autolink neutralization bypass via HTML character references (issue unbound-force#321): cmark-gfm resolves character references into text nodes before the autolink extension post-processes the inline tree, so entity-encoded triggers reconstruct after byte-level defanging. The change backslash-escapes & at the three non-code-span sinks, keeps code-span content verbatim, and pins every entity encoding family with byte-level negative fixtures. Phase 1 of the v2.4.0 release plan (unbound-force#337); the OpenSpec change lands before the renderer fix per the spec-first development process.
…ter references cmark-gfm decodes HTML character references before autolink extension, so an attacker-controlled branch or path like `&unbound-force#119;ww.evil.example` reconstructs a `www.` trigger after `neutralizeAutolinks` byte defanging and would linkify in the GitHub Step Summary. - Add "&" → "\&" to headerEscaper/proseEscaper and split plain-cell path via escapeAmp in escapeCell; tableName code spans keep "&" verbatim (backtick spans never interpret references, so escaping would display) - Add byte-level entity fixture matrix (decimal, hex x/X/mixed-case, named, hybrid literal-plus-entity) pinning exact escaped output per sink and render-level hostile-value tests with scanner preconditions - Verify benign parity R&D → R\&D and verbatim-entity a&b → a\&b, literal-trigger defanging unchanged, goldens byte-identical Assisted-by: Muse-Spark-Open-816B-A42B-NVFP4 Generated with AI assistance (Muse-Spark-Open-816B-A42B-NVFP4)
uf-divisor
left a comment
There was a problem hiding this comment.
Council Review: APPROVE WITH ADVISORIES
7/7 reviewers succeeded — 6 APPROVE, 1 APPROVE WITH ADVISORIES (divisor-curator). No CRITICAL or HIGH findings.
| Reviewer | Verdict | Findings |
|---|---|---|
| divisor-adversary | APPROVE | 0 |
| divisor-architect | APPROVE | 0 |
| divisor-curator | APPROVE WITH ADVISORIES | 1 LOW |
| divisor-entropy | APPROVE | 0 |
| divisor-gaze-testing | APPROVE | 0 |
| divisor-guard | APPROVE | 0 |
| divisor-testing | APPROVE | 0 |
Summary
Backslash-escapes & at all three non-code-span sinks (headerEscaper, proseEscaper, and the plain-cell path via new escapeAmp layered on the shared escapeCellMarkup), closing the cmark-gfm character-reference bypass of neutralizeAutolinks (#321) across decimal, hex, named, and hybrid entity encodings. Code-span content stays verbatim — character references are never interpreted inside code spans — and golden output for benign input is byte-identical.
Findings
- LOW (divisor-curator, informational): Documentation-completeness triage confirms no README, AGENTS.md, CHANGELOG, or website updates are required — internal-only security hardening with no user-facing behavior change for benign input; the OpenSpec proposal explicitly flags docs as unchanged. No action needed. (Inline comment attached.)
CI
All 6 checks pass (Gaze AI Report, MegaLinter, Unit + Integration Go 1.24/1.25, E2E Go 1.24/1.25).
This review was generated by /uf.review-pr (AI-assisted).
Summary
Fixes the markdown renderer autolink neutralization bypass via HTML character references (#321, epic #337 Phase 1).
cmark-gfm resolves HTML character references (
w,@,:,., …) into text nodes before the autolink extension post-processes the inline tree, so attacker-controlled values (branch names, module paths, table cells) likewww.evil.exampleoruser@host.examplereconstructed their autolink trigger afterneutralizeAutolinks' byte-level defanging and still linkified in GitHub Step Summaries.What changed
&inheaderEscaperandproseEscaper, and add anescapeAmplayer to the plain-cell path (escapeCell) — a backslash-escaped&cannot open an HTML character reference, so cmark-gfm cannot decode entity-encoded autolink triggers after byte-level defanging.tableName's code spans keep&verbatim: entities are never interpreted inside code spans, and escaping there would display the backslash.w.@:/) × every encoding family (decimal numeric, hex lowercase/uppercase/mixed-case digits, named references, hybrid literal-plus-entity) across all three sinks, asserting exact escaped output bytes (epic rule: negative fixtures for each entity encoding of each trigger character).&scanner outside code spans.neutralizeAutolinksuntouched.Landed via OpenSpec change
markdown-autolink-entity-bypass(proposal/design/spec/tasks pushed at 742a422 before implementation, per the spec-first rule).Verification
go build ./...✓go test -race -count=1 -short -timeout 15m ./...— 22 packages ok, 0 failuresgolangci-lint run— 0 issuesopenspec validate markdown-autolink-entity-bypass— validCloses #321