Skip to content

feat(secrets)!: scoped secret release, no secrets for model commands - #631

Merged
ajianaz merged 1 commit into
developfrom
feat/scoped-secret-release
Nov 12, 2026
Merged

ajianaz merged 1 commit into
developfrom
feat/scoped-secret-release

Conversation

@ajianaz

@ajianaz ajianaz commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

What

#598 part (a), scoped secret release. A new [secrets] config table binds each secret NAME to the tools whose child processes may receive it. BREAKING: run_command, job_start and cron scripts get no secret by default, GITHUB_TOKEN included. The gh and git tools keep the token. A child session gets only its parent's grant, narrowed by a profile.

Why

Owner decision 2026-11-11 (docs/secrets-integrations-design.md §4, §8.3). ENV-1 kept GITHUB_TOKEN in every child process, so any command the model wrote could read it and send it anywhere, including a command steered by a prompt injection.

Changes

  • tole-core/src/secret_release.rs (new): the Release table, mapping each secret name to its consumers.
    • A consumer is a tool name (gh, git, run_command, job_start) or one of tole's own launchers (hook, mcp, cron, uteke, memory, cora, skills).
    • The default binds only GITHUB_TOKEN, to gh, git, hook and mcp.
    • held_grants() returns the secrets this process holds that are bound to some consumer: the most a child may be given.
    • The host sets the release once at startup (set_release); release() returns it, or the default.
  • tole-core/src/subprocess.rs: the hardcoded GITHUB_TOKEN exception is gone.
    • scrub_env_for(cmd, consumer) keeps only what the release grants that consumer.
    • scrub_env_for_child keeps no secret.
    • scrub_env_for_child_keeping keeps exactly the listed names.
    • Every launcher now names its consumer: run_command, job_start, gh, git, hooks, stdio MCP, uteke, memory, the cora search and review gate, the skill index, and cron scripts and delivery commands.
    • RunCommandTool has an optional release override, for tests and embedders.
  • Child sessions:
    • AgentStartTool no longer keeps GITHUB_TOKEN implicitly.
    • A classic agent_start child gets the parent's held_grants().
    • The delegate tool uses its own config's release: with no profile the child gets the parent grant; with a profile, parent grant ∩ profile.grants. A secret the parent's release binds to nothing can never reach a child, even when a profile lists it.
  • tole-cli config: a [secrets] table of NAME = { tools = [...] } entries.
    • Its keys are secret NAMES, so they are exempt from the forbidden-key rule; a secret-like key anywhere else is still forbidden.
    • Validation, with errors naming the remedy and never echoing a key or value:
      • each key must be a secret-shaped environment variable name;
      • each tool must be a name of [a-z0-9_].
    • Project layer, narrow only: a project entry's tools are intersected with the user's binding, or with the default's when the user has none. A tool the project adds is ignored, with a startup warning naming the remedy ("add the tools to NAME under [secrets] in your user config"). config check shows each binding, and project lines carry the narrow-only note.
    • Config::release() turns the table into a release; main.rs sets it for the process.
  • Docs:
    • a CHANGELOG entry under "Behavior change", marked BREAKING;
    • a migration note, docs/secrets-integrations-design.md §9 (what changed, how to restore the old behaviour for one token, why);
    • the threat-model ENV-1 row, the limitation entry and the child-agent paragraph;
    • a README [secrets] section.

Testing

All run locally on b5e40fc (develop 1c5b320), with CARGO_TARGET_DIR set explicitly and CARGO_INCREMENTAL=0.

  • cargo test --workspace --no-fail-fast passes: 1556 passed, 0 failed (84 suites).
  • cargo test -p tole-core --no-default-features passes: 539 passed; cargo check -p tole-core --no-default-features --tests passes.
  • cargo test -p tole-cli --no-default-features passes: 462 passed. With --features shell-tools added: 625 passed.
  • cargo fmt --all -- --check passes.
  • cargo clippy -D warnings passes for --workspace --all-targets, -p tole-core --no-default-features --all-targets, -p tole-cli --no-default-features and -p tole-cli --no-default-features --features shell-tools.
  • cora review --no-llm --staged: "No issues found".

New tests:

  • run_command::tests::a_command_gets_no_secret_unless_one_is_granted_to_run_command: with the process release, printenv GITHUB_TOKEN in a run_command child prints nothing. With a release granting GITHUB_TOKEN to run_command, it prints the token, and another secret stays absent.
  • secret_release::tests:
    • by default, gh, git, hook and mcp get GITHUB_TOKEN, while run_command, job_start, cron and the helpers do not;
    • an entry replaces only its own name's binding;
    • release never narrows redaction: an unbound secret is still redacted.
  • delegate::tests::a_profile_child_… (extended):
    • the parent grant is held ∩ bound;
    • a secret that is the parent's but not the profile's is scrubbed;
    • a secret that is in the profile and held, but bound to nothing, is scrubbed;
    • a child without a profile gets exactly the parent grant.
  • config::tests::secrets_bind_names_to_tools_and_a_project_can_only_narrow_them:
    • parsing, and the release built from it;
    • a project cannot widen (a new tool, or a new secret) but can narrow;
    • the default is the ceiling when the user has no entry;
    • the widening warning names the remedy;
    • bad keys and tools are rejected without echoing them, and other secret-like keys are still forbidden;
    • the config check lines.

Red/green: I broke each rule on purpose, saw the named test fail, then restored it and saw it pass. All 9 breaks were caught:

Broken rule Caught by
GITHUB_TOKEN kept for every child (the old exception) run_command test
run_command ignores the release run_command test
the default grants commands the token run_command test, default-release test
a profile does not narrow the grant profile/child test
the parent grant is not limited to bound secrets profile/child test
a project config can widen config test
no widening warning config test
secret names forbidden as config keys config test, profile/child test
secret names not validated config test

Notes and deviations

  • Project grants narrow only. A project grant cannot restore a token; the remedy is a user-config entry. The design said an explicit grant restores it "per project"; I chose narrow-only because the project file comes from a cloned repository and the task asked that a project never widen. Widening entries are ignored with a warning rather than failing the config, so a project file shared by a team keeps working for members whose user config differs.
  • Hooks and stdio MCP servers keep GITHUB_TOKEN by default. They are configured by the owner, not written by the model, and a GitHub MCP server or hook may rely on the token. Users can narrow this.
  • Helpers lose GITHUB_TOKEN. tole's helper processes (uteke, memory, cora, skill index, review gate) no longer receive it; none of them needs it.
  • In-process tools. A binding to an in-process tool such as web_search is accepted but has no effect yet: release only governs child processes.
  • job_start coverage. job_start uses the same mechanism under the job_start consumer. Its policy is tested; the wiring is a one-line call with no end-to-end test (it is a detached job).
  • Out of scope (part b): .env* and key-file read redaction, and the tole doctor report.

Size: 645 changed lines (575 added, 70 removed) across 26 files.

Related Issues

Part (a) of #598 (secrets epic #594; follows #595 and #585).

Checklist

  • Branch name follows convention (feat/scoped-secret-release)
  • Branch is from develop
  • Commit messages follow Conventional Commits
  • No secrets or credentials committed
  • One logical change per PR

Owner decision 2026-11-11 (#598 part a, design secrets-integrations
§4, §8.3). A new [secrets] table binds each secret NAME to the tools
whose child processes may receive it, e.g.
GITHUB_TOKEN = { tools = ["gh", "git"] }. Every launcher scrubs the
secret-shaped variables (ENV-1) that the release does not bind to it.

BREAKING: run_command, job_start and cron scripts get no secret by
default, GITHUB_TOKEN included. The default keeps GITHUB_TOKEN for the
gh and git tools and the owner's hooks and MCP servers only; a user
config entry restores it for commands. A project config can only
narrow a binding: a widening entry is ignored with a warning naming
the remedy. A child session (agent_start or delegate) gets its
parent's grant, the secrets it holds that its release binds to some
tool, narrowed by a profile's grants, so it never holds a secret its
parent may not use. Redaction is unchanged and covers every secret.

[secrets] keys are secret names, so they are exempt from the
forbidden-key rule; a key that is not a secret-shaped NAME or a tool
entry that is not a tool name is a config error naming the remedy.
Migration note: docs/secrets-integrations-design.md §9.
@github-actions

Copy link
Copy Markdown

🔍 Cora AI Code Review

✅ No issues found. Code looks good!


Review powered by cora-code · BYOK · MIT

@ajianaz
ajianaz merged commit 9f66f13 into develop Nov 12, 2026
19 of 20 checks passed
@ajianaz
ajianaz deleted the feat/scoped-secret-release branch November 20, 2026 08:37
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.

2 participants