Skip to content

fix(codegen,core): close DoS and charset gaps in generated bridge validator - #485

Merged
bug-ops merged 1 commit into
masterfrom
fix/471-bridge-validator-gaps
Aug 11, 2026
Merged

fix(codegen,core): close DoS and charset gaps in generated bridge validator#485
bug-ops merged 1 commit into
masterfrom
fix/471-bridge-validator-gaps

Conversation

@bug-ops

@bug-ops bug-ops commented Aug 11, 2026

Copy link
Copy Markdown
Owner

Summary

  • Render the DoS size/count ceilings (MAX_ARG_COUNT, MAX_ARG_LEN, MAX_ENV_COUNT, MAX_ENV_VALUE_LEN, MAX_URL_LEN, MAX_HEADER_COUNT, MAX_HEADER_VALUE_LEN) from mcp-execution-core into BridgeContext and enforce them in the generated TypeScript runtime bridge, mirroring validate_stdio_size_bounds/validate_network_size_bounds and their ordering ahead of injection-specific checks.
  • Port the [A-Za-z_][A-Za-z0-9_]* charset restriction from validate_env_name into the generated bridge's validateEnvName, rendered from a shared pattern (escaped via sanitize_ts_string_literal) instead of hand-copied.
  • Reject non-string env/header values and non-object env/headers fields outright at the bridge boundary, closing the CWE-400 gap where a config edited after generation could bypass the new ceilings entirely.

Fixes

Closes #471, closes #467

Test plan

  • cargo +nightly fmt --check
  • cargo clippy --all-targets --all-features --workspace -- -D warnings
  • cargo nextest run --all-features --workspace --no-fail-fast (1397 passed)
  • cargo test --doc --all-features --workspace
  • rustdoc gate (RUSTFLAGS="-D warnings" RUSTDOCFLAGS="--deny rustdoc::broken_intra_doc_links" cargo doc --no-deps --workspace)
  • New behavioral tests compile and execute the generated bridge under Node (tsc --noEmit --strict, real spawn-path assertions), including boundary/at-cap and multi-byte UTF-8 cases

…idator

The generated TypeScript runtime bridge mirrored the Rust command
validator's injection checks but omitted its DoS size/count ceilings
entirely, and validateEnvName lacked the ASCII-charset restriction
its Rust counterpart already enforced. Both gaps let a config edited
after generation reach spawn() with unbounded argv/env/headers or a
Unicode-ambiguous env name.

Render the size/count constants and charset pattern from
mcp-execution-core into BridgeContext instead of hand-copying them,
so the generated checks cannot silently drift from their Rust source
of truth again. Reject non-string and non-object env/header values
outright rather than skipping their length checks.

Closes #471, #467
@github-actions github-actions Bot added area: codegen Code generation area: core Core types and infrastructure crate: mcp-core Changes to mcp-core crate (foundation types, traits, errors) crate: mcp-codegen Changes to mcp-codegen crate (TypeScript code generation) type: documentation Documentation changes (*.md, docs/, comments) breaking change Contains breaking API changes (requires major version bump) release Release preparation (changelog, version bumps) labels Aug 11, 2026
@bug-ops
bug-ops merged commit 9931e92 into master Aug 11, 2026
22 checks passed
@bug-ops
bug-ops deleted the fix/471-bridge-validator-gaps branch August 11, 2026 09:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: codegen Code generation area: core Core types and infrastructure breaking change Contains breaking API changes (requires major version bump) crate: mcp-codegen Changes to mcp-codegen crate (TypeScript code generation) crate: mcp-core Changes to mcp-core crate (foundation types, traits, errors) release Release preparation (changelog, version bumps) type: documentation Documentation changes (*.md, docs/, comments)

Projects

None yet

1 participant