Repository navigation
Description
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_injectionstrips 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.
- Offline, a scripted fake model obeys embedded instructions; each bad reply part is dropped and counted, and findings.json and findings.sarif are byte-identical with the model stages on and off.
- (person-run) One review of the corpus on the real pool records, per file, whether the model followed the text.
After its PR A, feat(cli): prompt-injection smuggling detector and canary audit (devops scan injection) #589 adds Tag-block and zero-width variants.
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
- Which model stages does the corpus test?: feat(review): each finding group gets a model-written explanation and plan grounded in the rule's documentation at the installed tool version, kept apart from findings, with every quote, citation, version and code block checked #1147's explanations and feat(review): related findings are linked by shared CWE, rule family, symbol-graph component or package, and one review-level plan orders the work across groups #1148's plan, because refactor(review): the persona review stage, the legacy segment engine and review-time RAG are deleted, and devops review builds a model client only for the explanation stages #1151 deletes the persona stage and the corpus targets the remaining model stages. [sources: docs/agent/tasks/task-417-synthetic-prompt-adversaries-for-injection-resistance.md]
- What is the relationship to feat(cli): prompt-injection smuggling detector and canary audit (
devops scan injection) #589 (prompt-injection smuggling detector)?: feat(cli): prompt-injection smuggling detector and canary audit (devops scan injection) #589 adds Tag-block and zero-width variants to the corpus after feat(ai): synthetic prompt adversaries for injection resistance #417's PR is merged; feat(ai): synthetic prompt adversaries for injection resistance #417 is the prerequisite, not the other way around. [sources: docs/agent/tasks/task-417-synthetic-prompt-adversaries-for-injection-resistance.md] - Is the person-run criterion part of the automated CI test suite?: No. It is a manual verification step performed by a person against the real model pool; it is not part of the offline CI test. (proposed) [sources: docs/agent/tasks/task-417-synthetic-prompt-adversaries-for-injection-resistance.md]
- What does the offline test's fake model do, and what is asserted about its output?: The fake model obeys the embedded instructions in the corpus files. The test asserts that each bad reply part is dropped and counted, and that findings.json and findings.sarif are byte-identical with the model stages on and off. [sources: docs/agent/tasks/task-417-synthetic-prompt-adversaries-for-injection-resistance.md]
- Does the corpus test the sanitizer directly or the full pipeline?: The full pipeline: the corpus files are run through the review pipeline (including sanitize_prompt_injection, redact_text, and the model stages), and the assertion is on the final findings output, not on the sanitizer's intermediate output. [sources: src/devops_cli/security/sanitizer.py:296-302, src/devops_cli/ai/review/runner.py:1315]
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsIn Review
Activity
dan-petty commentedon Oct 1, 2026
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.
9 remaining items
chore(main): release 0.4.0 (#1960)