Skip to content

fix(security): keep NBI's config files out of agent file tools and shell output - #549

Draft
FelipeRamos-neuro wants to merge 4 commits into
plmbr:mainfrom
FelipeRamos-neuro:fix/protect-nbi-config-from-agent
Draft

FelipeRamos-neuro wants to merge 4 commits into
plmbr:mainfrom
FelipeRamos-neuro:fix/protect-nbi-config-from-agent

Conversation

@FelipeRamos-neuro

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

Copy link
Copy Markdown
Contributor

Stacked on #546, #547 and #548. Until they merge, this diff includes their commits; review the last commit only.

Summary

is_protected_nbi_path(path)
  name == nbi.mcp.temp.json            -> protected
  resolved path in protected set       -> protected
  (st_dev, st_ino) in protected set    -> protected   (hard links, case-insensitive names)

read_file / write_to_file / insert_content -> refuse (one fixed message)
search_files                               -> skip
chatbook @-mentions                        -> refuse

redact_env_secrets
  + credentials stored in config.json and mcp.json (placeholders such as `ollama`, `not-needed` excluded)
  • NBIConfig registers its config paths and clears both caches on load and save.
  • The protected set and the stored-credential list are cached for 5 s. A generation counter keeps a save that lands during collection from being cached stale.
  • Shell tools are unchanged: a command can still read or edit the config.

Evidence

  • Before: with a workspace root that contains the NBI config directories, the file tools handle config.json and mcp.json like any file, and redact_env_secrets leaves a stored key without a known prefix.
  • After: the file tools refuse or skip them, including through symlinks and hard links, and the key is redacted. Other files in the same directory are unaffected.
is_protected_nbi_path  209 us -> 22 us per call (cached)
redact_env_secrets     +110 us -> +7 us per line (cached)

pytest tests/ 2563 passed, 4 skipped, jest 959 passed, tsc, ESLint, Prettier and i18n check clean. Reverting any one of the inode check, the mention gate, the generation guard or the Claude-mode scrubbing makes a test fail.

Merge Danger

Door: two-way

Blast Radius: agent file tools and shell output

A workflow that had the agent edit ~/.jupyter/nbi/mcp.json through the file tools stops working. The config API and Settings still edit it.

Closes #545

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
…files

The Claude-mode server list masks every env and headers value. The NBI
MCP editor masks credential-named values in the temp copy it writes to
the workspace and restores them on save; a mask with nothing stored
behind it is refused with a 400.

Closes plmbr#543
run_claude_cli scrubs the env and argv values it was given, then runs
the shared redactor. Claude-mode stream errors, the bail-out message and
the related log lines are redacted too.

Closes plmbr#544
…ell output

The file tools, search_files and Chatbook mentions refuse NBI's own
config files (resolved path and file identity, so links count). Shell
output now also redacts the credentials NBI stores, leaving placeholder
keys alone. The protected-path set and the stored-credential list are
cached and invalidated on config load and save.

Closes plmbr#545

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.

Keep NBI's own config files out of the agent's file tools and shell output

1 participant