Skip to content

Fix read-key export secrets, role 409, KG validation and CLI 0.1.4 issues - #1525

Merged
helpcodeai merged 7 commits into
mainfrom
fix/cli-and-read-key-secrets
Nov 5, 2026
Merged

helpcodeai merged 7 commits into
mainfrom
fix/cli-and-read-key-secrets

Conversation

@helpcodeai

@helpcodeai helpcodeai commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Summary

These problems came up while testing CLI 0.1.2 against Cloud.

Security (backend): a MANAGEMENT_READ key returned every connector secret in clear. GET /api/connectors/export-all and GET /api/connectors/:id/export include secret env vars and headers when the user is ADMIN. A management key inherits its owner's role, so an admin's read-only key received client secrets and passwords in plain text (verified on Cloud, values not printed). GET /api/connectors already masked them. Exports now include secrets only when the caller is ADMIN and is not using a MANAGEMENT_READ key. A dashboard session or a MANAGEMENT_ADMIN key still gets a full backup. I scanned every other parameterless management GET for plain-text secret fields: nothing else leaks.

Backend, found by the end-to-end run below:

  • Creating or renaming a role to an existing name answered 500 (unhandled Prisma P2002 on @@unique([organizationId, name])). It now answers 409 with a clear message.
  • PUT /api/knowledge-graph/settings used an inline body type, so nothing was validated: {"enabled":"yes"} answered 200 and was silently ignored. It now has a class-validator DTO and answers 400. The dashboard sends only the six booleans, so it is unaffected.

CLI 0.1.4:

  • amcp api drops the server's reason on 401/403. A POST with a read key printed "Authentication failed (403)", which reads as a broken key. It now prints Forbidden (403): This API key is read-only, still with exit code 3.
  • amcp api GET … --data '{}' failed with "Could not connect to the MCP server" (exit 4), because fetch refuses a body on GET. It is now refused locally with a clear message (exit 2), and no request is sent.
  • Connection errors from api and management login named "the MCP server". They now name the management API.
  • login --management / --browser erased an MCP login on the same profile, and an MCP login erased the management key. Both are now kept when they point at the same instance.
  • New amcp --version / -v, also added to shell completion.
  • amcp api --list showed [admin] wrongly. Controller-level @Roles('ADMIN') was ignored, so SMTP, alert webhook, SSO and roles routes were not tagged. ADMIN, EDITOR routes were tagged admin-only. The generator now mirrors RolesGuard (getAllAndOverride): 36 routes gain the tag and 11 lose it.
  • MCP login/tools errors said only "Authentication failed (401/403)". They now tell a rejected key (401) from a key not allowed on that server (403, with a hint to pass the server ID the key was created for). The server's message is still never printed.

Deployment modes

  • Cloud and self-hosted behave the same.
  • Behaviour change: a backup made with a read-only key no longer contains secrets. For a restorable backup, use the dashboard or an admin-scope key.

End-to-end run on Cloud (CLI 0.1.2, admin and read keys)

I ran about 190 amcp calls against cloud.anythingmcp.com. They only touched resources created for the test (prefix amcp-cli-test-, all deleted afterwards). Settings were written back with their original values.

  • MCP servers: create, update, code mode, deactivate/activate, activity, duplicate slug (409), assign connectors, delete.
  • Connectors and tools: create, update, env vars, test, tools CRUD, annotations, proxy, tool test with live data, bulk, export JSON/YAML, import (duplicate skipped, renamed copy created), catalogue adapter import, delete.
  • MCP keys and amcp tools: mint, login --key-stdin, tools ls / --filter / describe / call (args, stdin, timeout, destructive guard), revoke (exit 3), delete.
  • Settings: footer links, alert webhook, SMTP (save, test, remove), organization, knowledge graph, File Search policy, memory, profile, onboarding, learning.
  • Roles, knowledge folders, memory items, skills, knowledge graph nodes and edges.

Everything worked except the problems fixed here.

Tests

  • packages/backend: npx jest src/connectors/connectors.controller.spec.ts src/connectors/connectors.export-import.spec.ts src/connectors/connectors.import-all.spec.ts --maxWorkers=4. Result: 181 passed, including new read-key / admin-key export cases. npx jest src/roles src/knowledge-graph/kg.controller.settings.spec.ts src/knowledge-graph/kg.service.spec.ts --maxWorkers=4: 80 passed. npx tsc --noEmit -p tsconfig.json passes. eslint on the changed files is clean.
  • packages/cli: npm test. Result: 23 passed, 2 skipped (fish is not installed), 0 failed. New cases cover the 403 reason, GET with --data, profile merge, MCP 401 vs 403, and --version.
  • node scripts/generate-cli-operations.mjs --check: up to date. npx tsc --noEmit passes.
  • node scripts/generate-llms-txt.mjs --check passes.

- export-all and :id/export no longer include secret env vars and headers
  for a MANAGEMENT_READ key, even when its owner is an admin.
- amcp api keeps the server reason on 401/403 (e.g. read-only key) and
  names the management API, not the MCP server, in connection errors.
- amcp api refuses --data with GET/HEAD instead of failing as a
  connection error.
- A management login keeps an MCP login on the same profile and
  instance, and vice versa.
- Add amcp --version; bump the CLI to 0.1.3.
…min tags

- Creating or renaming a role to an existing name answered 500 (Prisma
  P2002); it now answers 409.
- PUT /api/knowledge-graph/settings validates its body with a DTO: a
  non-boolean was silently ignored with 200.
- The CLI catalogue honours controller-level @roles('ADMIN') (SMTP,
  alert webhook, SSO, roles) and no longer tags ADMIN+EDITOR routes as
  admin-only, matching RolesGuard.
- MCP errors tell a rejected key (401) from a key not allowed on the
  server (403) and hint at the server ID.
@helpcodeai helpcodeai changed the title Mask export secrets for read-only keys; fix CLI api errors and profiles Fix read-key export secrets, role 409, KG validation and CLI 0.1.3 issues Nov 5, 2026
Refuse an export without an organization (Prisma treats an undefined
filter as no filter, which on Cloud would read every tenant) and look
up :id/export by id and organizationId, answering 404 for another
workspace's connector.
@helpcodeai
helpcodeai enabled auto-merge (squash) November 5, 2026 08:47
@helpcodeai helpcodeai changed the title Fix read-key export secrets, role 409, KG validation and CLI 0.1.3 issues Fix read-key export secrets, role 409, KG validation and CLI 0.1.4 issues Nov 5, 2026
@helpcodeai
helpcodeai merged commit 06dc766 into main Nov 5, 2026
14 checks passed
@helpcodeai
helpcodeai deleted the fix/cli-and-read-key-secrets branch November 5, 2026 10:18
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 5, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant