Repository navigation
security(review): admit judge output as untrusted input; cache keyed by the exact prompts (#644) - #652
Merged
Conversation
…by the exact prompts (#644) judge::admit clears rule_id, bounds text and count, drops files and lines the diff does not contain; applied to review and scan. The Packet now carries the finished hardened prompts, and the review cache moves behind HttpJudge keyed by those prompts, storing the raw model answer so ignore.rules, min_severity and rules are applied on cache hits too. Scan batches get an untrusted-data fence. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: ajianaz <ajianaz@users.noreply.github.com>
ajianaz
force-pushed
the
security/644-untrusted-judge-output
branch
from
October 15, 2026 05:18
1af7685 to
e65774e
Compare
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.
Closes #644. Part 3/6. Stacked on #651 (#649), which is stacked on #650 (#648): earlier commits here are those PRs; the diff shrinks as they merge.
What
judge::Packetnow carries the finished prompts (llm::ReviewPrompts: hardened system prompt + user prompt with the fenced diff), so a judge that is not the HTTP LLM gets the same defenses.judge::admit(issues, valid_files, source): the one gate for any judge's output. Clearsrule_id/also_matches, truncates text (title 300, body/fix 8000 chars), caps at 200 findings (most severe kept), drops files outside the diff/batch, and turns a line the diff/file does not contain into a file-level finding. Applied inreview_withand incora scanper batch. Deterministic findings merge after, so a judge can add but never remove.HttpJudge: stores the raw model answer keyed by the exact prompts + model/provider/base_url/temperature.cora scanwraps each batch in an untrusted-data fence (same as review).Why
Defenses against prompt injection only existed inside the HTTP path, and anything a model returned flowed to formatters, SARIF upload and history unchecked: a forged
rule_idfeeds suppression and the deterministic cap. The old cache key (diff + model + provider + base_url + temperature) ignored focus, rules, profile, sanitize,ignore.rules,hook.min_severityand could serve a stale or other-mode result.Testing
cargo fmt --check,cargo clippy --all-targets --features tree-sitter -- -D warnings,cargo test --features tree-sitter(1156 passed; new: 9admittests, hostile-output pipeline test, cache-key tests, scan fence tests).returning cached judge response), then addignore.rulesand confirm the finding disappears on a cache hit.sanitize_commentsstays review-only).