Neutralize reserved markers in wrapped mail text #229

Merged
svc-svd-writer merged 2 commits from fix/228-neutralize-untrusted-fence into main 2026-11-23 04:42:13 +00:00

Summary

Stored body, attachment text or signature
  → neutralize exact Unicode case-fold equivalents of reserved fence markers
  → apply the tool's existing payload budget
  → wrap with the pinned fence

Closes #228. Operator ruling · Mind-spec alignment

Evidence

  • Baseline fixtures failed at all three tools or exceeded the signature budget with three blocks.
  • Six additional Unicode fixtures failed with ASCII-only matching. The focused suite passed 234 tests at the revised head. It covers Unicode expansions, mixed case, ordinary text, historical rows, truncated markers, single and shared budgets, and the signature line boundary.

Merge Danger

Reversible code change. Scope is the display and budgets of the three existing fenced payloads. Coverage is from generated fixtures. Downstream reader behavior, live sources and deployed data remain unverified.

## Summary ```text Stored body, attachment text or signature → neutralize exact Unicode case-fold equivalents of reserved fence markers → apply the tool's existing payload budget → wrap with the pinned fence ``` Closes #228. [Operator ruling](https://git.groupthink.asia/dev/mail-mind-mcp/issues/228#issuecomment-46656) · [Mind-spec alignment](https://git.groupthink.asia/dev/mail-mind-mcp/issues/228#issuecomment-46668) ## Evidence - Baseline fixtures failed at all three tools or exceeded the signature budget with three blocks. - Six additional Unicode fixtures failed with ASCII-only matching. The focused suite passed 234 tests at the revised head. It covers Unicode expansions, mixed case, ordinary text, historical rows, truncated markers, single and shared budgets, and the signature line boundary. ## Merge Danger Reversible code change. Scope is the display and budgets of the three existing fenced payloads. Coverage is from generated fixtures. Downstream reader behavior, live sources and deployed data remain unverified.
Neutralize reserved markers in wrapped mail text
All checks were successful
ci/woodpecker/pr/validation Pipeline was successful
3782e2951b
Closes #228

Co-Authored-By: Codex GPT-5 <noreply@openai.com>
Author
Member

Independent Standards PASS · 0 open findings at 3782e2951b9412c7c68e2e2c9cd3fa9fc5434227.

The exact diff passed git diff --check. The reviewer found no breach of the repository's coding and security standards or ADR 0008 §2. The rendering callback preserves sign-off selection and deduplication and accounts for separators at the line-boundary cap.

**Independent Standards PASS · 0 open findings** at `3782e2951b9412c7c68e2e2c9cd3fa9fc5434227`. The exact diff passed `git diff --check`. The reviewer found no breach of the repository's coding and security standards or ADR 0008 §2. The rendering callback preserves sign-off selection and deduplication and accounts for separators at the line-boundary cap.
Author
Member

Independent Spec FAIL · 1 open finding at 3782e2951b9412c7c68e2e2c9cd3fa9fc5434227.

The operator requires that a reader ignoring case also sees no reserved marker inside the payload. The ASCII-only matcher leaves a Unicode long s in either marker intact. The generated input matches the reserved string after the same Unicode case fold used in the fixture oracle. Existing fixtures cover ASCII case variants. The other reviewed tool, scope and budget requirements match the agreed design. Operator ruling

**Independent Spec FAIL · 1 open finding** at `3782e2951b9412c7c68e2e2c9cd3fa9fc5434227`. The operator requires that a reader ignoring case also sees no reserved marker inside the payload. The ASCII-only matcher leaves a Unicode long s in either marker intact. The generated input matches the reserved string after the same Unicode case fold used in the fixture oracle. Existing fixtures cover ASCII case variants. The other reviewed tool, scope and budget requirements match the agreed design. [Operator ruling](https://git.groupthink.asia/dev/mail-mind-mcp/issues/228#issuecomment-46547)
Author
Member

§19 security review · STOP · 1 open finding at 3782e2951b9412c7c68e2e2c9cd3fa9fc5434227.

The review found a Unicode case-fold collision at the three existing wrapper boundaries. The shared matcher only ignores ASCII case. Local checks using the exact matcher and pinned wrapper confirmed both reserved markers survive as case-fold equivalents with U+017F and with U+FB06. The §6 ruling directs a STOP for any further path escaping the fence. The commit-range secret scan found no leaks. These checks used generated strings and repository code. Downstream parsing, deployed incidence, live IMAP/JMAP and deployed-mirror coverage are unsupported.

No merge clearance. The guide is asked to obtain an operator ruling before a repair. Operator ruling

**§19 security review · STOP · 1 open finding** at `3782e2951b9412c7c68e2e2c9cd3fa9fc5434227`. The review found a Unicode case-fold collision at the three existing wrapper boundaries. The shared matcher only ignores ASCII case. Local checks using the exact matcher and pinned wrapper confirmed both reserved markers survive as case-fold equivalents with U+017F and with U+FB06. The §6 ruling directs a STOP for any further path escaping the fence. The commit-range secret scan found no leaks. These checks used generated strings and repository code. Downstream parsing, deployed incidence, live IMAP/JMAP and deployed-mirror coverage are unsupported. No merge clearance. The guide is asked to obtain an operator ruling before a repair. [Operator ruling](https://git.groupthink.asia/dev/mail-mind-mcp/issues/228#issuecomment-46547)
Match reserved fence markers by Unicode case fold
All checks were successful
ci/woodpecker/pr/validation Pipeline was successful
da73e23596
Refs #228

Co-Authored-By: Codex GPT-5 <noreply@openai.com>
Author
Member

§19 security review · PASS · 0 open findings at da73e23596aff45154be47476e13eac3d94b2df3.

The revision closes the Unicode case-fold collision found on the previous head. At the three existing wrapper boundaries the implementation recognizes original bracketed spans, compares their Python case folds and replaces only the opening bracket of exact matches. The public fixtures confirm spelling preservation, ordinary bracketed text, both marker variants with U+017F and U+FB06, the shared read budget, and the signature line boundary. The focused suite passed 234 cases. A separate generated-string check enumerated all 4,194,304 fold-equivalent original strings per marker under Unicode 16.0.0. It verified each replacement and confirmed the reserved bracket characters have no other fold preimages in that runtime. The original matcher failed six regression cases before the fix.

The escaping is confined to the existing wrapped output. The diff leaves stored data, evidence selection, peer output and external payloads unchanged and adds no network access. Gitleaks reported no findings on the reviewed commit range. Downstream fence interpretation, deployed incidence, live IMAP/JMAP and deployed-mirror coverage remain unsupported. Previous finding · Operator ruling

**§19 security review · PASS · 0 open findings** at `da73e23596aff45154be47476e13eac3d94b2df3`. The revision closes the Unicode case-fold collision found on the previous head. At the three existing wrapper boundaries the implementation recognizes original bracketed spans, compares their Python case folds and replaces only the opening bracket of exact matches. The public fixtures confirm spelling preservation, ordinary bracketed text, both marker variants with U+017F and U+FB06, the shared read budget, and the signature line boundary. The focused suite passed 234 cases. A separate generated-string check enumerated all 4,194,304 fold-equivalent original strings per marker under Unicode 16.0.0. It verified each replacement and confirmed the reserved bracket characters have no other fold preimages in that runtime. The original matcher failed six regression cases before the fix. The escaping is confined to the existing wrapped output. The diff leaves stored data, evidence selection, peer output and external payloads unchanged and adds no network access. Gitleaks reported no findings on the reviewed commit range. Downstream fence interpretation, deployed incidence, live IMAP/JMAP and deployed-mirror coverage remain unsupported. [Previous finding](https://git.groupthink.asia/dev/mail-mind-mcp/pulls/229#issuecomment-46648) · [Operator ruling](https://git.groupthink.asia/dev/mail-mind-mcp/issues/228#issuecomment-46656)
Author
Member

Independent Standards PASS · 0 open findings at da73e23596aff45154be47476e13eac3d94b2df3.

The reviewer inspected both commits and the exact diff, which passed git diff --check. The change follows repository conventions, applies Unicode case folding before the existing payload caps and preserves the evidence boundary and line-based signature limit. The reviewer independently checked generated Unicode variants, nested brackets and ordinary text.

**Independent Standards PASS · 0 open findings** at `da73e23596aff45154be47476e13eac3d94b2df3`. The reviewer inspected both commits and the exact diff, which passed `git diff --check`. The change follows repository conventions, applies Unicode case folding before the existing payload caps and preserves the evidence boundary and line-based signature limit. The reviewer independently checked generated Unicode variants, nested brackets and ordinary text.
Author
Member

Independent Spec PASS · 0 open findings at da73e23596aff45154be47476e13eac3d94b2df3.

The Unicode finding is resolved. The matcher preserves the source code points after the replaced bracket. Public-tool fixtures cover both reserved markers with long s and the expanding ligature, ordinary text, truncation, batch reads, repeated attachment calls and combined signatures. The reviewer independently checked the six non-ASCII single-code-point substitutions that fold to marker substrings.

**Independent Spec PASS · 0 open findings** at `da73e23596aff45154be47476e13eac3d94b2df3`. The Unicode finding is resolved. The matcher preserves the source code points after the replaced bracket. Public-tool fixtures cover both reserved markers with long s and the expanding ligature, ordinary text, truncation, batch reads, repeated attachment calls and combined signatures. The reviewer independently checked the six non-ASCII single-code-point substitutions that fold to marker substrings.
Author
Member

Exact-head CI and raw-log audit

Head da73e23596aff45154be47476e13eac3d94b2df3 passed Woodpecker pipeline 131. Ruff, mypy, the non-integration suite (1,681 passed, 8 skipped, 30 deselected) and dependency audit passed.

Audited the complete CI log records for clone (17171, 9 records) and check (17172, 232 records), and the exact-head local verification log, per dev/stables#2237. Zero occurrences of command not found, errors during collection, = not found, ran outside the project environment, or "is_error":true. The raw JSONL SHA-256 is 6993f51690b376590518cee3ec31509b87a422a64f6b1b3d9ad6490289475940 for clone and f8822b5a658eaee96dcd813680775d4f3bf89787a7052500bef531855302a99f for check.

## Exact-head CI and raw-log audit Head `da73e23596aff45154be47476e13eac3d94b2df3` passed [Woodpecker pipeline 131](https://ci.groupthink.asia/repos/72/pipeline/131/1). Ruff, mypy, the non-integration suite (1,681 passed, 8 skipped, 30 deselected) and dependency audit passed. Audited the complete CI log records for clone (17171, 9 records) and check (17172, 232 records), and the exact-head local verification log, per dev/stables#2237. Zero occurrences of `command not found`, `errors during collection`, `= not found`, `ran outside the project environment`, or `"is_error":true`. The raw JSONL SHA-256 is `6993f51690b376590518cee3ec31509b87a422a64f6b1b3d9ad6490289475940` for clone and `f8822b5a658eaee96dcd813680775d4f3bf89787a7052500bef531855302a99f` for check.
svc-svd-writer deleted branch fix/228-neutralize-untrusted-fence 2026-11-23 04:42:13 +00:00
Sign in to join this conversation.
No description provided.