Skip to content

feat(review): defend against adversarial source-code comments (ALIBI) - #526

Merged
ajianaz merged 2 commits into
developfrom
feat/alibi-comment-sanitizer
Aug 25, 2026
Merged

feat(review): defend against adversarial source-code comments (ALIBI)#526
ajianaz merged 2 commits into
developfrom
feat/alibi-comment-sanitizer

Conversation

@ajianaz

@ajianaz ajianaz commented Aug 25, 2026

Copy link
Copy Markdown
Collaborator

What

Defend the LLM review pipeline against adversarial source-code comments (ALIBI attack, arXiv:2607.24964). Adversarial comments with fabricated tool-result claims ('sanitizer passed', 'already validated') steer LLM reviewer reasoning with >90% attack success; prompt-level 'ignore comments' instructions are proven ineffective.

  • New comment_sanitizer module:
    • Claim flagging (always on) — added comments asserting verification or tool results are surfaced in review context as untrusted claims
    • Comment stripping (opt-in)review.sanitize-comments: true in .cora.yaml strips comment bodies from added diff lines with quote-aware marker detection (//, leading #, -- after whitespace, leading ;); line numbers preserved via [comment removed] markers
  • Deterministic scanners (rules, secrets, security patterns) always run on the original unsanitized diff — only the LLM prompt receives sanitized text
  • SECURITY.md threat model section + docs/configuration.md entry

Why

Closes #524. Issue #524 tracks applying the ALIBI research findings to harden the review pipeline. The defense is architectural (remove/flag the adversarial text) rather than prompt-level, per the paper's evaluation of adaptive attacks.

Testing

  • 9 unit tests in comment_sanitizer covering: marker detection, string-literal false-positive guard (URLs), claim detection, decrement-operator guard (i-- not stripped), SQL/ASM markers, render round-trip
  • Full suite: 889 + 16 + 6 tests passing
  • cargo fmt + cargo clippy --all-targets -- -D warnings clean
  • Pre-commit cora review: initial run caught 2 MAJOR issues (scanner isolation, decrement stripping) — both fixed and re-scan clean

LLM reviewers are highly vulnerable to adversarial comments in the code
under review — fabricated tool-result claims ('sanitizer passed', 'already
validated') steer reviewer reasoning with >90% attack success across 125
real-world vulnerabilities (arXiv:2607.24964). Prompt-level 'ignore
comments' instructions are proven ineffective against adaptive attacks.

Architectural defenses (issue #524):
- comment_sanitizer module: strip comments from added diff lines
  (opt-in, review.sanitize-comments) with quote-aware marker detection
  (//, leading #, --, leading ;) — line numbers preserved
- Claim flagging (always on): added comments asserting verification or
  tool results are surfaced in review context as untrusted claims
- Deterministic scanners (rules, secrets, security) always run on the
  unsanitized diff
- SECURITY.md threat model section + configuration docs

Refs #524
…crement ops

- Rules/secrets/security scanners now parse the original diff; only the
  LLM prompt receives the sanitized text (matches documented behavior)
- '--' marker requires preceding whitespace/line-start so C/C++
  decrement (i--) is not stripped as a comment
- Add regression test for decrement guard

Refs #524
@ajianaz
ajianaz merged commit cf2bc30 into develop Aug 25, 2026
17 of 18 checks passed
@ajianaz
ajianaz deleted the feat/alibi-comment-sanitizer branch August 25, 2026 05:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Security: harden review pipeline against adversarial code comments (ALIBI, arXiv:2607.24964)

1 participant