feat(agent): warn about credential-looking variables inherited from the shell by radim10 · Pull Request #80 · stashbase/cli · GitHub
Skip to content

feat(agent): warn about credential-looking variables inherited from the shell - #80

Merged
radim10 merged 4 commits into
masterfrom
feat/inherited-env-check
Oct 20, 2026
Merged

radim10 merged 4 commits into
masterfrom
feat/inherited-env-check

Conversation

@radim10

@radim10 radim10 commented Oct 20, 2026

Copy link
Copy Markdown
Member

Native agent runs pass the caller's whole shell environment to the agent (only STASHBASE_API_KEY and binding source names are removed), so an exported token like GITHUB_TOKEN reaches the agent as a real value and skips the placeholder model.

Changes

  • agent run (native, local and --remote): prints one line with how many credential-looking variables the agent inherits. Hidden by --silent. Docker runs are skipped, since the container starts from a clean environment.
  • agent validate: a new "Inherited env" check lists those variables by name (never values).
  • [config_env]: an empty value is no longer flagged as sensitive, so NAME = "" blanks an inherited variable without a confirmation prompt.
  • Docs: "Inherited Shell Variables" in agent-profiles.md; per-backend environment notes in sandboxing.md.

No new profile config.

Detection

Best-effort, reusing the [config_env] rules minus the high-entropy check (too noisy over a whole shell env): sensitive name parts, known token prefixes, URLs with passwords. Skips path values, sandbox-owned names, and names a binding or [config_env] provides.

Testing

  • cargo test: all passing (new unit tests for detection, empty values and the validate check).
  • Manual native runs on macOS: warning line, validate list, and FAKE_API_TOKEN = "" reaching the agent as empty under --silent with no TTY.

…he shell

Native agent runs pass the caller's environment to the agent, so an
exported token reaches it as a real value. agent run now prints how many
credential-looking variables the agent inherits, and agent validate
lists them by name. Docker runs start from a clean environment and skip
the check.

An empty [config_env] value is no longer flagged as sensitive, so
NAME = "" blanks an inherited variable.
Only STASHBASE_API_KEY is removed from a native agent's environment, so
other STASHBASE_* names reach the agent and must be checked.
Unix environment names are case-sensitive, so a binding or config_env
entry named github_token leaves an inherited GITHUB_TOKEN in place. The
check now skips only the exact names the launcher removes or sets.
Guards the behavior the inherited-env check relies on when it skips
names [config_env] sets.
@radim10 radim10 self-assigned this Oct 20, 2026
@radim10
radim10 merged commit f217cc3 into master Oct 20, 2026
0 of 3 checks 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