Repository navigation
fix(mcp): reject malformed base64 file writes - #378
Prajwal2246 wants to merge 1 commit into
Conversation
|
@Prajwal2246 is attempting to deploy a commit to the superserve Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
Your trial has ended. Reactivate Greptile to resume code reviews.
There was a problem hiding this comment.
OnePatch is tracking this change: malformed base64 is rejected at the sandbox_files_write boundary instead of being silently decoded into an empty or truncated overwrite.
Watching
- The hosted MCP server (
Production – superserve-mcp) deploys the merge commit, so the validation is actually live — baseline 30 success / 0 failure over 30 days. - CI /
Lint, typecheck, test, buildstays green on main at the merge commit, within its usual ~164s — the 23 new cases are the only thing pinning the accepted alphabet. -
Production – uiandProduction – consoleship the same commit, as build witnesses that localise any failure topackages/mcp.
Would fail it
- The superserve-mcp production deployment goes red, or never reports the merge commit — the #377 overwrite bug stays unfixed in production.
- CI goes red on main: a failing test means the validator and its documented contract disagree, and the live risk is rejecting a write that used to succeed.
- A sibling Vercel project ships the commit while superserve-mcp does not.
Note on coverage: the hosted MCP server sends OnePatch no telemetry, so the rejection rate itself cannot be measured — these checks verify that the change reaches production, not how it behaves once there. Installed @superserve/mcp copies keep the old handler until a release is cut.
changes/superserve-ai--superserve--pr-378 · awaiting merge
|
Hi @meAmitPatil 👋 I've rebased this on the latest |
cc68741 to
63f8833
Compare
Related Issues
Fixes #377
Description
Reject malformed base64 in
sandbox_files_writebefore calling the write client. Previously, inputs such as!!!orSGVsbG8=garbagecould silently overwrite a file with empty or partial content becauseBuffer.fromaccepts invalid input.Validate the alphabet, length, and padding at the MCP boundary. Keep standard and URL-safe characters, optional padding, ASCII whitespace, intentional empty writes, text writes, and the decoded-size limit supported. Document the accepted variants in the tool's content description.
Additional Context
The SDK receives decoded bytes, so validation belongs in the MCP handler while the original encoded input is still available. No dependencies or SDK interfaces change.
Testing
Added 23 tests through the existing in-memory MCP transport and fake sandbox client. All 12 malformed-input cases failed against the unchanged handler and pass with the fix; they assert that the write client is not called and existing contents are preserved. Other cases cover accepted encodings, empty content, and exactly/above the 8 MiB decoded-size limit.
bun run lint,bun run format:check,bun run typecheck,bun run build, andbun run docs:check-navpassed.Screenshots/Demo
Not applicable; no UI changes.