Skip to content

fix(mcp): fail closed on empty scoped-key tag sets and missing accessType - #1581

Open
Sravanjangam wants to merge 1 commit into
supermemoryai:mainfrom
Sravanjangam:fix/mcp-rbac-fail-closed
Open

fix(mcp): fail closed on empty scoped-key tag sets and missing accessType#1581
Sravanjangam wants to merge 1 commit into
supermemoryai:mainfrom
Sravanjangam:fix/mcp-rbac-fail-closed

Conversation

@Sravanjangam

@Sravanjangam Sravanjangam commented Aug 22, 2026

Copy link
Copy Markdown

Hi supermemory team 👋 Thanks for building such a great product! While running a security & quality audit of the repo we hit this issue and put together a small, tested fix — details below.

Problem

MCP RBAC failed open:

  1. effectiveContainerTagAccess() treated a scoped session whose scoped-tag set resolves empty as unrestricted → every container tag came back "write".
  2. sessionInfoSchema marked accessType optional, so a session missing it skipped the restricted branch entirely and inherited the "write" default.

Net effect: a "scoped, read-only" API key had org-wide write access through MCP. Part of #1578 (finding M4, high severity).

Solution

Default-deny semantics: an empty allowlist allows nothing, and a session that doesn't declare its access type is rejected at parse time rather than silently escalated.

Changes

  • apps/mcp/src/server/auth/rbac.ts → early-return [] when scope.type === "scoped" && scopedTags.size === 0
  • apps/mcp/src/shared/types.tsaccessType now required (with comment explaining why)
  • rbac.test.ts → +2 cases (scoped-empty denies writes; scoped key lists only its tags)
  • shared/types.test.ts (new) → 2 schema cases incl. missing accessType rejected

Verification

Fresh from the committed branch: bunx vitest run src/server/auth src/shared17/17 pass, including pre-existing fixtures proving real sessions always send accessType (no compatibility break observed); tsc adds zero new errors vs baseline; Biome clean.


Happy to iterate on any of this — feedback and reworks very welcome! 🙏

Environment

  • macOS 26.1 (arm64) · bun 1.4.0 · node v26.7.0
  • vitest 3.2.4 (workspace-pinned) · Biome lint clean
  • Branch fix/mcp-rbac-fail-closed — all gates re-run fresh at commit 629ec2e59cb9

…cessType

- rbac: a scoped key whose tag/tag list resolves empty previously
  matched NO restriction clause, so every container tag came back with
  org-wide 'write' — defeating the scoped-key purpose. Empty set now
  denies everything.
- shared/types: require accessType in sessionInfoSchema. An omitted
  value used to skip the restricted branch entirely and inherit the
  'write' default; a schema-missing field now fails session parsing
  (-> 401) instead of failing open. All existing fixtures already send
  it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant