Skip to content

security(mcp): harden validate_roots() and truncate_instructions()#2458

Merged
bug-ops merged 1 commit intomainfrom
2455-mcp-security-hardening
Mar 30, 2026
Merged

security(mcp): harden validate_roots() and truncate_instructions()#2458
bug-ops merged 1 commit intomainfrom
2455-mcp-security-hardening

Conversation

@bug-ops
Copy link
Copy Markdown
Owner

@bug-ops bug-ops commented Mar 30, 2026

Summary

Test plan

  • validate_roots_file_uri_traversal_is_canonicalized — traversal URI is canonicalized
  • validate_roots_file_uri_is_kept — normal file:// URI passes through
  • truncate_instructions_sanitizes_injection — injection patterns in server instructions are replaced with [sanitized]
  • 338/338 zeph-mcp lib tests pass
  • Full workspace: 7341/7341 pass, clippy clean, fmt clean

Closes #2455
Closes #2456

@github-actions github-actions bot added documentation Improvements or additions to documentation rust Rust code changes size/M Medium PR (51-200 lines) labels Mar 30, 2026
Closes #2455: apply std::fs::canonicalize() in validate_roots() so that
path traversal payloads (file:///etc/../secret) are resolved and
rejected. Non-existent paths fall through with a warning to preserve
compatibility with remote MCP servers.

Closes #2456: apply sanitize_string() to server instructions in
truncate_instructions() before length truncation, matching the
sanitization already applied to tool descriptions.
@bug-ops bug-ops force-pushed the 2455-mcp-security-hardening branch from b69386a to 77f7e52 Compare March 30, 2026 19:21
@bug-ops bug-ops enabled auto-merge (squash) March 30, 2026 19:21
@bug-ops bug-ops merged commit e09bab9 into main Mar 30, 2026
27 checks passed
@bug-ops bug-ops deleted the 2455-mcp-security-hardening branch March 30, 2026 19:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation rust Rust code changes size/M Medium PR (51-200 lines)

Projects

None yet

1 participant