Skip to content

fix(pods): stop leaking other users' private DMs into admin sidebars - #375

Merged
samxu01 merged 1 commit into
mainfrom
fix/pod-visibility-admin-leak
May 15, 2026
Merged

samxu01 merged 1 commit into
mainfrom
fix/pod-visibility-admin-leak

Conversation

@samxu01

@samxu01 samxu01 commented May 15, 2026

Copy link
Copy Markdown
Contributor

Summary

  • GET /api/pods and GET /api/pods/:type no longer bypass membership filter for admins on the default sidebar listing
  • GET /api/pods/:id now returns 404 for personal pod types (agent-room / agent-dm / agent-admin) when caller is not a member
  • ?scope=all becomes an explicit admin-only opt-in for moderation tooling; non-admins silently downgrade to scope=mine

Why

Reproduced as xcjsam (global admin) on app-dev: sidebar showed 82 pods, including sam-demo's 1:1 agent-rooms with Nova/Pixel/Cody. Clicking any of them looked like "Talk to" was navigating into a stranger's DM. Post fails with Not authorized to post in this pod (correct), so the user experience was "I clicked Talk-to and now I can't chat." The real bug was upstream: the pod listing should never have surfaced other users' personal DMs.

POST /api/agents/runtime/room itself was correct — it creates a fresh (agentUser, caller) room and the message route correctly gates posting on membership. The leak was purely in the read side.

Test plan

  • backend/__tests__/unit/controllers/podController.test.js — 17/17 passing (4 new cases: admin filter on default scope, scope=all admin pass-through, scope=all non-admin downgrade, getPodById 404)
  • After deploy: verify with xcjsam token that GET /api/pods returns only xcjsam's pods (not 82), and that GET /api/pods/<sam-demo's agent-room id> returns 404
  • Verify "Talk to" still creates a fresh room and navigates correctly (it already did; just confirm the sidebar no longer surfaces the wrong destination)

`getAllPods` and `getPodsByType` were bypassing the membership filter
for global admins. The intent was a moderation view; the effect was
that admins (e.g. the xcjsam dev account) saw every agent-room and
agent-dm in the instance in their default sidebar — including
1:1 DMs other users had with their installed agents. Clicking one
of those rows looked like "Talk to" was navigating to a stranger's
DM, and posting failed with "Not authorized to post in this pod"
because the pod-message route correctly checks membership.

Three changes:

1. `getAllPods`: default `scope=mine` now filters to caller membership
   for everyone, admins included. `?scope=all` is a separate admin-
   only opt-in for moderation tooling; non-admins are silently
   downgraded to `scope=mine`.

2. `getPodsByType`: personal pod types (agent-room, agent-dm,
   agent-admin) are always filtered to caller membership — the
   instance-wide audit is a separate admin tool, not this generic
   listing.

3. `getPodById`: add a membership gate for personal pod types and
   404 non-members. The route previously returned the full pod
   payload to anyone authenticated, which leaked existence and
   membership of every private DM by direct ID lookup.

Unit tests rewritten to encode the corrected invariant + cover the
new `scope=all` admin path and the `getPodById` 404 case.
@samxu01
samxu01 merged commit 7d0ac2d into main May 15, 2026
8 of 9 checks passed
lilyshen0722 added a commit that referenced this pull request May 15, 2026
Adds a new bullet under Agent Runtime — Quick Rules covering the
membership-by-default gate on the sidebar / listing / direct-ID
surfaces (admins do NOT bypass; ?scope=all is the admin opt-in)
and the canViewPod gate that pod-scoped read endpoints must call
before returning content.

Mirrors the pod-manager skill update in commonly-skills@e2ae064.
samxu01 added a commit that referenced this pull request May 16, 2026
PR #375 made getPodById 404 non-members of all personal pod types to
prevent admins accidentally landing in other users' DMs via the sidebar.
That broke V2 inspector's a2a DM navigation — the /v2/pods/<id> layout
404'd even though canViewPod (used by /api/messages, /api/posts, etc.)
allows §3.7 fan-out viewers.

Carve-out:
- agent-dm: defers to canViewPod (admins + §3.7 fan-out)
- agent-room: strict membership (1:1 user↔agent)
- agent-admin: strict membership (ops surface)

Frontend already renders an isReadOnly banner in place of the composer
for non-member viewers. 20/20 podController tests pass (3 new).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
samxu01 pushed a commit that referenced this pull request Sep 8, 2026
…es canViewPod

sprint-review 66454/66455 on #1640: ARTIFACT_SELECT is exported and the
test asserts the real Mongoose query carries no `data` — bytes never
leave Mongo for a listing. A ?podId= outside membership now consults
DMService.canViewPod (members + admins + agent-dm fan-out), the rule the
old Files pane used, so the cutover is not more restrictive on a named
content read; the listing surface stays membership-only (PR #375).

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JavWvyVL478UfEhJjcfMgX
lilyshen0722 added a commit that referenced this pull request Sep 8, 2026
…ommonly_list_artifacts — PR 5 of Direction C (#1640)

* feat(artifacts): GET /api/artifacts + commonly_list_artifacts — kernel half of PR 5

Direction C PR 5 (Sharpen 66366, amended 66376). There is no separate
'published page' record: agents attach through the same upload path, so a
page is a File row whose contentType is text/html, and `kind` is derived
(image/* → image, text/html → page, else doc; markdown stays a doc).

- services/artifactService: one query over a caller-supplied pod scope;
  podId fixed = the inspector's Files pane, absent = the Artifacts page;
  kind / q (originalName only) / limit 1..100 / (createdAt, _id) cursor.
- routes/artifacts: dualAuth, the shape reactions use — a human's scope is
  pod membership (no admin bypass on the default surface), an agent's is
  its active installation set from agentRuntimeAuth. Fixed podId outside
  the scope → 403; unknown kind → 400.
- @commonlyai/mcp 0.3.10: commonly_list_artifacts with the same params
  (29 tools).

Tests: service (kind, cursor, limit, name filter, scoped paging on a
memory Mongo), route (both scope resolvers, 403/400/401), MCP 60/60.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JavWvyVL478UfEhJjcfMgX

* feat(artifacts): Artifacts page, inspector Files pane, rail entry — shell half of PR 5

Built to ScaleArtifacts.dc.html on the one query from the kernel half:

- /v2/artifacts: display head + muted meta; kind segments (All / Images /
  Docs / Pages) and pod segments (All pods / first two / more ▾) on the
  Activity segment grammar; a bordered search that debounces into the
  URL; a table — ext chip (the file's own extension, bordered mono, never
  a colour square), name, kind, short pod name, shared by, when, size (a
  page shows none) — newest first; foot `N of total · newest first` with
  `N more` cobalt text paging by cursor; a click opens the file through a
  signed URL. Filters travel through the URL so ?podId= from the inspector
  and a shared link both land on the same read.
- Inspector Files pane: `files in <pod>` — the same query with podId
  fixed and limit 5, ext chip + name + when per row, `All N files` as
  cobalt text into /v2/artifacts?podId=.
- Rail: Artifacts after Activity; en + zh-CN strings; CJK tracking reset
  covers the new title.

Tests: V2ArtifactsPage (helpers, board render, URL-borne filters,
podId from URL, cursor paging + signed open, two empty states),
V2Inspector (files pane rows and links, no-files copy), invariants
(head, segment grammar, ext chip, mono numbers, phone block, pane).

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JavWvyVL478UfEhJjcfMgX

* fix(artifacts): pin the metadata-only projection; a named-pod read uses canViewPod

sprint-review 66454/66455 on #1640: ARTIFACT_SELECT is exported and the
test asserts the real Mongoose query carries no `data` — bytes never
leave Mongo for a listing. A ?podId= outside membership now consults
DMService.canViewPod (members + admins + agent-dm fan-out), the rule the
old Files pane used, so the cutover is not more restrictive on a named
content read; the listing surface stays membership-only (PR #375).

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JavWvyVL478UfEhJjcfMgX

* fix(artifacts): the four UX misses and the overrule; the agent boundary is pinned

ux-lead 66462 at aa32d0f: (1) the ext chip sits on the mono floor, 11px,
in the table and the inspector pane; (2) at ≤760 there is no sideways
scroll — file / kind / when stay, the pod folds under the name as a mono
line, pod / shared-by / size hide; (3) the head stays display 32 at every
width; (4) the table spans the content area, no centred 1040 cap. The
overrule: an image row opens the chat lightbox, pages and docs open in a
new tab, and an inspector file row opens the file the same way rather
than running a name search.

sprint-review 66465/66466: the agent branch of the named-pod read is
pinned — an agent token with a podId outside its installations is 403
even where membership would grant, and a malformed podId is 403 rather
than a CastError 500.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JavWvyVL478UfEhJjcfMgX

* fix(activity): the reply editor's Send grows in height only at ≤760

sprint-review 66493/66498 at d4d6929: the descendant rule gave Send a
100% flex basis inside the reply editor (489px Send beside a 139px
textarea at 700). The card-action stack is a child rule again; the nested
Send takes min-height 44 alone. Invariant pins both and rejects the
descendant width rule.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JavWvyVL478UfEhJjcfMgX

---------

Co-authored-by: Claude Fable 5.1 <[email protected]>

This branch was previously deployed

1 inactive deployment
dev — 7d0ac2db Deployed May 15, 2026 by samxu01 via Build + push + helm upgrade #184
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