Skip to content

Commit e4d0c8d

Browse files
committed
Tamper an interior requestState character in the rejection test
1 parent e4c54b9 commit e4d0c8d

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

‎packages/hosts/mcp/src/tool-server-v2.test.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,12 @@ describe("SDK v2 Executor MCP assembly", () => {
251251
expect(isInputRequiredResult(first)).toBe(true);
252252
if (!isInputRequiredResult(first) || !first.requestState) return;
253253

254-
const tampered = `${first.requestState.slice(0, -1)}x`;
254+
// Corrupt an interior character: changing the final one can only touch
255+
// discarded base64url padding bits, which lenient decoders (Bun) drop —
256+
// the decoded bytes would be identical and the signature would verify.
257+
const middle = Math.floor(first.requestState.length / 2);
258+
const swapped = first.requestState[middle] === "A" ? "B" : "A";
259+
const tampered = `${first.requestState.slice(0, middle)}${swapped}${first.requestState.slice(middle + 1)}`;
255260
await expect(
256261
manualToolCall(client, {
257262
name: "execute",

0 commit comments

Comments
 (0)