Skip to content

[SECURITY] Honor strict MCP audit failure modes in tool responses #826

Closed

Description

@jeffreyaven

Constituent of #769. Reviewed current main at 1de4135 on 2026-10-08; this issue proposes work, no implementation is included.

CWEs: CWE-778.

Finding and evidence

The documented strict/strict_mutations audit contract says failed audit writes become client-visible errors (pkg/mcp_server/README.md). In pkg/mcp_server/gate.go, recordAudit discards the error after handleAuditFailure logs it; finalizeAudit unconditionally returns nil.

An in-memory MCP test registered the real tool wrapper with a sink whose Record returns probe audit failure, ran a mutation in full_access with failure_mode=strict, and received a successful tool result. The sink was called once and its failure was printed only to stderr.

Required outcome

  • Propagate sink failures according to the documented strict, strict_mutations and best_effort contracts.
  • Preserve the fact that execution may already have succeeded. Return an explicit audit failure that does not encourage blindly retrying a potentially completed mutation.
  • Decide separately whether a pre-execution audit-health gate is needed; do not imply the existing post-execution write can roll back a cloud mutation.

Validation and acceptance

Test real tool middleware with a deterministic failing sink: strict fails reads and writes, strict_mutations surfaces mutation/lifecycle failures while reads continue, and best_effort continues. Include a black-box injectable I/O-failure scenario with a mock mutation counter to prove exactly one execution and clear failure reporting.

Scope and related work

This additional finding arose while validating #769. It is distinct from secret redaction and SQL permission policy; the defect is an advertised audit guarantee that is not enforced.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions