Skip to content

fix: markdown renderer autolink neutralization bypass via HTML character references #321

Closed

Description

@jflowers

Summary

neutralizeAutolinks (internal/aireport/render_markdown.go:223) defangs only literal autolink trigger bytes (://, bare @, www.) in tool-rendered markdown. cmark-gfm (GitHub Step Summaries) resolves HTML character references (w, @, ., :, ., …) into text nodes during inline parsing, before the autolink extension post-processes the inline tree. An attacker-controlled value — e.g. a branch named www.evil.example or user@host.example — therefore reconstructs its trigger after byte-level defanging and still linkifies.

Impact

Verified live on the PR #314 branch after commit f764b07 pinned literal-trigger defanging: values echoed into the deterministic report (branch names, header metadata, table cells) can still gain autolink treatment despite neutralization, leaving the injection surface open in GitHub Step Summaries. Neither headerEscaper nor proseEscaper currently escapes &.

Disclosed in the review of #318 (.uf/dewey/learnings/input-validation-20261102T232636-jay-flowers.md); the renderer gap predates that PR.

Suggested fix (choke point)

In the escaper paths feeding neutralizeAutolinks:

  • escape & outside code spans — a backslash-escaped \& cannot open an entity reference, and entities are never interpreted inside code spans (so a naive &-escape there would display the backslash), or
  • defang &# and the named entities that decode to trigger characters alongside the literal triggers.

Test expectations

Byte-level negative fixtures pinning each entity encoding of each trigger character (www., user@, ://, . variants) so no encoder round-trip reopens the surface.

Constraints

  • Production code change — requires a spec workflow (OpenSpec change) per AGENTS.md Spec-First Development.
  • Deterministic-rendering contracts (specs/040 contracts/markdown-report.md) must stay intact: escaping changes must not alter rendered output for benign inputs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions