Skip to content

fix: a stored secret is write-only, for everybody — keys, tool-server auth, agent secrets, settings (CLEAN-275) - #254

Merged
maksymhryzodub-prog merged 7 commits into
mainfrom
fix/CLEAN-275-secrets-write-only
Nov 30, 2026
Merged

maksymhryzodub-prog merged 7 commits into
mainfrom
fix/CLEAN-275-secrets-write-only

Conversation

@maksymhryzodub-prog

Copy link
Copy Markdown
Contributor

Ticket: CLEAN-275.

What was wrong

Any Admin received stored secrets in plaintext; the Owner did too. Confirmed on production, read-only: the installation's settings hold the hub key, the AWS key pair, an Anthropic API key, a Claude Code OAuth token and a GitHub PAT, and GET /settings returned every value to any Admin. Also returned: every LLM credential's key (the list showed its first and last four characters, the edit form was prefilled with it), every tool-server credential, agent secrets, the env preview (model key, hub key, AWS keys, MCP_SERVERS_B64 with server auth inside), Telegram bot tokens, the last four characters of the notification address, and template install previews echoing a manifest's authValue. The assistant's tools masked catalogued secret settings only, so an uncatalogued key came back in plaintext.

The rule

A stored secret is write-only, for everybody, the Owner included. No route, tool, preview, export, log or error returns a stored secret or any part of it. A response says only whether one is set. CLEAN-271's exception (the assistant's secrets readable by the Owner) is retired.

What changes

  • Read side. apiKeySet, authValueSet, oauthClientIdSet, botTokenSet, { name, set, updatedAt } for agent secrets, { name, value|null, withheld } for the env preview. One presenter per slice on shared helpers in #/setup/writeOnly.
  • Default-deny. A setting's value is returned only for keys the catalogue marks non-secret; anything uncatalogued answers value: null, set. The env preview shows values only for names in AGENT_ENV_SHOWN; MCP_SERVERS_B64 is re-encoded without credentials.
  • Write side. An omitted or empty secret keeps the stored value, a string replaces it, null clears it where clearing is allowed; a required secret cannot be cleared, and a secret setting is cleared with DELETE /settings/:group/:name. No write answer echoes a value.
  • GitHub check moved into the API (POST /settings/github/check, tool check_github_token): the console used to call GitHub from the browser with the PAT it read back.
  • Server-side use is unchanged, proven by the byte-identical pod assembly for the assistant and for an ordinary agent (an empty-key edit leaves the pod identical and still carrying the real key).
  • Settings read through the assistant read live. Found by the leak sweep: list_settings called by a person through the assistant returned the value kept back for the assistant (CLEAN-271). Kept-back values now apply only to work for the assistant itself.
  • Census: writeOnly.census.spec.ts fails when a credential-shaped field is unfiled, a response DTO declares a stored secret, a credential-like setting or pod env name is shown, or a route/tool answers a secret-bearing row without a presenter.
  • Management console: LLM list and edit, tool-server form, Settings (Bridle, GitHub, Storage, Knowledge), agent Secrets tab, Environment panel, channels, notification destination: "Set · replace" / "Not set", empty keeps, typed replaces, Remove where allowed. Fixed on the way: Knowledge credential pickers overflowed at 390 px; the tool-server hint printed ${'$'} literally.
  • Docs: docs/agent-tools.md ("## Secrets" rewritten) and docs/operations/secret-rotation.md: what was readable, how each is rotated, the hub-key order.

Behaviour to know before merging

  • Rotate after deploying: the hub key, the AWS key pair, the GitHub PAT, knowledge and LightRAG keys, anthropic_api_key and claude_code_oauth_token, every LLM key, tool-server credentials, agent secrets including mcpOauth:*, Telegram bot tokens — and JWT_SECRET (CLEAN-281). The hub key must stay equal to the API's BRIDLE_API_KEY env: the Owner sets the setting, then the API env, then every agent restarts. See the runbook.
  • Rows saved before this release keep the old four-character notification hint at rest; nothing returns it.
  • Root version bumped to 0.3.129.

Checked

  • Whole api jest suite: 279 suites, 6285 tests. bun run build clean. test:scripts 245/245. Admin and app npx nuxt typecheck clean; touched console slices green; locale:check, i18n:check clean. Swagger and both SDKs regenerated.
  • Visual check, Playwright, local stack, 390x844 and 1440x900: passed. secrets.mjs 468/468 as the Owner and a limited Admin.
  • Leak sweep (leak-sweep.mjs, adopted here as a regression check): 27/27 — 9 roles over the API, the tools and both consoles; the Owner and the assistant received none of the 13 planted secrets; no role reads the hub key. Only the known CLEAN-175 status-stream ids remain.
  • Ordered e2e set: routes 40, acting 133, http 170, owner-only 80, live-status 11, switch 55, owner-editor 97, ceiling 97, deletion 62, enforce 116, pins 128, ownership 258, assistant-pages 292, badge 262, secrets 468, assistant-built-from 261 — all passed (app-console scripts against this branch's console on port 3002; another session occupied 3000).
  • Not covered locally (no S3, mock workflow provider): the agent Secrets tab, channels and a populated Environment panel in the browser; the API and specs cover them.

Twin consoles

LLM, tool servers and settings are admin-only. The app console shows or prefills no stored secret anywhere; only useRegistrationEnabled.ts changed, to read the typed settings answer.

maksymhryzodub-prog and others added 7 commits November 30, 2026 22:10
No route, tool, preview or error returns a stored secret or any part of it
any more, the Owner included. Answers say apiKeySet / authValueSet /
botTokenSet, a setting's secret + set, an env entry's withheld. One place:
#/setup/writeOnly, with a presenter per slice (llmAsRead, mcpServerAsRead,
agentChannelAsRead, settingAsRead, agentEnvAsRead, manifestAsRead).

- Default-deny: a setting's value only for a key the catalogue files
  secret: false (aws_access_key_id is now secret, uncatalogued keys are
  withheld); an env value only for a name in AGENT_ENV_SHOWN;
  MCP_SERVERS_B64 shown without credentials.
- Writes: an omitted or empty secret keeps the stored value, null clears a
  tool server's credential, a value replaces.
- CLEAN-271's Owner exception (WITHHELD_SECRET) is retired.
- The notification destination's last-four hint is gone.
- Settings read by a person are live, through the assistant or not
  (readingSettingsAsShown); its deploy still reads the approved values.
- The GitHub check runs server-side: POST /settings/github/check and
  check_github_token.
- Provider and probe errors are scrubbed.
- writeOnly.census.spec.ts files every credential-shaped DTO field, setting
  and env name, and fails on a route or tool that answers a secret-bearing
  row without a presenter.

Co-Authored-By: Claude <noreply@anthropic.com>
…LEAN-275)

The LLM list and edit, the tool-server form, the Settings forms (Bridle,
GitHub, Storage, Knowledge), the agent Secrets tab, the Environment panel,
the channels form and the notification destination no longer show, mask,
reveal or prefill a stored secret. A secret field is empty with
"Set · replace" or "Not set"; empty keeps the stored value, a typed value
replaces it, Remove clears what may be cleared. The GitHub check asks the
API. The Secrets tab loses the JSON plaintext view.

App: no screen shows a stored secret; the registration flag reader follows
the typed settings answer. SDKs regenerated in both consoles.

Co-Authored-By: Claude <noreply@anthropic.com>
…in could read (CLEAN-275)

Co-Authored-By: Claude <noreply@anthropic.com>
…N-275)

secrets.mjs: as the Owner and an Admin at 390 and 1440 px, the LLM edit
page, the tool-server form, the Bridle, GitHub, Storage and Knowledge
settings and the notification destination show Set, never a value (DOM,
inputs, HTML, Nuxt payload, every response body); an empty save keeps,
a typed value replaces, Remove clears, proved in the database. The
GitHub check runs server-side. Agent Secrets and channels say "not run"
without an S3 store.

leak-sweep: stored secrets are allowed for nobody, the Owner included
(docs/agent-tools.md "## Secrets"); the CLEAN-275 known entry is gone;
an explicit Owner check; the notification address's last four
characters are a canary of their own; aws_access_key_id is planted; a
short existing setting is no longer overwritten; excerpts never print a
real value next to a canary; the env preview says when it cannot be
reached. Both join all.mjs.

assistant-built-from: the Admin and the Owner both read flags, not keys.

Co-Authored-By: Claude <noreply@anthropic.com>
…t shows ${RANCH_API_TOKEN} (CLEAN-275)

At 390 px the chat and embedding credential selects took the width of
their longest option and ran past the card. The tool-server form printed
${'$'}{RANCH_API_TOKEN} literally: a Vue template does not interpolate ${}.

Co-Authored-By: Claude <noreply@anthropic.com>
…-write-only

# Conflicts:
#	admin/slices/setup/api/data/repositories/api/schemas.gen.ts
#	admin/slices/setup/api/data/repositories/api/types.gen.ts
#	app/slices/setup/api/data/repositories/api/schemas.gen.ts
#	app/slices/setup/api/data/repositories/api/types.gen.ts
@maksymhryzodub-prog
maksymhryzodub-prog merged commit b8048fc into main Nov 30, 2026
1 check passed
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