Repository navigation
fix(security): secrets held by name, value or role join the redaction set and the child scrub, serve token from a file - #690
Merged
Conversation
…y-role # Conflicts: # CHANGELOG.md # docs/threat-model.md
🔍 Cora AI Code Review✅ No issues found. Code looks good! Review powered by cora-code · BYOK · MIT |
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.
What
Every secret tole holds, whether by name, by value or by role, now joins both the redaction set and the child-environment scrub (ENV-1).
tole servecan also read its bearer token from a file, so the token does not have to sit in the process arguments.Why
#682 (audit of #594): the scrub and the redactor recognised a secret only by its variable NAME (
API_KEY,SECRET,TOKEN,PASSWORD, ...). As a result:DB_PASS,PGPASS,DATABASE_URL,REDIS_URL=redis://:pw@...,SENTRY_DSN,OPENAI_KEY,STRIPE_SK,NPM_AUTHandSESSION_COOKIEreachedrun_command,job_startand cron children and were never redacted.hmac_key_env = "GH_HOOK_KEY"(or read fromhmac_key_file) was neither scrubbed nor redacted. With that key, anyone can sign deliveries.tole serve --token <value>left the token readable in/proc/<pid>/cmdlineand outside the secret set.${NAME}web header expansions were redacted, butNAMEstill reached every child.Changes
secrets::is_secret_name, shared by the scrub and the redactor):PASSPHRASEanywhere in the name.PASS,_KEY,_DSN,_SK,_COOKIE,_AUTH,_BEARERandDATABASE_URL.AUTH_andBEARER_.SSH_AUTH_SOCK(thegittool needs it),GPG_KEY(official language images export a key fingerprint under that name), names endingPUBLIC_KEY,PUB_KEYorPUBKEY, and names endingBYPASS.GIT_AUTHOR_*,XDG_SESSION_TYPE,DBUS_SESSION_BUS_ADDRESS,MONKEY,KEYBOARD,PWD,REDIS_URL,TOLE_BASE_URL.secrets::is_secret_var, used by the scrub):SecretSet::collectnow collects that password, so it is redacted too.SecretSet::holds).*_PROXY, any case) are exempt from removal for their URL password, because every network command behind an authenticated proxy needs them. Their password is still redacted.secrets::add_role_secret/role_secretsrecord a value under a label and install it in the process set.hooks::hold_keysrecords every webhook route key ashooks.<route>.tole serveandtole hook testcall it.serve_tokenrecords the serve token.provider_chain::process_secretsfolds role secrets into each session's set.SecretSet::from_envnow includes the${NAME}header expansions, so the process set knows them before any session exists.TOLE_BASE_URL,OPENAI_BASE_URLandTOLE_FALLBACK_BASE_URL, which the scrub now removes when they carry a password (child_env::PROVIDER_SECRETS).[secrets]keys may also be*_URL/*_URInames, so a connection string scrubbed for its value can be granted back.tole serve --token-file <path>:--token.--token <value>still works, with a warning namingTOLE_SERVE_TOKENand--token-file.secrets-integrations-design.md§9.--token-fileentry.Decisions to check
AUTHOR,SESSIONandKEYBOARDstay ordinary. I did not addSESSIONas a marker: it is too broad (XDG_SESSION_TYPE).REDIS_URLand other*_URLnames are secrets by value (when they carry a password), not by name.DATABASE_URLis a secret by name, as you asked.HTTPS_PROXYkeeps reaching children, and its password is redacted. Removing it would breakcargo,gitandcurlbehind such a proxy, with no grant to restore it unless the name is[A-Z0-9_].--tokenis warned, not removed. Removing it would break existing service units. Residual:tole approvals --token(a client) keeps the argument form;TOLE_SERVE_TOKENworks there.[secrets]. The key validation accepts secret-shaped names and*_URL/*_URInames. Such a variable is bound to tole's own web backend, which reads it in-process.DB_PASS,DATABASE_URL,OPENAI_KEYor a password-bearing*_URLnow needs a[secrets]grant.Testing
secrets::tests::the_name_rule_covers_the_pass_key_dsn_and_auth_families: the audit's name list (less the*_URLnames, which are covered by value), and a list of ordinary names that must stay ordinary.secrets::tests::a_variable_is_a_secret_by_its_value: a URL password under any name, a value held by role, the proxy exemption, and the collected password redacted.crates/tole-core/tests/secrets_by_role.rs(its own process, real environment): a webhook-style role secret under an odd name,REDIS_URLwith a password,DB_PASSand a${HDR_SETTING}header expansion are all absent from a scrubbedrun_commandchild'sprintenv. An ordinary variable and the proxy setting stay. All of them are redacted from text under their names.hooks::tests::hold_keys_makes_every_route_key_a_process_secret: a key from a variable with an innocent name is redacted as«hooks.gh»and known to the scrub.serve::tests::the_serve_token_prefers_the_file_and_never_echoes_a_value: precedence, the empty and missing file, no token in errors, and the token redacted as«TOLE_SERVE_TOKEN».crates/tole-cli/tests/serve_token.rs(real binary):--token-file, the server accepts the file's token (200) and refuses another (401), and/proc/<pid>/cmdlinedoes not contain the token.--tokenprints the warning.--tokentogether with--token-fileis refused.secrets_by_role("child env holds" the role value).hold_keysfails the hooks test.cargo fmt --all --check,cargo clippy --workspace --all-targets --all-features -- -D warnings,cargo test --workspace,cargo test -p tole-core --no-default-features, the no-mcp CI profile, andcora review --no-llm --base origin/develop(no issues).Closes #682