Repository navigation
[MCP contract security 1/2] Review complete tool contracts before trust - #803
salmonumbrella wants to merge 9 commits into
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 941d3f806d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| switch v := v.(type) { | ||
| case string: | ||
| return has(v) | ||
| case map[string]any: |
There was a problem hiding this comment.
Reject numeric credential echoes before exposing contracts
When a fromEnv credential is a numeric string such as 123456, an MCP server can echo it as a JSON number in _meta or a schema default. contractJSON preserves that value as json.Number, but this switch ignores numbers, so captureTool succeeds, exposes the credential in the new CLI/API snapshots, and allows it into an approved baseline. The same omission exists in containsLiveSecret in check_live.go, allowing numeric identity material through its credential check too. Check numeric lexemes against known credentials in both helpers before exposing or fingerprinting them.
AGENTS.md reference: AGENTS.md:L36-L36
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in dbcc5726: both contractHasSecret and containsLiveSecret inspect exact json.Number lexemes before contract capture or fingerprinting. Numeric capture coverage is retained in TestCaptureContractKnownShortSecretsInDecodedKeysAndValues; the live-probe path remains covered by TestNumericConnectionCredentialRejectedBeforeProbeAndFingerprint. Current-head CI is pending.
| if opts.StrictTools { | ||
| result.Findings = append(result.Findings, CheckFinding{Level: "error", Check: "tool-change", Message: "strict tool checking requires a complete live observation"}) |
There was a problem hiding this comment.
Exempt disabled entries from strict observation failures
For a project containing a disabled: true switch created through the dashboard’s off toggle, liveSkipReason correctly skips the entry, but this branch turns that expected skip into an error whenever --strict-tools is set. Consequently, strict checks fail even when every enabled server has an unchanged approved contract. The disabled entry cannot acquire a baseline to clear the error because it intentionally has no connection fields. Exempt disabled entries from the complete-live-observation requirement.
AGENTS.md reference: AGENTS.md:L36-L36
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in dbcc5726. Strict live checking adds a completeness error only for a skipped server that is not disabled, so intentionally disabled project entries retain the expected skip behavior. TestLiveStrictToolsSkipsDisabledProjectEntry covers it. Current-head CI is pending.
941d3f8 to
3d01ea0
Compare
|
@codex review |
|
Codex Review: Didn't find any major issues. 🚀 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3d01ea0565
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| } | ||
| for i := range report.Servers { | ||
| result := &report.Servers[i] | ||
| result.Name, result.Project = redactor.redact(result.Name), redactor.redact(result.Project) |
There was a problem hiding this comment.
Preserve lossless project roots in check results
For an mcp.projects folder added through the dashboard whose name contains a legitimate format character such as Persian ZWNJ (U+200C), redactor.redact replaces that character with the literal \u200c sequence in project. MCPContractReview.tsx:168 then sends this display-escaped value as the approval root, so Check's exact source.Projects[root] lookup rejects an otherwise valid reviewed inventory; useMCPCheck.ts:7 also stops associating static findings with that project. Preserve a lossless scope identifier for these consumers and escape it only when rendering, while retaining credential redaction for refusals.
AGENTS.md reference: AGENTS.md:L36-L36
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 4b2de1ba. Check results preserve exact project-scope bytes unless they contain a known credential, in which case review is refused and the value is redacted. The dashboard matches and submits the exact root while escaping it for display. Coverage is in TestCheckProjectScopePreservesControlsAndRedactsCredentials and associates and approves the exact project root while escaping it for display. Current-head CI is pending.
Extend existing tool pinning with complete bounded snapshots, conservative contract differences and credential-safe descriptor audits. Bind approval to the reviewed inventory, connection identity, scope and current source/store. Share explicit revision-bound acceptance across CLI and local dashboard API, harden discovery transports and preserve full exact-number review text. Document threat boundaries and independently authored prior-art provenance. Tests are authored but unrun: required local devcontainer is unavailable. Remote CI and review must verify compilation and runtime behavior.
Preserve credential-free project root identifiers exactly so dashboard checks associate the right project and approvals submit the selected scope. Continue redacting credential-bearing roots after refusing their review, and escape controls at presentation boundaries. The rebased feature already rejects numeric credential lexemes in both contract and live checks and excludes disabled project entries from strict observation failures; their regression coverage remains in the feature commit.
Remove unreachable and duplicated scenarios, retain unique credential and scope checks, and use valid server fixtures. Exercise real control runes in JSON output and consolidate dashboard refusal and localization cases.
Combine remaining scope, persistence, status and contract cases into shared tables while preserving distinct behavior checks and reachable fixtures.
Resolve the stdio working directory before launch and bind that same path into the review identity, so retargeted symlinks cannot reuse approval. Reject unresolved directories before starting a server. Parse HTTP media types to handle case and parameters in event streams and discovery errors. Exercise both cases and remove the disclaimer-only UI test.
Describe the complete contract snapshots stored in tool-pins.json and warn that their text may be sensitive. Keep the existing translated file maps consistent.
Fingerprint the explicit transport, credential references, tool policy and native options without target selection or disabled state. Client selection changes can then retain an unchanged contract approval.
Keep the live review, explicit revision approval and fresh unchanged check as the CLI integration boundary while leaving detailed drift and logging coverage to their owning tests.
Remove the unsupported disabled entry with an active connection while retaining identity and approval coverage for valid target changes.
3d01ea0 to
4764636
Compare
|
@codex review The requested fixes to all three open findings are in this rebased head: |
|
Codex Review: Didn't find any major issues. Another round soon, please! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
@runkids ready |
|
Thanks for all the work you've put into these. A lot of large PRs have arrived at once, more than I can take in right now, so I need to go through them slowly. I can't promise a date, but I'll get to them. |
Type
proposals/only)Linked Issue
Refs #789, specifically the RugSnare comment, and design note #802. This covers MCP contract protection, not the entire six-part issue.
What changed
Why
A server can change the instructions or schema it advertises after initial setup. Existing hashes warn about some changes but do not show the full contract or bind acceptance to the exact inventory reviewed. Users need to inspect the change before saving trust.
Usage
For same-name servers under
mcp.projects, select--root <configured-path>;--root ''selects this config's own server list. Project mode remains-p. In the dashboard, Review live tools opens an inert dialog; Probe live tools starts the check and Trust this inventory explicitly approves one returned scope/revision.Baseline approval requires environment/header/bearer declarations to use
fromEnv. Referenced values and ambient environment are not process attestation. A stale second probe or concurrent source/store change refuses acceptance. Otherwise-valid non-sensitive literals remain manageable and probeable. Every nonempty resolved reference value is treated conservatively as confidential: an identity substring match can refuse static/live/draft checks even when accidental. Changing only the reference syntax does not resolve a matching value; remove the overlap from identity-bearing material.Threat model and limits
This is a point-in-time advertised-contract check. It cannot detect malicious implementation behind an unchanged contract, attest executable bytes, block individual calls or quarantine a native client's runtime. Unsigned local state does not authenticate a deliberate edit by an attacker with write access. Optional externally anchored signing is the second slice of this series.
Descriptor audits are review signals, not proof of safety. Known configured credential echoes are refused before trust fingerprints; arbitrary unconfigured secrets remain outside that guarantee. Full snapshots may contain sensitive text and remain private local state. See the security note.
Prior art
Independently authored native Go, informed primarily by RugSnare (Apache-2.0) and conceptual requirements from Tirith (AGPL-3.0). No source, translated code, fixtures or golden vectors from either project are copied into this contribution. The native hash profile preserves numeric lexemes and all array order; no PIN-SPEC/RFC 8785 interoperability is claimed.
Verification
Current candidate:
47646362cfebcb4073a631b47341bb57871ed5d1, rebased onto upstreammainatb97206e9465c78d4afe674f782a3326cab8b3ace. Current-head upstream CI is green, and Codex found no new issues; roborev-ci is still pending.This rework fixes the three open Codex threads. Source review also fixed case-insensitive HTTP media-type handling, symlink-target binding for stdio working directories, and client-selection fields spuriously staling connection identity; it removed a rendered copy-only dashboard test and corrected private tool-pin state descriptions in all existing translated file maps. The test-quality review consolidated duplicate coverage, repaired invalid fixtures, and narrowed CLI integration to explicit revision approval and persistence.
One focused MCP test command passed on interim commit
4b2de1ba, before the later test consolidations and the MIME/symlink fixes:go test ./internal/mcp -run 'TestCaptureContractRejectsNumericCredentialLexemes|TestToolBaselineRejectsNumericCredentialsInCurrentAndStoredSnapshots|TestNumericConnectionCredentialRejectedBeforeProbeAndFingerprint|TestLiveStrictToolsSkipsDisabledProjectEntry|TestCheckProjectScopePreservesControlsAndRedactsCredentials' -count=1No tests or builds ran after that interim check; current-head Go, UI and website checks remain for upstream CI.
Earlier CI and source reviews applied to candidate
3d01ea05658cf3242e6d8690fc8a5c258740f50fon based58bc0dd4d5d0a90a3ec41674f975510a0ac2ba6; those results do not validate this rebased head. That candidate's Nix/check run42631392063and test run42631392217passed, with Docker online and redteam-signal skipped.Not run locally: full Go suites,
make check, UI tests/typecheck/lint/build, browser QA, website build, runbooks, E2E or Windows tests. The single allowed focused MCP test above was run once. No local Docker or PostgreSQL checks were performed.Hegel remains in a separate test-only module; CI requests
hegel.dev/go/hegel@latest. It adds no production runtime dependency.Checklist
make check) — authored, execution pending