Skip to content

fix(mcp): fence PR/issue comments and browser tool outputs against prompt injection (CLO-1113) - #237

Open
nullStack65 wants to merge 1 commit into
release/native-0.1.10from
fix/clo-1113-mcp-tool-output-fencing
Open

nullStack65 wants to merge 1 commit into
release/native-0.1.10from
fix/clo-1113-mcp-tool-output-fencing

Conversation

@nullStack65

Copy link
Copy Markdown
Owner

Part of CLO-1113 (audit finding A-P1-10: Reduce blast radius).

Summary

Completes the native T3 MCP server untrusted-content framing companion to nullStack65/t3code#221:

  • pull_request_read (apps/server/src/mcp/toolkits/pullRequests/handlers.ts): Wraps body, conversation.reviewThreads[].comments[].body, and conversation.comments[].body in <untrusted-pr-description-*> / <untrusted-pr-comment-*> boundary tags with spoofed closing-tag and mention neutralization.
  • read_issue (apps/server/src/mcp/toolkits/issues/handlers.ts): Wraps body and comments[].body in <untrusted-issue-description-*> / <untrusted-issue-comment-*> boundary tags.
  • preview_snapshot (apps/server/src/mcp/McpHttpServer.ts): Wraps both content snapshot JSON text and structuredContent visibleText / accessibilityTree inside <untrusted-preview-snapshot-*> fences while keeping aria-ref locators intact and keeping total UTF-8 output within MAX_SNAPSHOT_TEXT_BYTES (20,000 bytes).
  • preview_evaluate (apps/server/src/mcp/toolkits/preview/handlers.ts): Recursively wraps string leaves in { value } via frameUntrustedJsonValue(..., "preview_evaluate") while preserving typed numbers, booleans, null, arrays, and object structure.
  • Tests: Expands untrustedContent.test.ts, pullRequests/handlers.test.ts, issues/handlers.test.ts, preview/handlers.test.ts, and McpHttpServer.test.ts with adversarial prompt-injection and spoofed-closing-tag assertions.

Deploy: fleet

Prior art

Searched: 2026-11-27 gh search repos "prompt injection mcp" --updated ">=2025-11-27" --sort stars --limit 15

  • HeadyZhang/agent-audit: reject - static vulnerability scanner for agent configurations rather than runtime untrusted-output framing.
  • akanthed/SecureAI-Scan: reject - external scanning CLI that adds third-party runtime dependencies instead of zero-dependency boundary tagging inside T3's Effect MCP server.
  • efij/secure-claude-code: reject - Claude-Code-only hook wrapper that does not cover Codex, Antigravity, Pi, or native T3 MCP tool handlers.
  • apps/server/src/security/untrustedContent.ts: extend - reuses the existing randomized <untrusted-label-id> boundary helper introduced in #221 across the remaining MCP read/browser toolkits.

Model: gemini-4-carbon
Task: fix
Agent: Builder
Harness: t3/antigravity
Model-family: Gemini (runtime model label)
Model-generation: 4 (runtime model label)
Skills-SHA: 605bd914249d98bfcd493d4933474a07183e5856; AGENTS.md, bot-baseline.md, skills/t3-session-lifecycle/SKILL.md, skills/pr-review-and-closeout/SKILL.md

@coderabbitai

coderabbitai Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@nullStack65

Copy link
Copy Markdown
Owner Author
{
  "reviewed_base": "b64e48d52718896b379866bfa4099dbaa908abb8",
  "reviewed_head": "bb253f0d8430ed2fcd5ab6317d6b6a654e610d31",
  "reviewer": "claude-opus-5-5, t3/claudeAgent",
  "reviewer_family": "claude",
  "author_session": "mcp:4edf9483-c71c-4f93-a974-0f655381e227",
  "reviewer_session": "thread:delegated-task:command%3Amcp%3Af55e2085-6d7b-4d16-9399-708a35775c31%3Adelegate-task%3Aclo-1113-review-t3code-pr-237-claude",
  "fresh_context": true,
  "review_kind": "full",
  "round_id": "round-pr237-1",
  "intent": ["CLO-1113 Scope 1: fence pull_request_read, read_issue, preview_snapshot, preview_evaluate outputs"],
  "prior_findings": [],
  "findings": [
    {
      "id": "F1",
      "severity": "important",
      "outcome": "open",
      "summary": "preview_snapshot structuredContent fenced only visibleText and accessibilityTree, leaving title, url, consoleEntries, networkEntries, actionTimeline, and the first {url} text block unfenced.",
      "file": "apps/server/src/mcp/McpHttpServer.ts",
      "line": 547,
      "check": "Code inspection of structuredValue and content[0] in McpHttpServer.ts"
    },
    {
      "id": "F2",
      "severity": "important",
      "outcome": "open",
      "summary": "frameUntrustedJsonValue added ~300 bytes per string leaf without bounding total output to 64 KB and left attacker-controlled object keys unfenced in preview_evaluate.",
      "file": "apps/server/src/mcp/toolkits/preview/handlers.ts",
      "line": 254,
      "check": "Array(12_000).fill('a') expands to 3.6 MB framed and {'SYSTEM: ...': 1} leaves key bare"
    },
    {
      "id": "F3",
      "severity": "nit",
      "outcome": "open",
      "summary": "boundSnapshotMetadata shrink loop measured structured bytes before adding omitted, allowing structuredContent to exceed 20,000 bytes slightly.",
      "file": "apps/server/src/mcp/McpHttpServer.ts",
      "line": 563,
      "check": "Code inspection of boundSnapshotMetadata omitted attachment"
    },
    {
      "id": "F4",
      "severity": "nit",
      "outcome": "skipped",
      "summary": "UNTRUSTED_BREAK_PATTERN from #221 inserts U+2060 after @, currency symbols, and standalone /tokens inside framed payloads.",
      "file": "apps/server/src/security/untrustedContent.ts",
      "line": 21,
      "check": "Intentional shared CLI mention/slash-command neutralizer from PR #221"
    },
    {
      "id": "F5",
      "severity": "nit",
      "outcome": "skipped",
      "summary": "PR/issue titles, review-thread paths, and check run names remain unfenced metadata outside CLO-1113 Scope 1 description/comment scope.",
      "file": "apps/server/src/mcp/toolkits/pullRequests/handlers.ts",
      "line": 706,
      "check": "Scoped to PR/issue descriptions and comments per CLO-1113"
    }
  ]
}

nullStack65 added a commit that referenced this pull request Nov 27, 2026
…view_evaluate (CLO-1113)

Addresses clean-room review findings F1-F3 on PR #237:

- Fence preview_snapshot structuredContent via a single untrustedSnapshot
  envelope (leaving no bare title, url, or consoleEntries fields) and fence
  the first {url} text block as well (F1).
- Include omitted inside the 20,000-byte boundSnapshotMetadata shrink loop
  so structuredContent never exceeds MAX_SNAPSHOT_TEXT_BYTES (F3).
- Replace leaf-by-leaf preview_evaluate framing with single-envelope
  frameBoundedUntrustedValue so object keys are fenced and total UTF-8
  output stays <= 64,000 bytes (F2).

Model: gemini-4-carbon
Task: fix
Agent: Builder
Harness: t3/antigravity
Model-family: Gemini (runtime model label)
Model-generation: 4 (runtime model label)
Skills-SHA: 605bd914249d98bfcd493d4933474a07183e5856; AGENTS.md, bot-baseline.md, skills/t3-session-lifecycle/SKILL.md, skills/pr-review-and-closeout/SKILL.md
@nullStack65

Copy link
Copy Markdown
Owner Author
{
  "reviewed_base": "9fd13faa16321f87a07916f0550e14b8a99dd47a",
  "reviewed_head": "d15fb692cbd91e32b74f50587518f19ef7bc33ed",
  "patch_id": "8d7b36d5beb810764a525ebf21c99201a3e4f55f",
  "reviewer": "claude-opus-5-5, t3/claudeAgent",
  "reviewer_family": "claude",
  "author_session": "mcp:4edf9483-c71c-4f93-a974-0f655381e227",
  "reviewer_session": "thread:delegated-task:command%3Amcp%3Af55e2085-6d7b-4d16-9399-708a35775c31%3Adelegate-task%3Aclo-1113-recheck-t3code-pr-237-claude",
  "fresh_context": true,
  "review_kind": "focused_recheck",
  "round_id": "round-pr237-1",
  "intent": [
    "CLO-1113 Scope 1: fence pull_request_read, read_issue, preview_snapshot, preview_evaluate outputs"
  ],
  "prior_findings": [
    "F1",
    "F2",
    "F3"
  ],
  "findings": [
    {
      "id": "F1",
      "severity": "important",
      "outcome": "confirmed",
      "rechecked_head": "d15fb692cbd91e32b74f50587518f19ef7bc33ed",
      "summary": "preview_snapshot structuredContent fenced only visibleText and accessibilityTree, leaving title, url, consoleEntries, networkEntries, actionTimeline, and the first {url} text block unfenced.",
      "file": "apps/server/src/mcp/McpHttpServer.ts",
      "line": 547,
      "check": "structuredValue holds only loading/screenshot/screenshotPath/untrustedSnapshot/omitted; {url} and saved.url fenced; McpHttpServer.test.ts 45/45"
    },
    {
      "id": "F2",
      "severity": "important",
      "outcome": "confirmed",
      "rechecked_head": "d15fb692cbd91e32b74f50587518f19ef7bc33ed",
      "summary": "frameUntrustedJsonValue added ~300 bytes per string leaf without bounding total output to 64 KB and left attacker-controlled object keys unfenced in preview_evaluate.",
      "file": "apps/server/src/mcp/toolkits/preview/handlers.ts",
      "line": 254,
      "check": "frameBoundedUntrustedValue wraps keys+values in single envelope <= 64000 UTF-8 bytes; untrustedContent.test.ts 5/5, handlers.test.ts 5/5"
    },
    {
      "id": "F3",
      "severity": "nit",
      "outcome": "fixed",
      "rechecked_head": "d15fb692cbd91e32b74f50587518f19ef7bc33ed",
      "summary": "boundSnapshotMetadata shrink loop measured structured bytes before adding omitted, allowing structuredContent to exceed 20,000 bytes slightly.",
      "file": "apps/server/src/mcp/McpHttpServer.ts",
      "line": 563,
      "check": "computeOmitted() and structuredValue rebuilt inside while-loop byte check <= 20000"
    },
    {
      "id": "F4",
      "severity": "nit",
      "outcome": "skipped",
      "summary": "UNTRUSTED_BREAK_PATTERN from #221 inserts U+2060 after @, currency symbols, and standalone /tokens inside framed payloads.",
      "file": "apps/server/src/security/untrustedContent.ts",
      "line": 21,
      "check": "Intentional shared CLI mention/slash-command neutralizer from PR #221"
    },
    {
      "id": "F5",
      "severity": "nit",
      "outcome": "skipped",
      "summary": "PR/issue titles, review-thread paths, and check run names remain unfenced metadata outside CLO-1113 Scope 1 description/comment scope.",
      "file": "apps/server/src/mcp/toolkits/pullRequests/handlers.ts",
      "line": 706,
      "check": "Scoped to PR/issue descriptions and comments per CLO-1113"
    }
  ]
}

@nullStack65

nullStack65 commented Nov 27, 2026 •

Copy link
Copy Markdown
Owner Author
{
  "reviewed_base": "9fd13faa16321f87a07916f0550e14b8a99dd47a",
  "reviewed_head": "d15fb692cbd91e32b74f50587518f19ef7bc33ed",
  "reviewer": "grok-4.7, t3/grok-direct",
  "reviewer_family": "grok",
  "author_session": "mcp:4edf9483-c71c-4f93-a974-0f655381e227",
  "reviewer_session": "thread:delegated-task:command%3Amcp%3Aebe15491-8236-4634-977c-8445cee54b2c%3Adelegate-task%3Aclo-1113-review-t3code-pr-237-grok",
  "fresh_context": true,
  "review_kind": "full",
  "round_id": "round-pr237-2",
  "intent": [
    "CLO-1113 Scope 1: fence pull_request_read, read_issue, preview_snapshot, preview_evaluate outputs"
  ],
  "prior_findings": [],
  "findings": [
    {
      "id": "unfenced-diff-patch",
      "severity": "critical",
      "outcome": "fixed",
      "summary": "pull_request_read with include diff returns diff.patch verbatim without untrusted fencing.",
      "file": "apps/server/src/mcp/toolkits/pullRequests/handlers.ts",
      "line": 767,
      "check": "Code inspection of readSections diff.patch in pullRequests/handlers.ts",
      "fix_note": "fixed in 9e0f641f8121: diff.patch wrapped with frameUntrustedContent(pr_diff); handlers.test.ts asserts fence + unfence round-trip"
    },
    {
      "id": "unfenced-pr-issue-free-text",
      "severity": "important",
      "outcome": "fixed",
      "summary": "pull_request_read and read_issue return free-text metadata outside the fence (PR title, headBranch, checks.failed, checkRuns name/description/url, review/comment paths, issue title, label names, linked PR titles).",
      "file": "apps/server/src/mcp/toolkits/pullRequests/handlers.ts",
      "line": 706,
      "check": "Code inspection of pullRequests/handlers.ts and issues/handlers.ts",
      "fix_note": "fixed in 9e0f641f8121: PR title/headBranch/checks.failed/checkRuns name+description+url/thread+comment paths and issue title/labels/linked PR titles fenced; ci_logs, ci_rerun and review placement unwrap fenced input; tests updated"
    },
    {
      "id": "unfenced-evaluate-page-url",
      "severity": "important",
      "outcome": "fixed",
      "summary": "preview_evaluate attaches toolIcon.pageUrl from the live page URL (up to 4096 chars) outside the untrusted fence.",
      "file": "apps/server/src/mcp/toolkits/preview/handlers.ts",
      "line": 255,
      "check": "Code inspection of preview/handlers.ts invoke toolIcon.pageUrl",
      "fix_note": "fixed in 9e0f641f8121: toolIcon.pageUrl reduced to URL origin (http/https only, <=255 chars); preview handlers.test.ts asserts origin only"
    },
    {
      "id": "evaluate-json-envelope-expands-past-64kb",
      "severity": "nit",
      "outcome": "fixed",
      "summary": "frameBoundedUntrustedValue caps raw UTF-8 bytes at 64000, while JSON-encoding control characters or quotes inside the tool envelope expands wire bytes to a bounded multiple.",
      "file": "apps/server/src/security/untrustedContent.ts",
      "line": 82,
      "check": "Payload bound inspection of frameBoundedUntrustedValue",
      "fix_note": "fixed in 9e0f641f8121: frameBoundedUntrustedValue bounds max(raw, JSON-encoded) UTF-8 bytes; control-character test added"
    }
  ]
}

@nullStack65

nullStack65 commented Nov 27, 2026 •

Copy link
Copy Markdown
Owner Author

Focused re-check of the second review round on head 9e0f641. Same base (b64e48d) at the reviewed and current heads; range-diff shows the two reviewed commits unchanged and one new commit, 9e0f641, with no merge commits. Tests on the head: vp test run untrustedContent, pullRequests/issues/preview handlers: 4 files, 54/54 passed.

New nit from this diff, noted here and not added as a finding ID (a focused re-check keeps the original IDs): read_issue now returns fenced label names and titles, but create_issue's label and title inputs (apps/server/src/mcp/toolkits/issues/tools.ts:294) do not unwrap a fenced value the way ci_logs, ci_rerun and review comment placement now do, so an agent copying a label verbatim would create a label whose name is the fence text. Non-blocking.

{
  "reviewed_base": "9fd13faa16321f87a07916f0550e14b8a99dd47a",
  "reviewed_head": "d15fb692cbd91e32b74f50587518f19ef7bc33ed",
  "rechecked_head": "9e0f641f812183a50bf8dec6347577c59079bf63",
  "reviewer": "claude-opus-5-5, t3/claudeAgent",
  "reviewer_family": "claude",
  "author_session": "mcp:4edf9483-c71c-4f93-a974-0f655381e227",
  "reviewer_session": "thread:drain-supervisor-recheck-t3code-pr-237-claude",
  "fresh_context": true,
  "review_kind": "focused_recheck",
  "round_id": "round-pr237-2",
  "intent": [
    "CLO-1113 Scope 1: fence pull_request_read, read_issue, preview_snapshot, preview_evaluate outputs"
  ],
  "prior_findings": [
    "unfenced-diff-patch",
    "unfenced-pr-issue-free-text",
    "unfenced-evaluate-page-url",
    "evaluate-json-envelope-expands-past-64kb"
  ],
  "findings": [
    {
      "id": "unfenced-diff-patch",
      "severity": "critical",
      "outcome": "confirmed",
      "rechecked_head": "9e0f641f812183a50bf8dec6347577c59079bf63",
      "summary": "pull_request_read with include diff returns diff.patch verbatim without untrusted fencing.",
      "file": "apps/server/src/mcp/toolkits/pullRequests/handlers.ts",
      "line": 795,
      "check": "diff.patch now frameUntrustedContent(patch, pr_diff, frameId); review comment placement still uses the raw forge patch; pullRequests handlers.test.ts passes on head"
    },
    {
      "id": "unfenced-pr-issue-free-text",
      "severity": "important",
      "outcome": "confirmed",
      "rechecked_head": "9e0f641f812183a50bf8dec6347577c59079bf63",
      "summary": "pull_request_read and read_issue return free-text metadata outside the fence (PR title, headBranch, checks.failed, checkRuns name/description/url, review/comment paths, issue title, label names, linked PR titles).",
      "file": "apps/server/src/mcp/toolkits/pullRequests/handlers.ts",
      "line": 712,
      "check": "Every listed field fenced with a shared per-read frameId; schemas are plain String/TrimmedNonEmptyString so encoding holds; ci_logs/ci_rerun/review placement unwrap fenced input via unwrapUntrustedContentIfFenced (strips U+2060, falls back to raw); issues and pullRequests handlers tests pass"
    },
    {
      "id": "unfenced-evaluate-page-url",
      "severity": "important",
      "outcome": "confirmed",
      "rechecked_head": "9e0f641f812183a50bf8dec6347577c59079bf63",
      "summary": "preview_evaluate attaches toolIcon.pageUrl from the live page URL (up to 4096 chars) outside the untrusted fence.",
      "file": "apps/server/src/mcp/toolkits/preview/handlers.ts",
      "line": 92,
      "check": "safeWebsiteIconOrigin returns URL.origin only for http/https, <=255 chars, else no icon; preview handlers.test.ts passes"
    },
    {
      "id": "evaluate-json-envelope-expands-past-64kb",
      "severity": "nit",
      "outcome": "fixed",
      "rechecked_head": "9e0f641f812183a50bf8dec6347577c59079bf63",
      "summary": "frameBoundedUntrustedValue caps raw UTF-8 bytes at 64000, while JSON-encoding control characters or quotes inside the tool envelope expands wire bytes to a bounded multiple.",
      "file": "apps/server/src/security/untrustedContent.ts",
      "line": 67,
      "check": "Fast path and binary search both compare max(raw, JSON.stringify) UTF-8 bytes to maxBytes; untrustedContent.test.ts passes"
    }
  ]
}

@nullStack65

Copy link
Copy Markdown
Owner Author

Repair worker (drain supervisor) on head 9e0f641: no code change needed, nothing pushed.

The review gate hold on this PR (MCP prompt-injection fencing, CLO-1113) is evidence-only:

  1. F1 (preview_snapshot metadata unfenced) and F2 (preview_evaluate output unbounded, keys unfenced) are both confirmed on the older head d15fb69. The only commit since, 9e0f641, leaves apps/server/src/mcp/McpHttpServer.ts untouched (F1) and only tightens F2: frameBoundedUntrustedValue now bounds max(raw, JSON-encoded) bytes, and keys stay inside the single envelope. Tests on 9e0f641: vp test run McpHttpServer, preview handlers, untrustedContent: 3 files, 55/55 passed.
    Needed: a separate fresh focused re-check in round round-pr237-1 that sets rechecked_head (and reviewed_head) to 9e0f641 for F1 and F2. This worker did not post a gate record, since a separate re-check must confirm.
  2. unfenced-diff-patch (critical: PR diff returned without a fence) is fixed and re-checked on this head. It routes to the caller, who releases it (outcome released, released_by).

@nullStack65

Copy link
Copy Markdown
Owner Author

Focused re-check of the first review round (round-pr237-1: F1, F2, F3) on head 9e0f641f8121, by a fresh-context reviewer (claude-opus-5-5). Base b64e48d527 is the merge base with release/native-0.1.10. The only commit after d15fb69 is 9e0f641f81.

Results

  1. F1 preview_snapshot metadata fencing: fix confirmed on head.
  2. F2 preview_evaluate single envelope with a 64 KB cap and fenced keys: fix confirmed on head, including an independent byte-bound probe.
  3. F3 omitted count inside the 20 KB loop: no regression.
  4. Commit 9e0f641f81 does what its message claims. It fences diff.patch, the PR and issue free-text metadata listed in the message, and check name, description and url. ci_logs, ci_rerun and review placement unwrap fenced input. toolIcon.pageUrl is reduced to the http(s) origin. The JSON-encoded byte bound is applied in both the fast path and the binary search. I found no new problem from that commit beyond the non-blocking create_issue nit already noted in the round-2 re-check.

Tests on head (vp test run): McpHttpServer.test.ts, preview, pullRequests and issues handlers, and untrustedContent.test.ts gave 93/103. Every fencing, snapshot-bounding and evaluate test passes. The 10 failures are all in McpHttpServer.test.ts and are HTTP-transport tests (fetch failed / SocketError: other side closed on 127.0.0.1). The same 10 fail identically on base b64e48d527 in this sandbox, so they are environmental and pre-existing, not caused by this PR.

Gate note

  1. This record carries the round-2 findings forward unchanged from the round-2 re-check (comment 7222047893), so that this newest record does not hide them. That includes the critical unfenced-diff-patch, which still needs caller release.
  2. Outcome confirmed here uses review_gate.py's meaning: the fix was confirmed on this head.
{
  "reviewed_base": "b64e48d52718896b379866bfa4099dbaa908abb8",
  "reviewed_head": "9e0f641f812183a50bf8dec6347577c59079bf63",
  "rechecked_head": "9e0f641f812183a50bf8dec6347577c59079bf63",
  "reviewer": "claude-opus-5-5, t3/claudeAgent",
  "reviewer_family": "claude",
  "author_session": "mcp:4edf9483-c71c-4f93-a974-0f655381e227",
  "reviewer_session": "t3:scratch/t3-b164f477-d36b59297784cdca (review sub-agent launched by mcp:launch:f93d3d4d5bdcacb3d83aee2e5aae7131e56913ed18a2c8a2c972ddf37cd17acb)",
  "fresh_context": true,
  "review_kind": "focused_recheck",
  "round_id": "round-pr237-1",
  "intent": [
    "CLO-1113 Scope 1: fence pull_request_read, read_issue, preview_snapshot, preview_evaluate outputs"
  ],
  "prior_findings": [
    "F1",
    "F2",
    "F3"
  ],
  "findings": [
    {
      "id": "F1",
      "severity": "important",
      "outcome": "confirmed",
      "rechecked_head": "9e0f641f812183a50bf8dec6347577c59079bf63",
      "summary": "preview_snapshot structuredContent fenced only visibleText and accessibilityTree, leaving title, url, consoleEntries, networkEntries, actionTimeline, and the first {url} text block unfenced.",
      "file": "apps/server/src/mcp/McpHttpServer.ts",
      "line": 564,
      "check": "On head: structuredValue carries only loading, screenshot dims, screenshotPath (hostname slug), untrustedSnapshot (whole page JSON in one preview_snapshot envelope) and fixed-label omitted strings; first {url} text block (l.850) and saved-path url (l.821) fenced with the same frameId. McpHttpServer.test.ts 'fences preview_snapshot text and structuredContent against prompt injection' passes."
    },
    {
      "id": "F2",
      "severity": "important",
      "outcome": "confirmed",
      "rechecked_head": "9e0f641f812183a50bf8dec6347577c59079bf63",
      "summary": "frameUntrustedJsonValue added ~300 bytes per string leaf without bounding total output to 64 KB and left attacker-controlled object keys unfenced in preview_evaluate.",
      "file": "apps/server/src/security/untrustedContent.ts",
      "line": 76,
      "check": "On head: preview/handlers.ts:264 calls frameBoundedUntrustedValue, which JSON.stringifies objects (keys included) into one envelope, binary-searches to <=64000 bytes on max(raw, JSON-encoded) UTF-8. Independent probe: quote/newline-heavy string, 50k emoji, 5000 injected keys all came out as a single envelope at 64000/64000/63999 JSON bytes and unfenced cleanly. untrustedContent.test.ts 64 KB test and preview handlers test pass."
    },
    {
      "id": "F3",
      "severity": "nit",
      "outcome": "fixed",
      "rechecked_head": "9e0f641f812183a50bf8dec6347577c59079bf63",
      "summary": "boundSnapshotMetadata shrink loop measured structured bytes before adding omitted, allowing structuredContent to exceed 20,000 bytes slightly.",
      "file": "apps/server/src/mcp/McpHttpServer.ts",
      "line": 604,
      "check": "No regression: computeOmitted() and structuredValue(text, omitted) are rebuilt inside the while loop (l.603-606) before the 20,000-byte check; the 4 snapshot-bounding tests pass."
    },
    {
      "id": "F4",
      "severity": "nit",
      "outcome": "skipped",
      "summary": "UNTRUSTED_BREAK_PATTERN from #221 inserts U+2060 after @, currency symbols, and standalone /tokens inside framed payloads.",
      "file": "apps/server/src/security/untrustedContent.ts",
      "line": 21,
      "check": "Carried from round-1 record; intentional shared neutralizer."
    },
    {
      "id": "F5",
      "severity": "nit",
      "outcome": "skipped",
      "summary": "PR/issue titles, review-thread paths, and check run names remain unfenced metadata outside CLO-1113 Scope 1 description/comment scope.",
      "file": "apps/server/src/mcp/toolkits/pullRequests/handlers.ts",
      "line": 712,
      "check": "Carried from round-1 record; superseded by round-2 unfenced-pr-issue-free-text, fenced in 9e0f641f8121."
    },
    {
      "id": "unfenced-diff-patch",
      "severity": "critical",
      "outcome": "confirmed",
      "rechecked_head": "9e0f641f812183a50bf8dec6347577c59079bf63",
      "summary": "pull_request_read with include diff returns diff.patch verbatim without untrusted fencing.",
      "file": "apps/server/src/mcp/toolkits/pullRequests/handlers.ts",
      "line": 795,
      "check": "diff.patch now frameUntrustedContent(patch, pr_diff, frameId); review comment placement still uses the raw forge patch; pullRequests handlers.test.ts passes on head",
      "carried_from": "https://github.com/nullStack65/t3code/pull/237#issuecomment-7222047893 (round-pr237-2; carried unchanged, not re-litigated here)"
    },
    {
      "id": "unfenced-pr-issue-free-text",
      "severity": "important",
      "outcome": "confirmed",
      "rechecked_head": "9e0f641f812183a50bf8dec6347577c59079bf63",
      "summary": "pull_request_read and read_issue return free-text metadata outside the fence (PR title, headBranch, checks.failed, checkRuns name/description/url, review/comment paths, issue title, label names, linked PR titles).",
      "file": "apps/server/src/mcp/toolkits/pullRequests/handlers.ts",
      "line": 712,
      "check": "Every listed field fenced with a shared per-read frameId; schemas are plain String/TrimmedNonEmptyString so encoding holds; ci_logs/ci_rerun/review placement unwrap fenced input via unwrapUntrustedContentIfFenced (strips U+2060, falls back to raw); issues and pullRequests handlers tests pass",
      "carried_from": "https://github.com/nullStack65/t3code/pull/237#issuecomment-7222047893 (round-pr237-2; carried unchanged, not re-litigated here)"
    },
    {
      "id": "unfenced-evaluate-page-url",
      "severity": "important",
      "outcome": "confirmed",
      "rechecked_head": "9e0f641f812183a50bf8dec6347577c59079bf63",
      "summary": "preview_evaluate attaches toolIcon.pageUrl from the live page URL (up to 4096 chars) outside the untrusted fence.",
      "file": "apps/server/src/mcp/toolkits/preview/handlers.ts",
      "line": 92,
      "check": "safeWebsiteIconOrigin returns URL.origin only for http/https, <=255 chars, else no icon; preview handlers.test.ts passes",
      "carried_from": "https://github.com/nullStack65/t3code/pull/237#issuecomment-7222047893 (round-pr237-2; carried unchanged, not re-litigated here)"
    },
    {
      "id": "evaluate-json-envelope-expands-past-64kb",
      "severity": "nit",
      "outcome": "fixed",
      "rechecked_head": "9e0f641f812183a50bf8dec6347577c59079bf63",
      "summary": "frameBoundedUntrustedValue caps raw UTF-8 bytes at 64000, while JSON-encoding control characters or quotes inside the tool envelope expands wire bytes to a bounded multiple.",
      "file": "apps/server/src/security/untrustedContent.ts",
      "line": 67,
      "check": "Fast path and binary search both compare max(raw, JSON.stringify) UTF-8 bytes to maxBytes; untrustedContent.test.ts passes",
      "carried_from": "https://github.com/nullStack65/t3code/pull/237#issuecomment-7222047893 (round-pr237-2; carried unchanged, not re-litigated here)"
    }
  ]
}

…ompt injection (CLO-1113)

Squashed onto current base so the drain can re-review a fresh head. No
functional change beyond the rebase; original PR authoring model trailers are
preserved in the PR body.

Model: claude-sonnet-5-5
Task: fix
Agent: Builder drain parked-PR lane (Claude Code worker F8)
Lane: magpie
Harness: t3/claude-code
Model-family: Claude
Model-generation: Sonnet 5.5
Skills-SHA: unknown (source unavailable)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@nullStack65
nullStack65 force-pushed the fix/clo-1113-mcp-tool-output-fencing branch from 9e0f641 to f771ba2 Compare November 28, 2026 05:59

This branch has not been deployed

No deployments
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.

1 participant