Skip to content

bug(mcp): the other never-throw tools still audit a returned failure as a success #4248

Open

Description

@AndriiPasternak31

Problem

The MCP audit wrapper (src/mcp-server/src/audit.ts::withAudit) labels a tool call by throw / no-throw, plus an out-of-band outcome stamp. #4026 (PR #4246) added the non-denial stamp, audit.ts::toolFailed (kind failed). It moved apply_system and teardown_system onto it, and only those two.

Every other "never throws" tool still RETURNS its failures as {success: false, …} envelopes with no stamp. Each of those calls is audited success: true, so an operator reading mcp_operation rows cannot tell a refused or failed call from a successful one.

Evidence (dev @ aa12f15)

  • At least 32 single-line return JSON.stringify({ success: false, … }) sites with no stamp, in 16 modules under src/mcp-server/src/tools/. The largest groups: events.ts (5), memory.ts (4), reminders.ts, loops.ts and decisions.ts (3 each), and aauth.ts, a2a.ts and notifications.ts (2 each).
  • Single sites: a2a_call.ts:172, credential_vault.ts:185, agents.ts, metrics.ts, nevermined.ts, pipelines.ts, reports.ts, voip.ts.
  • Further unstamped envelopes are built across several lines, so the count above misses them. Examples are in operator_queue.ts, channels.ts, messages.ts, metrics.ts and skill_sources.ts.

What must be true

  • Every returned failure on the MCP tool surface is audited success: false.
  • An authorization refusal carries denied: true (access.ts::accessDenied). Any other failure carries no denied key (toolFailed).
  • Deciding which branches are denials is per tool, and is the substance of this work. A 403 or a not_permitted / not_authorized / human_only flag is a denial. A retryable outage, a validation error or an unavailable feature is not. Getting one wrong corrupts a security signal.
  • The caller-facing JSON of every tool is byte-identical. The stamp is out-of-band.
  • A guard makes the next tool unable to forget. audit-denial.test.ts already fails a deny branch that bypasses accessDenied; a returned success: false envelope that bypasses both helpers should fail the same way.

Context

  • Patterns: src/mcp-server/src/tools/systems.apply.test.ts reads each audit row through the registered tool, and audit-denial.test.ts holds the helper's unit tests and the mechanism guard.
  • Splitting the work into one PR per module group is fine.

Activity

  1. added
    priority-p3
    type-bug
    theme-security
    complexity-medium
    on Nov 4, 2026
  2. added
    status-ready
    on Nov 18, 2026
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

    complexity-mediumpriority-p3status-readytheme-securitytype-bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions