Skip to content

reveal_secret_headers unmasks upstream credentials for NON-admin callers on the REST and SSE doors (MCP requires an authenticated admin, these don't) #1167

Closed

Description

@Dumbris

Summary

The opt-in reveal_secret_headers flag is ANDed with caller identity on the MCP door but checked alone on the REST and SSE doors. With the flag on, an agent token — or in the server edition any tenant who mints one — is handed raw upstream credentials on surfaces the MCP door would mask for the same caller.

The asymmetry

MCP (internal/server/mcp.go:3775-3776) requires both:

revealHeaders := p.config != nil && p.config.RevealSecretHeaders &&
    auth.AuthContextFromContext(ctx).CanRevealSecrets()

CanRevealSecrets() (internal/auth/context.go:151) is IsAdmin() && !Anonymous — deliberately stricter than IsAdmin, and nil-safe so an absent context is unprivileged rather than admin-by-absence.

These sites check the flag only:

  • internal/httpapi/server.go:1619 — redactServerSecrets, backing GET /api/v1/servers
  • internal/httpapi/server.go:4247 — the doctor/diagnostics route
  • internal/httpapi/diagnostics_per_server.go:88 — per-server diagnostics
  • internal/runtime/event_bus.go:335 — the /events SSE servers.changed payload
  • internal/management/diagnostics.go:71
  • internal/upstream/manager.go:1705

Repro

With "reveal_secret_headers": true in config, present an agent token (mcp_agt_ prefix, no admin role) to GET /api/v1/servers. Every upstream's headers and env come back in the clear. The same token calling MCP upstream_servers list gets masked values.

Notes for whoever fixes it

The SSE case is genuinely different: event_bus.go builds one payload and broadcasts it, so there is no per-caller context to AND against. That door probably has to stay masked unconditionally, or gate what a subscription is allowed to receive — a raw broadcast cannot be correct for a mixed-privilege audience, which is the shape the server edition creates.

internal/upstream/manager.go:1705 is an internal/logging consumer; worth checking whether it is on a caller-facing path at all before changing it.

Severity

Off by default, so this is a hardening gap rather than a default-on leak — but the flag exists precisely so an operator can see their own credentials, and it currently reveals them to every caller instead. In the server edition that is a cross-tenant disclosure of admin credentials.

Found during the #1161 residual sweep (#1165); out of scope there because it spans six sites across three packages and needs a decision about SSE.

Activity

  1. Dumbris commented on Sep 2, 2026

    @Dumbris
    MemberAuthor

    Fixed in #1182 (merged 2026-09-02). GitHub only auto-closed the first reference in that PR's "Closes" line, so closing manually.

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

    kind/bugSomething isn't workingkind/securitySecurity fix or hardening

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions