Skip to content

security(secrets): secrets tole knows by role (webhook keys, serve --token, URL passwords, *_PASS, *_KEY) are neither scrubbed nor redacted #682

Closed

Description

@ajianaz

Found in the #594 security audit. Severity: medium. Status: confirmed (failing test + code reading).

Affected code

  • crates/tole-core/src/secrets.rs:77 is_secret_name: markers API_KEY, APIKEY, SECRET, TOKEN, PASSWORD, PASSWD, CREDENTIAL, PRIVATE_KEY. Both the child scrub (subprocess.rs:90) and SecretSet::collect use only this rule.
  • crates/tole-cli/src/hooks.rs load: hmac_key_env = "GH_HOOK_KEY" (the tests use HOOK_KEY) is accepted for any name; the key (or a hmac_key_file key) is never added to the process SecretSet.
  • crates/tole-cli/src/main.rs:1481: tole serve --token <value> puts the token in argv (visible to every same-uid process via ps//proc/<pid>/cmdline) and it is not added to the set either.
  • crates/tole-cli/src/provider_chain.rs:63 process_secrets: values expanded from ${NAME} in web headers are redacted whatever the name, but the scrub still hands a non-secret-shaped NAME to every child.

Problem

Not secret-shaped today (test output): DB_PASS, PGPASS, DATABASE_URL, REDIS_URL, SENTRY_DSN, NGINJEN_KEY, GH_HOOK_KEY, HOOK_KEY, STRIPE_SK, OPENAI_KEY, NPM_AUTH, SESSION_COOKIE, AUTH_BEARER. These reach run_command/job_start/cron children and are never redacted. The webhook key matters most: with it anyone can sign deliveries and run the route's cron job (with allow_writes, Write tools).

Scenario

[hooks.gh] hmac_key_env = "GH_HOOK_KEY", allow_writes = true. Any approved command (printenv) prints the key, unredacted, into the provider context and the log; an injection exfiltrates it and then forges signed deliveries at will.

Reproduction

Scratch test crates/tole-core/tests/audit_594.rs::common_secret_env_names_are_secret_shaped (lists the names above as not secret-shaped). Code reading for the hook key, --token and header names.

Suggested fix

  • Every secret tole holds by ROLE joins the set and the scrub regardless of its name: hook keys (env and file), the serve token, MCP header expansions, URL userinfo passwords of every configured URL (DATABASE_URL-style values: collect the password part of any env value that parses as scheme://user:pw@). Give the scrub a "known names" list from the same collection, not only the name rule.
  • Extend the markers: _PASS (suffix), PASSPHRASE, _KEY (suffix, with an allowlist of known non-secrets), _DSN, AUTH, COOKIE, SESSION; or refuse hmac_key_env names that are not secret-shaped.
  • Deprecate --token on the command line in favour of TOLE_SERVE_TOKEN / a token file, or at least add it to the set.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions