Skip to content

security(review): treat judge output as untrusted input; self-contained Packet; correct cache key #644

Closed

Description

@ajianaz

From the architecture audit. Part 3 of 6. Must land before the Agent adapter (6/6). Depends on 2/6.

Problem

Defenses against prompt injection only exist inside the HTTP path: harden_system_prompt, the diff fence (fence_for), comment_sanitizer, hallucinated-path filter. A caller that builds its own prompt from a packet loses them, and anything a judge returns (title, body, suggested_fix) flows to formatters, SARIF upload, history and MCP responses. Specific gaps:

  • rule_id is deserialized from model output (types.rs), then feeds inline_suppress, ignore.rules matching and the deterministic cap.
  • No bounds on issue count, title/body/suggested_fix length or line range; line is never checked against hunks; scan has no path guard, no fence, no sanitizer.
  • Cache key (cache.rs) is diff + model + provider + base_url + temperature only. focus, rules, profile, sanitize_comments, ignore.rules, min_severity (baked into cached should_block) and cora version do not invalidate it; nothing separates "LLM found nothing" from "no LLM ran".

Proposal

  • Packet is self-contained: carries the hardened system prompt, fence, sanitized text, valid_files (and the claim warning).
  • finalize treats any judge output as untrusted: clear rule_id, enforce bounds, path/line validation, judge can add findings but never remove deterministic ones.
  • Cache moves behind the HttpLlm adapter and keys on a hash of the whole Packet plus adapter id; never read/written for None or Agent.

Done when

  • Tests: forged rule_id, oversized body, out-of-diff file/line, and injection-looking text in findings are neutralized in finalize.
  • Changing focus/rules/profile/sanitize invalidates the cache; a deterministic-only result is never served as an LLM review.

Activity

  1. ajianaz commented on Oct 15, 2026

    @ajianaz
    CollaboratorAuthor

    Series map (sequential, one PR each): 1/6 finalize #648 → 2/6 prepare/judge/finalize #649 → 3/6 untrusted judge output + cache #644 → 4/6 scan deterministic family #645 (can parallel 3/6) → 5/6 select_judge #646 → 6/6 MCP agent tools + skill #647.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    scope:coresecurity

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions