Escape untrusted values rendered into issue/PR bodies - #9
Open
schenksj wants to merge 4 commits into
Open
Conversation
…nfig.py Prerequisite: agent package did not parse, blocking all tests. Co-Authored-By: Claude Code (VulnFix)
f.id and results_dir_name are stamped verbatim into the <!-- vulnhunt-finding-id: ... --> / <!-- vulnhunt-results-dir: ... --> footer markers. Both are attacker-influenced LLM/scan-README data, so a value containing '-->' closed the comment and injected arbitrary markdown/HTML into the rendered GitHub issue (CWE-79/CWE-116). Restrict marker values to a strict identifier charset [A-Za-z0-9._-] -- the same class the downstream parsers accept -- so a breakout is impossible while legitimate ids/dir-names survive intact. Co-Authored-By: Claude Code (VulnFix)
residual_vectors entries are LLM/finding-derived and were interpolated verbatim into the '## Residual Risk' markdown appended to the PR/issue body. The hand-wave / consistency guards reject vague or empty entries but never escape, so an entry could inject raw HTML (<script>) or a markdown link ([x](javascript:...)) into the rendered body (CWE-79/CWE-116). Neutralize each entry via html.escape + backslash-escaping the markdown link/code metacharacters so metacharacters render as literal text while benign prose survives readably. Co-Authored-By: Claude Code (VulnFix)
…down injection Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
Author
|
Adversarial review + fix applied (pushed CANON-21 (marker breakout) reviewed solid. CANON-44 review found a gap: Fix: collapse |
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 free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Escape untrusted values rendered into issue/PR bodies
Neutralizes two spots where finding-derived text is rendered into GitHub issue/PR markdown without escaping, plus the same small
config.pyprerequisite build fix. From the cross-model/vulnhuntevaluation (eval_rep/); developed test-first with the existing suites kept green.Prerequisite —
config.pycurrently doesn't parseCommit
aaad2ea.vulnhunter-agent/agent/config.pyhas an unclosed paren — thetoken_path_prefixes=tuple(...)generator is missing its),beforemax_comment_pages=int(— soimport agent.configraisesSyntaxErrorand the agent package can't be imported. Adds the missing),and a small regression test (tests/test_config.py).CANON-21 — Constrain marker values in issue-body HTML comments (CWE-79)
Commit
2615c32.vulnhunter-agent/agent/issues_render.pysubstitutesVULN_ID(andRESULTS_DIR_NAME) verbatim into HTML-comment markers like<!-- vulnhunt-finding-id: {VULN_ID} -->. These are intentionally left un-escaped so the markers stay machine-parseable, but a value containing-->would close the comment early._sanitize_marker_value()restricting marker values to[A-Za-z0-9._-]— exactly the charset the downstream parsers already accept (VULN-\d{3},..._VULNHUNT_RESULTS_[0-9A-Za-z._-]+) — applied toVULN_ID,RESULTS_DIR_NAME, and (defensively)IDEMPOTENCY_KEY. This preserves marker parsing rather thanhtml.escape, which would break the regexes.vulnhunter-agent/tests/test_issues_render.py::TestMarkerCommentBreakout. Fails on current code, passes after.CANON-44 — Escape residual-risk entries in the delivery body (CWE-79)
Commit
4949b3a.vulnhunter-fix/vulnhunter_fix/delivery.pyrenders eachresidual_vectorsentry verbatim into the## Residual Riskbullets. The existing guards reject vague/empty phrasing but don't escape markup._escape_residual_entry()(html.escape(quote=False)plus backslash-escaping of`[], matching the codebase's existing_sanitize_for_issue_bodyconvention) and apply it in the bullet join. Ordinary prose renders unchanged.vulnhunter-fix/tests/test_hand_wave_guard.py— a markup/link payload is escaped in the output. Fails on current code, passes after.Verification
vulnhunter-agent: 1113 passed, 1 skippedvulnhunter-fix: 548 passed, 9 skipped🤖 Generated with Claude Code