Skip to content

feat(ai): synthetic prompt adversaries for injection resistance #417

Description

@dan-petty

Context & Rationale

sanitize_prompt_injection strips delimiter tags, and reviewed code is attacker-controlled in the general case — this tool is pointed at arbitrary repositories. Nothing tests whether a source file containing crafted instructions can steer a review, and the sanitizer's coverage is asserted by its own unit tests against the patterns its author thought of.

Scope & Deliverables

  • Context & Rationale*: sanitize_prompt_injection strips delimiter tags, and reviewed code is attacker-controlled in the general case — this tool is pointed at arbitrary repositories. Nothing tests whether a source file containing crafted instructions can steer a review, and the sanitizer's coverage is asserted by its own unit tests against the patterns its author thought of.
  • Deliverable*: A corpus of source files carrying embedded instructions — in comments, docstrings, string literals, filenames — run through the review pipeline with an assertion that the findings describe the code rather than following the embedded text.
  • Constraint*: This measures resistance to the attacks in the corpus and says nothing about the ones not in it. The corpus is a regression suite, not a security proof, and reporting it as the latter would be worse than not having it.

Update 2026-10-08: refinement

#1151 deletes the persona stage, so the corpus tests #1147's explanations and #1148's plan.

Proposed design

Problem statement

The review pipeline processes attacker-controlled source files, and sanitize_prompt_injection only strips delimiter tags based on patterns its author anticipated. There is no test corpus that verifies crafted instructions embedded in source files (comments, docstrings, string literals, filenames) cannot steer the model's explanation or plan output. This issue adds a regression corpus of injection-bearing source files and an offline test that proves the model stages' findings output is byte-identical whether the model stages are on or off, so that any future regression in injection resistance is caught by CI rather than discovered in the field.

Acceptance criteria

  • Criterion 1: A corpus of source files carrying embedded injection instructions in comments, docstrings, string literals, and filenames exists in the test fixtures directory.
    Verification: The fixture files are present in the repository and a test collects them; running the test suite shows the corpus is loaded and non-empty.
  • Criterion 2: An offline test runs the corpus through the review pipeline with a scripted fake model that obeys embedded instructions, and asserts that each bad reply part is dropped and counted.
    Verification: The test passes in CI: the fake model's injected-instruction reply parts are individually dropped, a counter records the number dropped, and the assertion on the counter value succeeds.
  • Criterion 3: The offline test asserts findings.json and findings.sarif are byte-identical whether the model stages (explanation and plan) are on or off.
    Verification: The test runs the pipeline twice (model stages enabled and disabled) over the same corpus and asserts byte-equality of findings.json and findings.sarif; the test passes in CI.
  • Criterion 4: A person-run review of the corpus on the real model pool records, per file, whether the model followed the embedded text.
    Verification: A person executes one review of the corpus against the real pool and records a per-file pass/fail table showing whether the model's explanation or plan repeated or acted on the embedded instructions.

Key questions

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

#1147, #1148, #1151

Activity

  1. added this to the v0.2.23 milestone on Sep 22, 2026
  2. added
    type/feature
    scope/ai
    priority/p2-medium
    on Sep 22, 2026
  3. modified the milestones: v0.2.23, v0.2.24 on Sep 28, 2026
  4. dan-petty commented on Oct 1, 2026

    @dan-petty
    OwnerAuthor

    Moved from the shipped v0.2.23 to the backlog. It is still valid (checked 2026-10-01), and P2 items don't displace P1 work in the planned releases.

  5. added
    scope/security
    type/test
    and removed
    type/feature
    on Oct 2, 2026
  6. added this to the v0.2.35 milestone on Oct 9, 2026
  7. 9 remaining items

  8. modified the milestones: v0.2.37, v0.2.38, on Oct 17, 2026
  9. added a commit that references this issue on Oct 24, 2026
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

    priority/p2-mediumscope/aiscope/securitytype/test

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions