Repository navigation
shell: process apps inherit an allow-list of the environment, never keys or tokens (G9) [skip ci] - #157
Merged
Conversation
…eys or tokens (G9) [skip ci] scrub_env removed only OCTOS_* and OCTOSENSE_*, so provider keys in the shell's environment (OPENAI_API_KEY, ANTHROPIC_API_KEY, ...) and any other token reached every process app. - scrub_env now clears the child's environment and passes on only inherited_var's allow-list: PATH, HOME, USER, the locale (LANG, LC_*), TERM, the temp dir, TZ, the display (DISPLAY, WAYLAND_DISPLAY, XDG_*, XAUTHORITY, the session bus, the GPU loader variables), Makepad's own (MAKEPAD_*, STUDIO_*), what a `cargo run` launch needs (CARGO_HOME, RUSTUP_*, the target dir, the compilers), and Windows' system variables. What the shell sets on the command itself is kept. - Whatever the list says, a secret-shaped name (OCTOS*, *_API_KEY, *_TOKEN, *_SECRET, *_PASSWORD, *_KEY, AWS_*, ...) is dropped, from inherited and explicit variables alike. - Tests: a real child started with a fake shell environment full of keys and tokens sees none of them (nor their values) and keeps the display, locale and Makepad variables; the list never admits a secret-shaped name. No real key is read or printed. Not kept on purpose: SSH_AUTH_SOCK and other agent sockets (the Terminal's login shell sets its own). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ADR 0004 gap review, G9 (medium-low). Follows #156 (G6).
scrub_envremoved onlyOCTOS_*andOCTOSENSE_*. Provider keys in the shell's environment (OPENAI_API_KEY,ANTHROPIC_API_KEY, ...) and any other token reached every process app.What changed
An allow-list.
scrub_envnow clears the child's environment and passes on onlyinherited_var's list:PATH,HOME,USER,SHELL;LANG,LC_*),TERM, the temp dir,TZ;DISPLAY,WAYLAND_DISPLAY,XDG_*,XAUTHORITY, the session bus, the GPU loader variables;MAKEPAD_*,STUDIO_*);cargo runlaunch needs (CARGO_HOME,RUSTUP_*, the target dir, the compilers);What the shell sets on the command itself is kept.
Secret-shaped names are always dropped. Whatever the list says, a name that looks like a secret is dropped from inherited and explicit variables alike:
OCTOS*,*_API_KEY,*_TOKEN,*_SECRET,*_PASSWORD,*_KEY,AWS_*, ...Not kept on purpose:
SSH_AUTH_SOCKand other agent sockets. The Terminal's login shell sets its own.Tests
a_child_gets_only_the_allow_list_and_never_a_key_or_token: a real child started with a fake shell environment full of keys and tokens sees none of them and none of their values. It keeps the display, locale and Makepad variables. The values are fake; no real key is read or printed.the_allow_list_never_admits_a_secret_shaped_nameLocal checks
These all passed:
cargo checkfor desktop (default andmobile-apps) and for phone (octosense-home --features mobile-apps)cargo test -p octosense-shell --libon desktop and on phoneoctos-core,ws) and ai-host (octos-core,llm) teststools/check-shell-graph.shfor both shellstools/setup.py --check --cargotools/native_apps.py --check🤖 Generated with Claude Code