sec(mcp): bound create_stack manifest + service count + create_deploy env_vars#31
Merged
Merged
Conversation
… env_vars
Security audit 2026-05-29 hardening, defense in depth (CWE-770 — unbounded
resource alloc on tool args):
- create_stack:
- manifest cap 256 KiB (matches the api's openapi documented limit)
- service_tarballs map cap 32 entries (matches the api's per-stack ceiling)
- service-name keys must match ^[A-Za-z0-9][A-Za-z0-9 _-]*$ (1..64)
— same contract as every other resource name. The multipart wire
format (undici) already percent-encodes control bytes in field
names so there's no header-injection vector at the transport
layer, but a clean key contract prevents server-side surprises
with manifest `service://<name>` cross-refs.
- create_deploy:
- env_vars / resource_bindings each cap 256 entries + 8 KiB per value.
Without these bounds a hostile agent host could pass an unbounded
record and the MCP would serialise the whole thing into the multipart
`env_vars` form field before the api rejects on size.
Coverage: every legitimate input fits comfortably under the new caps; all
287 existing tests still pass. No runtime behaviour change for honest
callers, just precise local errors instead of round-tripping a giant
payload to the api just to get a 400 back.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Defense-in-depth hardening on the multipart-shaped tool args. Cap unbounded record / string inputs so a hostile MCP host can't waste the 50 MiB / 200 MB multipart budgets before the api gets a chance to reject.
Discovered during the security audit wave 2026-05-29 (mcp + cli scope). Full inbox: `/tmp/qa-session/shared/SEC-INBOX.md` findings F-15 + F-23.
Changes
Why not just trust the api?
Two reasons:
Coverage
Audit findings index (not all in this PR)
Out-of-scope here
🤖 Generated with Claude Code