Skip to content

fix: MCP publish arbitrary file read via spec_path (security) — v0.12.11#75

Merged
TheAmericanMaker merged 1 commit into
mainfrom
fix/mcp-publish-path-containment
Jul 23, 2026
Merged

fix: MCP publish arbitrary file read via spec_path (security) — v0.12.11#75
TheAmericanMaker merged 1 commit into
mainfrom
fix/mcp-publish-path-containment

Conversation

@TheAmericanMaker

Copy link
Copy Markdown
Member

Security fix

MCP codecarto_publish accepted any absolute file path for spec_path without enforcing containment. An MCP client could read any file on the filesystem by passing its absolute path as spec_path.

Fix

  • readSpecArg now accepts allowedRoots parameter
  • handlePublish passes workspace .codecarto/ and library path as allowed roots
  • Uses isWithinPathResolved (symlink-aware) for containment check
  • 2 regression tests: rejects outside paths, accepts workspace paths

Discovery

Found during the v0.12.9 self-analysis case study security triage. The semantic defect scan (Pass 5: API Contract Violations) identified it. The security triage subagent classified it as blocking.

Validation

  • 270/270 tests pass (268 + 2 new)
  • Build clean

The readSpecArg function accepted any absolute file path for spec_path
without enforcing containment. An MCP client could read any file on the
filesystem (e.g. /etc/passwd) by passing its absolute path as spec_path.

Fix: added path containment check using isWithinPathResolved. spec_path
must be within the workspace .codecarto/ directory or the configured
library path. Regression tests verify both rejection and acceptance.

270/270 tests pass (268 + 2 new).
@TheAmericanMaker
TheAmericanMaker merged commit 2eec9d3 into main Jul 23, 2026
5 checks passed
@TheAmericanMaker
TheAmericanMaker deleted the fix/mcp-publish-path-containment branch July 23, 2026 21:39
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