Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,29 @@ All notable changes to this project are documented here. The format follows
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Added

- **DET-009 `speaker_notes`**: directive/injection content in PowerPoint speaker notes. Notes were
already parsed (`element="notes"`) but nothing scored them, so a deck whose only injection was a
plain-text instruction in the notes scanned clean and was allowed. HIGH for an explicit
override/"do not tell" payload, MEDIUM for a system-addressed or verdict-directing one; the notes
run is defused on quarantine.
- **Reproducible DET-008 measurements**: an `AMBIGUOUS_CORPUS` pinned in
`tests/detectors/test_comment_directive.py` (4 legit notes that are reported on purpose, counted as
accepted false positives) and `scripts/probe_comment_directive.py`, the committed live
false-positive probe (build output excluded by default, `--include-build` to include it). The README
and `docs/comment-directive-coverage.md` figures now come from these artifacts.

### Fixed

- **PPTX paragraph coordinates**: the parser used the slide number as `TextParagraph.index`, so every
text box (and the notes) on a slide shared one coordinate. A single hidden run therefore matched
every run on the slide, and `sanitize --mode redact` replaced the whole slide with `[REDACTED]`.
Indices are now unique per paragraph; the slide number remains in `raw["slide"]`.
- DET-008 detector docstring said "0/45 benign comments"; the pinned corpus holds 46.

## [0.2.1] — 2026-09-20

Fixes merged from `main` (PR #1, `fix/dev-review-findings`) that this branch now builds on:
Expand Down
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: test lint typecheck build demo
.PHONY: test lint typecheck build demo probe

test:
.venv/bin/pytest -q
Expand All @@ -14,3 +14,6 @@ build:

demo:
.venv/bin/python examples/scan_demo.py

probe:
.venv/bin/python scripts/probe_comment_directive.py .
27 changes: 21 additions & 6 deletions README.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
[![CI](https://github.com/sscodeai/aiitg/actions/workflows/ci.yml/badge.svg)](https://github.com/sscodeai/aiitg/actions/workflows/ci.yml)
[![Python 3.11+](https://img.shields.io/badge/python-3.11%2B-blue.svg)]()
[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)]()
[![Tests](https://img.shields.io/badge/tests-330%20passed-brightgreen.svg)](.github/workflows/ci.yml)
[![Tests](https://img.shields.io/badge/tests-339%20passed-brightgreen.svg)](.github/workflows/ci.yml)
[![arXiv](https://img.shields.io/badge/arXiv-2507.06185-red.svg)]()

---
Expand Down Expand Up @@ -55,7 +55,7 @@ Untrusted input (docx/xlsx/xls/pdf/html/pptx)
│ FormatRegistry → parser → ParsedDocument │
│ (format-agnostic intermediate model) │
│ │
│ Detector chain (8 detectors) │
│ Detector chain (9 detectors) │
│ → Evidence list (coordinate-level) │
│ │
│ Sanitizer (strip / redact) │
Expand Down Expand Up @@ -93,6 +93,7 @@ Untrusted input (docx/xlsx/xls/pdf/html/pptx)
| DET-006 | annotations | Word コメント、PDF 注釈、HTML コメント | LOW |
| DET-007 | document_meta | メタデータ、VBA マクロ、JS シグナル | LOW |
| DET-008 | comment_directive | 普通のコードコメント、またはエージェントのルールファイルに隠された危険な指示。指示フレーム(マーカー / モデルへの呼びかけ / 命令形 / 権威の主張 / 検証を省けという指示)と、論文 Appendix A の 10 種の脆弱性クラスのいずれかが同時に揃ったときに発火 | CRITICAL · HIGH · MEDIUM |
| DET-009 | speaker_notes | PowerPoint の講演者メモにある指示・注入。機械は読むが、発表時には表示されない | HIGH · MEDIUM |

### 対応形式

Expand All @@ -117,7 +118,7 @@ aiitg scan report.docx --format json # JSON evidence report
aiitg scan report.xlsx --min-severity high # high 以上の finding のみ
aiitg scan report.pdf --format rich # ターミナル表形式
aiitg scan ./inbox --recursive --jsonl # ディレクトリ一括スキャン。1 行 1 compact JSON
aiitg list-detectors # 8 個の検出器を一覧表示
aiitg list-detectors # 9 個の検出器を一覧表示
```

終了コード: `0` = clean · `1` = 閾値以上の finding あり · `2` = 使用方法エラー · `3` = パースエラー(CI 向け)。
Expand Down Expand Up @@ -207,18 +208,32 @@ aiitg hook pretooluse < payload.json # deny(POL-001): ファイルは
|---|---|
| 攻撃コーパス(10 クラス × 3 フレーミング + エージェント向け 2 件。うち 2 件は論文から逐語) | 32/32 検出、29 CRITICAL / 3 HIGH |
| 良性コーパス(通常の作業コメント 46 件、5 つのコメント記法) | 誤検知 0 |
| 実在のサードパーティソース走査(本プロジェクト + `takumi/packages`: 167 ファイル、コメント 4,643 行) | 検出 0 |
| ペイロードと同じ形をした正当なメモ(`# TODO: use DBMS_SCHEDULER for the nightly job`) | 検出する(意図的な fail-closed) |
| 曖昧コーパス(ペイロードと同じ形をした正当なメモ 4 件、テストに固定) | 4/4 検出 — 受け入れた**誤検知クラス**(意図的な fail-closed) |
| 実在ソース走査(`scripts/probe_comment_directive.py`、本プロジェクト + `takumi/packages`、ビルド成果物は除外: 106 ファイル / コメント 738 行) | 検出 0 |

曖昧コーパスの 4 件は *正当な* メモであり、それでも報告されます。これは検出ではなく既知の誤検知として計上し、
コーパスが実際よりきれいに見えることはありません。実在ソース走査の数値はコミット済みスクリプトで再現できます(§6)。
以前の「167 ファイル / コメント 4,643 行」はビルド成果物(`dist/`)を含み、コメント行の数え方も緩かったものです——
`--include-build` で 168 ファイルになりますが、生成物は開発者が読むサードパーティソースではないため既定で除外します。

正直な境界: 論文の 700 件コーパスは HTML と一緒に公開されていないため、この数値は論文の数値の**再現ではありません**。
決定的なパターン検出器は原理的に不完全です(論文自身の最強スクリーナーでも約 1/3 を見逃しています)。
また DET-008 が読むのは *指示* であり、モデルが既に書いた脆弱なコードではありません(それは SAST の役割です)。
設計と既知のギャップ: [`docs/comment-directive-coverage.md`](docs/comment-directive-coverage.md)。

### 講演者メモ(DET-009)

スライドの講演者メモは発表時には表示されませんが、ファイルには残り、あらゆる抽出器——つまり要約する LLM——が読みます。
`pptx` は以前からメモをパースしていましたが、それを採点する検出器がなく、メモだけに平文の指示を仕込んだデッキは
検出 0 の clean として通過していました。DET-009 はこのチャネルを塞ぎます。読み手(モデルまたは人間)に指示しようとする
メモを報告し(明示的な上書き /「伝えるな」は HIGH、システム宛や結論を誘導するものは MEDIUM)、quarantine 時にはメモの run を
無効化します。「ロードマップのスライドを更新する」といった一般的なリマインダーは報告しません。DET-008 と同様に
パターン検出器であり、チャネルは覆いますが語彙は網羅的ではありません。

## テスト

```bash
make test # 330 tests
make test # 339 tests
make lint # ruff
make typecheck # mypy
make build # wheel/sdist をビルド
Expand Down
29 changes: 21 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
[![CI](https://github.com/sscodeai/aiitg/actions/workflows/ci.yml/badge.svg)](https://github.com/sscodeai/aiitg/actions/workflows/ci.yml)
[![Python 3.11+](https://img.shields.io/badge/python-3.11%2B-blue.svg)]()
[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)]()
[![Tests](https://img.shields.io/badge/tests-330%20passed-brightgreen.svg)](.github/workflows/ci.yml)
[![Tests](https://img.shields.io/badge/tests-339%20passed-brightgreen.svg)](.github/workflows/ci.yml)
[![arXiv](https://img.shields.io/badge/arXiv-2507.06185-red.svg)]()

---
Expand Down Expand Up @@ -56,7 +56,7 @@ Untrusted input (docx/xlsx/xls/pdf/html/pptx)
│ FormatRegistry → parser → ParsedDocument │
│ (format-agnostic intermediate model) │
│ │
│ Detector chain (8 detectors) │
│ Detector chain (9 detectors) │
│ → Evidence list (coordinate-level) │
│ │
│ Sanitizer (strip / redact) │
Expand Down Expand Up @@ -94,6 +94,7 @@ Untrusted input (docx/xlsx/xls/pdf/html/pptx)
| DET-006 | annotations | Word comments, PDF annotations, HTML comments | LOW |
| DET-007 | document_meta | Metadata / VBA macros / JS signals | LOW |
| DET-008 | comment_directive | Insecure instruction hidden in an ordinary code comment or agent rule file — the directive frame (marker / addressed / imperative / authority / "skip the check") plus one of the ten injected-weakness classes | CRITICAL · HIGH · MEDIUM |
| DET-009 | speaker_notes | Directive/injection content in PowerPoint speaker notes — machine-readable but not shown when the deck is presented | HIGH · MEDIUM |

### Formats

Expand Down Expand Up @@ -133,16 +134,28 @@ Measured on this repository's corpus and on live third-party source, with the bo
|---|---|
| Attack corpus (10 classes × 3 framings + 2 agent-directed; 2 payloads verbatim from the paper) | 32/32 detected, 29 CRITICAL / 3 HIGH |
| Benign corpus (46 ordinary work comments, five syntax families) | 0 false positives |
| Live third-party source probe (this project + `takumi/packages`: 167 files, 4,643 comment lines) | 0 findings |
| Legit notes byte-shaped like a payload (`# TODO: use DBMS_SCHEDULER for the nightly job`) | flagged — the deliberate fail-closed choice |
| Ambiguous corpus (4 legit notes byte-shaped like a payload, pinned in `tests/`) | 4/4 reported — accepted false positives, the deliberate fail-closed choice |
| Live third-party source probe (`scripts/probe_comment_directive.py`: this project + `takumi/packages`, build output excluded: 106 files, 738 comment lines) | 0 findings |

Honest boundaries: the paper's 700-item corpus was not released with its HTML, so these figures are
**not** a reproduction of the paper's numbers; a deterministic pattern detector is incomplete by
construction (the paper's own strongest screen still missed ~⅓); and DET-008 reads *instructions*, not
the vulnerable code a model may already have written — that is a SAST job. Design notes, the full
measurement method and the known gaps:
the vulnerable code a model may already have written — that is a SAST job. The ambiguous row is
reported as a known false-positive class, not as detections. Design notes, the full measurement method
and the known gaps:
[`docs/comment-directive-coverage.md`](docs/comment-directive-coverage.md).

### Speaker notes (DET-009)

A slide's speaker notes are not shown when the deck is presented, but they live in the file and every
extractor — and therefore every LLM that summarises the deck — reads them. `pptx` already parsed them;
until DET-009 nothing scored them, so a deck whose **only** injection was a plain-text instruction in
the notes scanned clean and was allowed. DET-009 closes that channel: a note that tries to instruct a
reader (a model or a human) is reported — HIGH for an explicit override/"do not tell" payload, MEDIUM
for a system-addressed or verdict-directing one — and the notes run is defused on quarantine. Generic
reminders ("update the roadmap slide") are not reported. Like DET-008 it is a pattern detector: the
channel is covered, the payload vocabulary is not exhaustive.

## Install

### Use it (recommended for the Claude Code hook)
Expand Down Expand Up @@ -181,7 +194,7 @@ aiitg scan report.docx --format json # JSON evidence report
aiitg scan report.xlsx --min-severity high # only high+ findings
aiitg scan report.pdf --format rich # terminal table
aiitg scan ./inbox --recursive --jsonl # batch directory scan, one compact JSON object per line
aiitg list-detectors # list all 8 detectors
aiitg list-detectors # list all 9 detectors
```

Exit codes: `0` = clean · `1` = findings at/above threshold · `2` = usage error · `3` = parse error (CI-friendly).
Expand Down Expand Up @@ -291,7 +304,7 @@ else:
## Testing

```bash
make test # 330 tests
make test # 339 tests
make lint # ruff
make typecheck # mypy
make build # build wheel/sdist
Expand Down
5 changes: 3 additions & 2 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ In scope — anything that breaks the project's promises:
overrides a real verdict).
- **Detection bypass**: a concealment technique that a human reader cannot see but aiitg reports as
`safe` with no evidence, or a sanitized output that still carries the hidden payload.
- **Directive bypass**: an instruction planted in a code comment or an agent rule file that reaches
the model without a `DET-008` finding, or a sanitized substitute that still carries it. This is not
- **Directive bypass**: an instruction planted in a code comment, an agent rule file, or a
PowerPoint speaker-note page that reaches the model without a `DET-008`/`DET-009` finding, or a
sanitized substitute that still carries it. This is not
*concealment* — a human reads the comment too — but it breaks the same promise through a different
channel, so it is in scope.
- **Policy bypass**: reaching `allow` for a document the default policy would block/quarantine, or a
Expand Down
25 changes: 19 additions & 6 deletions docs/comment-directive-coverage.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,15 @@ Corpus and probe live in `tests/detectors/test_comment_directive.py`,
|---|---|
| Attack corpus — 32 payloads: the paper's 10 classes × 3 framings + 2 agent-directed (2 payloads verbatim from the paper; the rest authored in its stated format) | **32/32 detected**, class agreement 32/32, 29 CRITICAL / 3 HIGH |
| Benign corpus — 46 ordinary work comments across five comment syntax families | **0 false positives** |
| Live source probe — 167 files / **4,643 comment lines** of third-party source (this project + `takumi/packages`, via the shipped `run_scan()`) | **0 findings** |
| Ambiguous cases (legit notes byte-shaped like payloads) | 4/4 flagged — the fail-closed choice, not an accident |
| Ambiguous corpus — 4 legit notes byte-shaped like payloads, pinned in the test file | 4/4 reported — **accepted false positives**, the fail-closed choice |
| Live source probe — `scripts/probe_comment_directive.py` over this project + `takumi/packages` (build output excluded): **106 files / 738 comment lines**, via the shipped `run_scan()` | **0 findings** |

The ambiguous row is the honest one: those four are *legit* notes that are reported anyway. They are
counted as a known false-positive class, not as detections, so the corpus can never look cleaner than
it is. The live-probe figures are reproducible with the committed script (see §6); the earlier
"167 files / 4,643 comment lines" figure came from *including* build output (`dist/`) and from a looser
comment-line definition — `--include-build` restores 168 files, but generated bundles are not
third-party source a developer reads, so they are excluded by default.

Boundaries, stated plainly:

Expand All @@ -125,9 +132,15 @@ Boundaries, stated plainly:

```bash
make test # unit + integration + e2e, incl. the corpus tests
pytest tests/detectors/test_comment_directive.py -q # the attack/benign corpus itself
pytest tests/detectors/test_comment_directive.py -q # the attack/benign/ambiguous corpora

# The live false-positive probe. Build output is excluded by default; pass
# --include-build to reproduce the (older, larger) 168-file figure.
python scripts/probe_comment_directive.py . ../takumi/packages
python scripts/probe_comment_directive.py . ../takumi/packages --json
```

The live probe walks a source tree, counts comment lines per language family, and runs `run_scan()`
over each file — it is deliberately an *external* script so the repository's own tree does not ship a
hard-coded measurement.
The probe walks a source tree, counts the full-line comments the detector actually reads (per
language family), and runs the shipped `run_scan()` over each file — it re-implements nothing, so it
measures the gateway as shipped. It is a *false-positive* measurement: it reports what the detector
flags on code written without any injected payload, and says nothing about recall.
5 changes: 3 additions & 2 deletions docs/plan-zero-touch-adoption.md
Original file line number Diff line number Diff line change
Expand Up @@ -615,8 +615,9 @@ Guardrails for backward compatibility:
- **Hook-contract drift**: the `hookSpecificOutput` schema is an external contract and may change.
Mitigation: pin the documented field names in one renderer (`render_outcome`), test it directly,
and keep the CLI stdout shape in one place.
- **Performance**: each enforced `Read` runs a full parse + the detector chain (documents: 7 detectors;
source files: the code-context detector only). Mitigation: extension
- **Performance**: each enforced `Read` runs a full parse + the detector chain (documents: up to 8
detectors — pptx adds the speaker-notes detector; source files: the code-context detector only).
Mitigation: extension
allowlist, `(path, mtime, size)` result cache, hook `timeout` in settings, and an `--no-scan`
passthrough for large files.
- **False positives**: `default_policy` quarantines on any evidence (POL-002), so legitimately
Expand Down
Loading
Loading