Skip to content

fix(settings): keep stored API keys out of the capabilities response - #546

Open
FelipeRamos-neuro wants to merge 1 commit into
plmbr:mainfrom
FelipeRamos-neuro:fix/mask-api-keys-in-ui
Open

FelipeRamos-neuro wants to merge 1 commit into
plmbr:mainfrom
FelipeRamos-neuro:fix/mask-api-keys-in-ui

Conversation

@FelipeRamos-neuro

@FelipeRamos-neuro FelipeRamos-neuro commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

 GET /capabilities
-  chat_models[].properties[api_key].value   "sk-live-..."
+  chat_models[].properties[api_key].value   "********"   (secret: true)
-  chat_model / inline_completion_model       real key
+  chat_model / inline_completion_model       "********"
-  claude_settings.api_key, acp_settings.api_key   real key
+  claude_settings.api_key, acp_settings.api_key   "********"

 POST /config
+  posted "********"  -> keep the stored value
+  posted ""          -> clear the key
+  posted "sk-new"    -> replace the key
  • New notebook_intelligence/credential_mask.py holds the mask, restore and secret-property helpers.
  • LLMProviderProperty.secret is opt-in for extension providers. api_key is masked by default.
  • Settings key inputs are password fields (autoComplete="new-password"), and focusing one selects the mask so typing replaces it.
  • A mask with nothing stored behind it is never saved.

Evidence

  • Before: a key stored in config.json (typed in Settings or written by hand) is in the capabilities JSON in clear text.
  • After: the same response carries ********. A real NBIConfig entry is covered, not a mock, because a mock hid the stored chat_model leak during development.

Tests:

capabilities(real chat_model, inline_completion_model, claude, acp) -> no stored key in the JSON
POST mask -> stored key unchanged | POST new -> replaced | POST "" -> cleared
POST mask for another model / nothing stored -> dropped, never persisted
password input + select-on-focus (jest)

pytest tests/ 2521 passed, jest 959 passed, tsc --noEmit, ESLint, Prettier and i18n check clean. Reverting the chat_model masking makes a test fail.

Merge Danger

Door: two-way

Settings now shows ******** where it showed the key. Anyone who relied on reading the key back from the capabilities response loses that.

Blast Radius: settings dialog and /capabilities consumers

Follow-up PRs, stacked on this one: #547 (MCP credentials), #548 (error text), #549 (file tools and shell output).

Closes #542

A key stored in config.json was sent to the browser in clear text and
filled a plain input. The capabilities response now carries a mask in
its place (model lists, stored chat_model and inline_completion_model
entries, claude_settings and acp_settings), ConfigHandler maps a posted
mask back to the stored key, and the key inputs are password fields.
LLMProviderProperty gains an opt-in `secret` flag.

Closes plmbr#542

This branch has not been deployed

No deployments
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.

Stored API keys are sent to the browser in clear text

1 participant