Repository navigation
Description
Context & Rationale
normalize_unicode_text (src/devops_cli/ai/text_utils.py:36-41, NFKC plus a 23-entry table dropping only U+200B/U+FEFF) runs on model output (ai/review_schema.py:119-181), not reviewed input. sanitize_prompt_injection (security/sanitizer.py:296-302) and sanitize_prompt_boundary_tags (sanitizer.py:284-293, wrapping review prompts at ai/review/runner.py:1315) match tag names only; <|im_start|>, [INST], <<SYS>>, Tag-block, zero-width and bidi characters pass. Reviewed files are read errors="replace" (runner.py:1292) then redact_text (runner.py:1494), credential masking only; PR posting (commands/review.py:645-661) checks nothing outbound. write_sarif is called only at commands/scan.py:839; scan sarif (scan.py:855-901) ingests any SARIF 2.1.0 under --suppress/--fail-on, keying rule ids from bracketed titles (security/normalization.py:29-32,171-185). vibes tools/prompt_injection_scanner.py has INJ001 Tag-block decode (line 214), INJ002/INJ003/INJ005 and a CanaryTokenManager (audit_response, line 185, EGR005); vibes observations/systems/10-mcp-protocol-boundaries-and-stateless-transport-constraints.md:53,125 names tool return strings as MCP's untaggable channel.
Scope & Deliverables
- Context & Rationale*:
normalize_unicode_text(src/devops_cli/ai/text_utils.py:36-41, NFKC plus a 23-entry table dropping only U+200B/U+FEFF) runs on model output (ai/review_schema.py:119-181), not reviewed input.sanitize_prompt_injection(security/sanitizer.py:296-302) andsanitize_prompt_boundary_tags(sanitizer.py:284-293, wrapping review prompts atai/review/runner.py:1315) match tag names only;<|im_start|>,[INST],<<SYS>>, Tag-block, zero-width and bidi characters pass. Reviewed files are readerrors="replace"(runner.py:1292) thenredact_text(runner.py:1494), credential masking only; PR posting (commands/review.py:645-661) checks nothing outbound.write_sarifis called only atcommands/scan.py:839;scan sarif(scan.py:855-901) ingests any SARIF 2.1.0 under--suppress/--fail-on, keying rule ids from bracketed titles (security/normalization.py:29-32,171-185). vibestools/prompt_injection_scanner.pyhas INJ001 Tag-block decode (line 214), INJ002/INJ003/INJ005 and aCanaryTokenManager(audit_response, line 185, EGR005); vibesobservations/systems/10-mcp-protocol-boundaries-and-stateless-transport-constraints.md:53,125names tool return strings as MCP's untaggable channel. - Deliverable*: PR A (additive): pure-function
security/prompt_injection.pywith INJ001 Tag-block decode, INJ002 format-character runs (unicodedata.category(c) == "Cf"), INJ003 delimiters (escaped, never deleted) and INJ005 exfiltration links; titles carry the bracketed rule id, sonormalize_finding/write_sarifare untouched. Adddevops scan injection <target>and ascan_injectionMCP tool with their own--sarif/--suppress/--fail-on, callingwrite_sarifand_load_policy_or_exit(scan.py:758) directly since_create_default_scanners(security/registry.py:16-44) is subprocess-only (separate refactor). PR A also adds RuffPLE2502,PLE2510,PLE2512–PLE2515,RUF001–RUF003topyproject.toml:76(PLE2511does not exist). PR B (hot path): call the module from_collect_file_blocks/_build_path_promptand diff pages, adding findings, not normalizing; a per-runsecrets.token_hexcanary in the review system prompt,audit_responseover every finding'stitle/description/fixand the comment body beforepull.create_issue_comment(commands/review.py:661); a hit fails the run (EGR005). Review auto-fix/apply-patch was removed in feat(review): remove unverified auto-fix and apply-patch claims (#601) #624 (Item feat(cli): one verdict writer, cited refutations and no unverified fix claims #601), so the run generates no patches and there is no patch surface to audit. Port the rule taxonomy,decode_unicode_tags, delimiter list and canary shape; not INJ004 (flags every security test) or EGR001–EGR004 (duplicateredact_text/Gitleaks). Rejected (PyPI metadata): llm-guard 0.3.16 pulls torch/transformers/presidio-analyzer; rebuff last released 0.1.1 (2024-01-20). No maintained lightweight equivalent exists; stdlibunicodedataplus Ruff is the adopt path. - Constraint*: Stripping is the wrong primitive: U+200C/U+200D are load-bearing in emoji, Indic and Arabic text. The review-side detector reports and continues; only a canary leak fails. Exempt U+E0000 (category Cn) and emoji tag sequences ending U+E007F by construct and offset, not extension. Its own fixtures will contain delimiters, so
scan injectionhonourssecurity/suppression.pyvia--suppress. The canary catches only a verbatim echo: a regression tripwire, not a proof. Audit for the token, not the guard block; never log it (ai/mcp/dispatcher.py:20-31CodeQL history). Sequence: PR A; then extend the Synthetic Prompt Adversaries corpus with Tag-block/zero-width variants; a later MCP item can import this module for_run_mcp_cmd(ai/mcp/server.py:45-77) output. - Measured*:
.venv/bin/pythonwalk oversrc,tests,docs,scripts,k8s,.github,AGENTS.md,.pre-commit-config.yaml,pyproject.toml: 1277 UTF-8 text files, none containing zero-width, Tag-block or bidi code points. Same probe:normalize_unicode_textpasses 28 of 28 Tag-block characters (U+E0020–U+E003B) and both sanitizers leave<|im_start|>,[INST],<<SYS>>unchanged.grep -rn -i canary src/ tests/: 13 lines, all Argo.ruff --version0.16.8;ruff ruleconfirms the listed PLE/RUF ids exist andPLE2511does not. - Source*: vibes
tools/prompt_injection_scanner.py,docs/ROADMAP.md(lines 167–173),observations/systems/10-mcp-protocol-boundaries-and-stateless-transport-constraints.md
Update 2026-10-08: refinement
The gap stands. RUF runs since v0.2.26 (pyproject.toml:102), so PR A adds only PLE2502, PLE2510, PLE2512-PLE2515. The detector call sites moved: ai/review/runner.py:1524-1538, :1735, :1755, :1938, :1987; ai/review/classification.py:318-330. No item exists for the MCP consumer, so it stays out of scope. The prompt-echo failure gets its own admission reason, apart from canary-failed (review/admission.py:99).
Proposed design
Problem statement
The devops-cli lacks a mechanism to detect and prevent prompt-injection smuggling attacks, which can bypass existing sanitization measures. This vulnerability allows attackers to inject malicious content through zero-width characters, tag-blocks, and other Unicode manipulations that are not currently filtered out during review or scan processes.
Acceptance criteria
- Criterion 1: A new
devops scan injectioncommand is added that can detect prompt-injection smuggling attacks
Verification: Runningdevops scan injectionproduces SARIF output with findings for detected injection attempts - Criterion 2: The injection detector identifies Tag-block characters (U+E0020-U+E003B) and reports them as INJ001 findings
Verification: A test file containing Tag-block characters triggers an INJ001 finding in the SARIF output - Criterion 3: The injection detector identifies format-character runs (Unicode category Cf) and reports them as INJ002 findings
Verification: A test file containing format characters triggers an INJ002 finding in the SARIF output - Criterion 4: The injection detector identifies delimiters that are escaped but not deleted and reports them as INJ003 findings
Verification: A test file containing delimiter sequences triggers an INJ003 finding in the SARIF output - Criterion 5: The injection detector identifies exfiltration links and reports them as INJ005 findings
Verification: A test file containing URL-like patterns that could be used for exfiltration triggers an INJ005 finding in the SARIF output - Criterion 6: The system includes a canary audit mechanism that fails the review run when injection is detected
Verification: When a scan injection detects an attack, it returns a non-zero exit code indicating failure
Key questions
- What are the specific Unicode character sequences that need to be detected for prompt-injection smuggling?: The detector needs to identify Tag-block characters (U+E0020-U+E003B), format-character runs (Unicode category Cf), delimiters that are escaped but not deleted, and exfiltration links. [sources: src/devops_cli/ai/text_utils.py:36-41]
- What Ruff rules need to be added to enforce injection detection?: Ruff PLE2502, PLE2510, PLE2512-PLE2515, and RUF001-RUF003 rules need to be added to pyproject.toml [sources: pyproject.toml:76]
- Should the injection detection also check auto-fix patches?: No, auto-fix/apply-patch was removed in feat(review): remove unverified auto-fix and apply-patch claims (#601) #624, so the run generates no patches and there is no patch surface to audit. [sources: src/devops_cli/ai/text_utils.py:36-41]
- What should happen when an injection is detected during a review?: When an injection is detected, the review run should fail with EGR005 error code. [sources: src/devops_cli/ai/text_utils.py:36-41]
Open questions
- How will the new injection detection be integrated into existing review processes? (missing verified source)
Fit
Needs splitting into 2 items:
- PR A: Add pure-function security/prompt_injection.py with injection detection rules and devops scan injection command
- PR B: Integrate injection detector into review hot paths and add canary audit mechanism
Suspected block
None.
Dependencies
None.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
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.
dan-petty commentedon Oct 2, 2026
More evidence for this issue from the devsecops review session
20261001-224227(2026-10-02). Each finding below was triaged againstrelease/v0.2.25(c279c18), judged real and covered by this issue, and then upheld by a second agent that tried to refute it.src/devops_cli/security/sanitizer.py:284, re-rated LOW): The roadmap text accurately describes an open backlog item. The gap is real: src/devops_cli/security/prompt_injection.py doesn't exist,devops scan injectiondoesn't exist, and the sanitizers match tag names only, so Tag-block, zero-width and bidi characters and chat-template delimiters in reviewed (untrusted) files reach the review prompt unflagged. Open issue feat(cli): prompt-injection smuggling detector and canary audit (devops scan injection) #589 ('prompt-injection smuggling detector and canary audit (devops scan injection)') covers it.dan-petty commentedon Oct 8, 2026
Linked: #417. This item detects smuggled instructions; #417's adversarial corpus tests resistance and gains Tag-block and zero-width variants after this item's PR A. Found by the 2026-10-08 backlog review.
dan-petty commentedon Oct 17, 2026
Proposal needs splitting into 2 items at 3dd7fa6 (see proposed design in issue body).