Neutralize sender-controlled untrusted-content fence markers #228

Closed
opened 2026-11-23 02:43:59 +00:00 by svc-agent-writer · 11 comments

Parent #224. Operator ruling · Generated finding

Sender text containing the literal untrusted fence markers can make the current response boundary ambiguous. Generated plain and HTML examples produced an extra closing marker. Deployed occurrence and downstream readers' handling are unmeasured.

Scope

  • Neutralize both literal markers inside every payload passed to the pinned untrusted-content wrapper. Apply to mail_read in all body modes, including existing mirrored rows, mail_attachment and mail_evidence.
  • Count escaped body and metadata against the applicable existing max_chars budget. Preserve ordinary text as displayed today.
  • Keep the protection in this repository. The guide owns the upstream draft with the operator.

Completion evidence

  • Through the public tools, check single and batch message reads, a single attachment read, and a single and multi-message evidence result. Include both sender-controlled markers and assert exactly one genuine opener and one closer per wrapped payload, plus the existing limits and ordinary output.
  • Post a short design note and obtain mind-spec ACCOMMODATE before implementation. The PR requires independent Standards and Spec PASS with zero open findings, posted §19 security review, green exact-head CI and the raw-log audit. Merge before #224 feature work.

Blocked by

Parent #224. [Operator ruling](https://git.groupthink.asia/dev/mail-mind-mcp/issues/224#issuecomment-46317) · [Generated finding](https://git.groupthink.asia/dev/mail-mind-mcp/issues/224#issuecomment-46304) Sender text containing the literal untrusted fence markers can make the current response boundary ambiguous. Generated plain and HTML examples produced an extra closing marker. Deployed occurrence and downstream readers' handling are unmeasured. ## Scope - Neutralize both literal markers inside every payload passed to the pinned untrusted-content wrapper. Apply to `mail_read` in all body modes, including existing mirrored rows, `mail_attachment` and `mail_evidence`. - Count escaped body and metadata against the applicable existing `max_chars` budget. Preserve ordinary text as displayed today. - Keep the protection in this repository. The guide owns the upstream draft with the operator. ## Completion evidence - Through the public tools, check single and batch message reads, a single attachment read, and a single and multi-message evidence result. Include both sender-controlled markers and assert exactly one genuine opener and one closer per wrapped payload, plus the existing limits and ordinary output. - Post a short design note and obtain mind-spec ACCOMMODATE before implementation. The PR requires independent Standards and Spec PASS with zero open findings, posted §19 security review, green exact-head CI and the raw-log audit. Merge before #224 feature work. ## Blocked by - #225
Author
Member

DD-469 alignment for #228

Neutralize the two reserved marker strings at the point where mail-mind renders an untrusted payload. Use a literal backslash escape for each marker's opening bracket so the literal marker cannot occur in the fenced text. Escape before cutting to the existing character cap. In batch reads, allocate the shared cap using escaped lengths, including any body metadata added by #224. Keep the pinned wrapper responsible for the real opening and closing markers. Ordinary text renders as before.

Apply this presentation rule to mail_read (existing rows and all body modes as #224 adds them), mail_attachment and the signature payload of mail_evidence. The attachment tool takes one part per call. mail_evidence keeps one fence around the combined signature section for a sender, whether the result uses one message or several. Public fixture checks will exercise both literal markers, clipping and ordinary text, and count the real boundary markers in each fenced payload. Deployed content and downstream interpretation are unmeasured.

Keep evidence inputs, sign-off verification, assessor payloads, stored values, peer output, scopes and consent rules as they are. This changes delimiter encoding in the existing text tool output only. No mind-v1 field or ADR amendment is proposed.

Request a canonical-fit answer of ACCOMMODATE or CLASH before implementation.

## DD-469 alignment for #228 Neutralize the two reserved marker strings at the point where mail-mind renders an untrusted payload. Use a literal backslash escape for each marker's opening bracket so the literal marker cannot occur in the fenced text. Escape before cutting to the existing character cap. In batch reads, allocate the shared cap using escaped lengths, including any body metadata added by #224. Keep the pinned wrapper responsible for the real opening and closing markers. Ordinary text renders as before. Apply this presentation rule to `mail_read` (existing rows and all body modes as #224 adds them), `mail_attachment` and the signature payload of `mail_evidence`. The attachment tool takes one part per call. `mail_evidence` keeps one fence around the combined signature section for a sender, whether the result uses one message or several. Public fixture checks will exercise both literal markers, clipping and ordinary text, and count the real boundary markers in each fenced payload. Deployed content and downstream interpretation are unmeasured. Keep evidence inputs, sign-off verification, assessor payloads, stored values, peer output, scopes and consent rules as they are. This changes delimiter encoding in the existing text tool output only. No mind-v1 field or ADR amendment is proposed. Request a canonical-fit answer of ACCOMMODATE or CLASH before implementation.
Author
Member

The guide filed the upstream wrapper issue under the operator ruling. #228 covers the local rendering paths in mail-mind-mcp. Upstream wrapper issue

The guide filed the upstream wrapper issue under the operator ruling. #228 covers the local rendering paths in mail-mind-mcp. [Upstream wrapper issue](https://git.groupthink.asia/dev/imap-blade-mcp/issues/6)
Author
Member

STOP · mind-spec returned CLASH on #228

Mind-spec answered CLASH to the fence-neutralization design in comment 46322. The canonical reply contains only that verdict. Ratatoskr answer f67827ef-858d-47d5-917a-afbdcc846593 on mail224-canonical.

#228 implementation is paused under the grant. #224 remains blocked on the #228 merge. #225 was already merged through PR #227 under the operator's separate disposition. Escalated to the guide for Piers's ruling.

**STOP · mind-spec returned CLASH on #228** Mind-spec answered `CLASH` to the fence-neutralization design in comment 46322. The canonical reply contains only that verdict. Ratatoskr answer `f67827ef-858d-47d5-917a-afbdcc846593` on `mail224-canonical`. #228 implementation is paused under the grant. #224 remains blocked on the #228 merge. #225 was already merged through PR #227 under the operator's separate disposition. Escalated to the guide for Piers's ruling.
Author
Member

Mind-spec identified the conflict in its follow-up b9d6c890-f27d-4966-8edd-73344f750fe0 on mail224-canonical.

The clash is the proposed backslash escape of the opening bracket. Prefixing [ with a literal backslash leaves the full reserved marker intact as a substring of the rendered payload. A literal marker count still sees that occurrence. The #224 ruling requires both marker strings to be absent from the payload so the pinned wrapper supplies the only opener and closer.

Proposed wording for Piers's ruling: replace the opening bracket of each exact marker occurrence with the four literal characters \x5b. This removes the bracket from the rendered payload at that position. Apply the character budget after replacement and assert that neither reserved marker appears anywhere inside the wrapped payload. Keep #228 stopped until Piers rules and mind-spec accommodates the revised note.

Mind-spec identified the conflict in its follow-up `b9d6c890-f27d-4966-8edd-73344f750fe0` on `mail224-canonical`. > The clash is the proposed backslash escape of the opening bracket. Prefixing `[` with a literal backslash leaves the full reserved marker intact as a substring of the rendered payload. A literal marker count still sees that occurrence. The #224 ruling requires both marker strings to be absent from the payload so the pinned wrapper supplies the only opener and closer. Proposed wording for Piers's ruling: replace the opening bracket of each exact marker occurrence with the four literal characters `\x5b`. This removes the bracket from the rendered payload at that position. Apply the character budget after replacement and assert that neither reserved marker appears anywhere inside the wrapped payload. Keep #228 stopped until Piers rules and mind-spec accommodates the revised note.
Author
Member

#228 · operator §6 ruling on your STOP (mind-spec CLASH f67827ef, follow-up b9d6c890) · corr mail224-align

Piers ruled (AskUserQuestion to the guide). This is his word within your grant (comment 46198). Post this ruling verbatim on #228 before you act on it.

  1. Neutralize each occurrence of either reserved marker, [untrusted-email-content] and [/untrusted-email-content], by replacing its opening [ with the four literal characters \x5b.
  2. Match both markers in any letter case. A reader that ignores case must not see a marker either. Text with no marker in any case renders unchanged.
  3. Apply max_chars, and the batch shared cap, after replacement.
  4. Public single and batch checks for mail_read, mail_attachment and mail_evidence assert that neither marker appears in any letter case inside a wrapped payload, and that each message block has exactly one real opener and one real closer. Include both markers, a case variant of each, a marker cut by the cap, and ordinary text.
  5. Revise the #228 design note to this rule and get mind-spec ACCOMMODATE on it before you build. The rest of the #224 ruling (46317) stands: its own §19 review, the full grant §4 gate, and the merge before the #224 feature work.

A CLASH, or any further path by which sender text escapes a fence or reaches evidence, assessor fields or an external service, is a STOP to the guide.

Honesty limit: unchanged from 46317. Do not claim how any downstream reader parses the fence, or that deployed rows hold marker-like text.

Report the posted ruling and mind-spec's answer to the guide on corr mail224-align.

#228 · operator §6 ruling on your STOP (mind-spec CLASH f67827ef, follow-up b9d6c890) · corr mail224-align Piers ruled (AskUserQuestion to the guide). This is his word within your grant (comment 46198). Post this ruling verbatim on #228 before you act on it. 1. Neutralize each occurrence of either reserved marker, `[untrusted-email-content]` and `[/untrusted-email-content]`, by replacing its opening `[` with the four literal characters `\x5b`. 2. Match both markers in any letter case. A reader that ignores case must not see a marker either. Text with no marker in any case renders unchanged. 3. Apply max_chars, and the batch shared cap, after replacement. 4. Public single and batch checks for mail_read, mail_attachment and mail_evidence assert that neither marker appears in any letter case inside a wrapped payload, and that each message block has exactly one real opener and one real closer. Include both markers, a case variant of each, a marker cut by the cap, and ordinary text. 5. Revise the #228 design note to this rule and get mind-spec ACCOMMODATE on it before you build. The rest of the #224 ruling (46317) stands: its own §19 review, the full grant §4 gate, and the merge before the #224 feature work. A CLASH, or any further path by which sender text escapes a fence or reaches evidence, assessor fields or an external service, is a STOP to the guide. Honesty limit: unchanged from 46317. Do not claim how any downstream reader parses the fence, or that deployed rows hold marker-like text. Report the posted ruling and mind-spec's answer to the guide on corr mail224-align.
Author
Member

Revised DD-469 alignment for #228

At the three wrap_untrusted call sites, case-insensitively match every occurrence of [untrusted-email-content] and [/untrusted-email-content] in the text being wrapped. Replace the opening bracket of each match with the four literal characters \x5b and preserve the rest of the matched text. The rendered payload has no occurrence of either reserved marker in any letter case. Text with no match renders unchanged. The pinned wrapper supplies the genuine markers.

Apply the existing payload cap after replacement. Charge escaped characters against single and batch max_chars with the current shared allocation for mail_read. Include future wrapped body metadata from #224 in that same budget. Escape the attachment text and the combined signature payload at their existing render boundaries. Retain the public call signatures and response shape. mail_attachment wraps one attachment per call, and mail_evidence wraps the combined signatures for one sender across the messages selected by max_messages.

Public tool fixtures will cover both markers and a case variant of each, ordinary text, a marker clipped at the cap, legacy records, single and batch reads, repeated single attachment calls, and single- and multi-message evidence. Check for exactly one genuine opener and closer per fenced block and zero internal occurrences, case-insensitively. Deployed incidence and downstream interpretation are unmeasured.

Evidence inputs, sign-off verification, the assessor payload, stored values, peer output, scopes and consent rules keep their current behavior. This changes escaping in the existing text presentation. No mind-v1 field or ADR amendment is proposed. Operator ruling

Please answer ACCOMMODATE or CLASH before implementation.

## Revised DD-469 alignment for #228 At the three `wrap_untrusted` call sites, case-insensitively match every occurrence of `[untrusted-email-content]` and `[/untrusted-email-content]` in the text being wrapped. Replace the opening bracket of each match with the four literal characters `\x5b` and preserve the rest of the matched text. The rendered payload has no occurrence of either reserved marker in any letter case. Text with no match renders unchanged. The pinned wrapper supplies the genuine markers. Apply the existing payload cap after replacement. Charge escaped characters against single and batch `max_chars` with the current shared allocation for `mail_read`. Include future wrapped body metadata from #224 in that same budget. Escape the attachment text and the combined signature payload at their existing render boundaries. Retain the public call signatures and response shape. `mail_attachment` wraps one attachment per call, and `mail_evidence` wraps the combined signatures for one sender across the messages selected by `max_messages`. Public tool fixtures will cover both markers and a case variant of each, ordinary text, a marker clipped at the cap, legacy records, single and batch reads, repeated single attachment calls, and single- and multi-message evidence. Check for exactly one genuine opener and closer per fenced block and zero internal occurrences, case-insensitively. Deployed incidence and downstream interpretation are unmeasured. Evidence inputs, sign-off verification, the assessor payload, stored values, peer output, scopes and consent rules keep their current behavior. This changes escaping in the existing text presentation. No mind-v1 field or ADR amendment is proposed. [Operator ruling](https://git.groupthink.asia/dev/mail-mind-mcp/issues/228#issuecomment-46547) Please answer ACCOMMODATE or CLASH before implementation.
Author
Member

Mind-spec returned ACCOMMODATE on the revised #228 fence design in comment 46553. Ratatoskr answer 00fb60d2-48f5-4dd5-86d8-9dd4f5a28375 on mail224-canonical. The operator ruling and the required review and CI gates apply. Revised design

Mind-spec returned `ACCOMMODATE` on the revised #228 fence design in comment 46553. Ratatoskr answer `00fb60d2-48f5-4dd5-86d8-9dd4f5a28375` on `mail224-canonical`. The operator ruling and the required review and CI gates apply. [Revised design](https://git.groupthink.asia/dev/mail-mind-mcp/issues/228#issuecomment-46553)
Author
Member

STOP on #228 and #224. Independent Spec review of PR #229 found that the ASCII-only marker matcher leaves Unicode forms that compare equal to the reserved markers after case folding. Verified for both markers using only generated strings and the exact candidate. The operator ruling requires escalation through the guide.

Proposed ruling for Piers: neutralize every occurrence whose Unicode case fold equals either reserved marker. Preserve the case and code points of the matched text after its opening bracket. Keep other text and the existing caps and wrapper behavior. Verify the Unicode variants through the three public tools along with the existing fixtures.

The PR stays open while #228 and #224 wait for operator direction. §19 finding

**STOP on #228 and #224.** Independent Spec review of PR #229 found that the ASCII-only marker matcher leaves Unicode forms that compare equal to the reserved markers after case folding. Verified for both markers using only generated strings and the exact candidate. The operator ruling requires escalation through the guide. Proposed ruling for Piers: neutralize every occurrence whose Unicode case fold equals either reserved marker. Preserve the case and code points of the matched text after its opening bracket. Keep other text and the existing caps and wrapper behavior. Verify the Unicode variants through the three public tools along with the existing fixtures. The PR stays open while #228 and #224 wait for operator direction. [§19 finding](https://git.groupthink.asia/dev/mail-mind-mcp/pulls/229#issuecomment-46648)
Author
Member

#228 · operator §6 ruling on your Unicode STOP (comment 46650, PR #229 findings 46646 and 46648) · corr mail224-align

Piers ruled (AskUserQuestion to the guide). This is his word within your grant (comment 46198). Post this ruling verbatim on #228 before you act on it.

  1. Neutralize every occurrence in the text being wrapped whose Unicode case fold (Python str.casefold) equals the case fold of either reserved marker, [untrusted-email-content] or [/untrusted-email-content]. Replace its opening [ with the four literal characters \x5b.
  2. Keep the matched text after its opening bracket, with its original case and code points. Keep all other text unchanged. A match can differ in length from the marker, for example U+FB06 folds to two characters, so map the match back to the original text.
  3. The ruling at 46547 otherwise stands: max_chars and the batch shared cap apply after replacement, and the three wrapper call sites keep their behavior.
  4. The public single and batch checks for mail_read, mail_attachment and mail_evidence add, for both markers, a variant with U+017F (long s) and a variant with U+FB06 (the "st" ligature), alongside the existing fixtures. They assert that no substring of a wrapped payload has a case fold equal to either marker's case fold, and that each message block has exactly one real opener and one real closer.
  5. Revise the #228 design note to this rule and get mind-spec ACCOMMODATE on it before you build. The #224 ruling (46317) stands: its own §19 review, the full grant §4 gate, and the merge before the #224 feature work.

A CLASH, or any further path by which sender text escapes a fence or reaches evidence, assessor fields or an external service, is a STOP to the guide.

Honesty limit: unchanged from 46317. Do not claim how any downstream reader parses the fence, or that deployed rows hold marker-like text.

Report the posted ruling and mind-spec's answer to the guide on corr mail224-align.

#228 · operator §6 ruling on your Unicode STOP (comment 46650, PR #229 findings 46646 and 46648) · corr mail224-align Piers ruled (AskUserQuestion to the guide). This is his word within your grant (comment 46198). Post this ruling verbatim on #228 before you act on it. 1. Neutralize every occurrence in the text being wrapped whose Unicode case fold (Python `str.casefold`) equals the case fold of either reserved marker, `[untrusted-email-content]` or `[/untrusted-email-content]`. Replace its opening `[` with the four literal characters `\x5b`. 2. Keep the matched text after its opening bracket, with its original case and code points. Keep all other text unchanged. A match can differ in length from the marker, for example U+FB06 folds to two characters, so map the match back to the original text. 3. The ruling at 46547 otherwise stands: max_chars and the batch shared cap apply after replacement, and the three wrapper call sites keep their behavior. 4. The public single and batch checks for mail_read, mail_attachment and mail_evidence add, for both markers, a variant with U+017F (long s) and a variant with U+FB06 (the "st" ligature), alongside the existing fixtures. They assert that no substring of a wrapped payload has a case fold equal to either marker's case fold, and that each message block has exactly one real opener and one real closer. 5. Revise the #228 design note to this rule and get mind-spec ACCOMMODATE on it before you build. The #224 ruling (46317) stands: its own §19 review, the full grant §4 gate, and the merge before the #224 feature work. A CLASH, or any further path by which sender text escapes a fence or reaches evidence, assessor fields or an external service, is a STOP to the guide. Honesty limit: unchanged from 46317. Do not claim how any downstream reader parses the fence, or that deployed rows hold marker-like text. Report the posted ruling and mind-spec's answer to the guide on corr mail224-align.
Author
Member

Revised DD-469 alignment for #228

At the three existing wrap_untrusted boundaries, recognize a candidate from its literal opening bracket through its closing bracket. Compare the complete candidate's Python str.casefold() with the folds of the two reserved markers. On equality, replace only the opening bracket with the four literal ASCII characters \x5b. Keep the remaining original characters in order. Use the matched original span so that an expansion in the folded string, such as U+FB06 folding to two letters, does not affect the rest of the text. All other text renders unchanged.

Apply max_chars after replacement and charge escaped characters to the existing shared mail_read budget. Keep the signature line boundary and the existing public tool schemas and output shapes. mail_attachment wraps one attachment per call. mail_evidence wraps the combined signatures across the requested messages. Future wrapped metadata from #224 will share the same read budget.

Synthetic public tool fixtures will verify both markers, ASCII case variants, and a U+017F and U+FB06 variant of each marker. They will exercise historical rows, ordinary text, a marker cut by the cap, single and batch reads, repeated attachment calls, and single- and multi-message evidence. Each wrapped block must have one genuine opener and closer and no case-fold-equivalent marker within its payload. These fixtures cover local output only.

Evidence inputs, sign-off verification, the assessor payload, stored values, peer output, scopes and consent rules keep their current behavior. No ADR or mind-v1 amendment is proposed. Operator ruling

Please answer ACCOMMODATE or CLASH before implementation.

## Revised DD-469 alignment for #228 At the three existing `wrap_untrusted` boundaries, recognize a candidate from its literal opening bracket through its closing bracket. Compare the complete candidate's Python `str.casefold()` with the folds of the two reserved markers. On equality, replace only the opening bracket with the four literal ASCII characters `\x5b`. Keep the remaining original characters in order. Use the matched original span so that an expansion in the folded string, such as U+FB06 folding to two letters, does not affect the rest of the text. All other text renders unchanged. Apply `max_chars` after replacement and charge escaped characters to the existing shared `mail_read` budget. Keep the signature line boundary and the existing public tool schemas and output shapes. `mail_attachment` wraps one attachment per call. `mail_evidence` wraps the combined signatures across the requested messages. Future wrapped metadata from #224 will share the same read budget. Synthetic public tool fixtures will verify both markers, ASCII case variants, and a U+017F and U+FB06 variant of each marker. They will exercise historical rows, ordinary text, a marker cut by the cap, single and batch reads, repeated attachment calls, and single- and multi-message evidence. Each wrapped block must have one genuine opener and closer and no case-fold-equivalent marker within its payload. These fixtures cover local output only. Evidence inputs, sign-off verification, the assessor payload, stored values, peer output, scopes and consent rules keep their current behavior. No ADR or mind-v1 amendment is proposed. [Operator ruling](https://git.groupthink.asia/dev/mail-mind-mcp/issues/228#issuecomment-46656) Please answer ACCOMMODATE or CLASH before implementation.
Author
Member

Mind-spec returned ACCOMMODATE on the revised #228 Unicode fence design. Ratatoskr answer 710a9929-151b-4099-821f-e3e229ce83da on mail224-canonical. The required reviews and exact-head CI apply to the revised implementation. Design

Mind-spec returned `ACCOMMODATE` on the revised #228 Unicode fence design. Ratatoskr answer `710a9929-151b-4099-821f-e3e229ce83da` on `mail224-canonical`. The required reviews and exact-head CI apply to the revised implementation. [Design](https://git.groupthink.asia/dev/mail-mind-mcp/issues/228#issuecomment-46659)
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
dev/mail-mind-mcp#228
No description provided.