Repository navigation
fix(product): a stored secret's value is read from stdin, never a flag - #99
Conversation
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
5fc9b50 to
0294507
Compare
|
Security priority: current head 0294507 has no returned CI run and the failed review receipt is stale (5fc9b50). Please run generator/spec-drift and shipped CLI tests on current main; prove stdin/hidden terminal input works, secret flags are refused, and secret values never reach argv, errors, traces or logs. Require Cyber qualification under PR_CONVERGENCE.md before merging. |
Symptom: three operations store a sealed value under a field named `value`
and took it as a plain flag, so it landed in shell history and the process
list: `hanzo environment secrets set <repo> <name> --value "$S"`,
`hanzo kms secrets create --name N --value "$S"` and
`hanzo notify credentials provider set <provider> <key> --value "$S"`.
Cause: the generator marks a field `secret: true` (no flag, value read from
stdin or a hidden prompt) by `format: password`, then by the field's NAME
(`is_secret`, src/bin/genproduct.rs). `value` matches no name rule, and the
server's document carries `format: password` on no field, so all three were
generated with `secret: false`.
Fix: `is_secret` also takes the operation's path; a body string field named
`value` on a path with a `secrets` or `credentials` segment is a secret. The
path is passed from `fields_of` through `walk_object` to the one call site;
query fields stay never-secret. generated.rs is regenerated with
`cargo run --features maintainer --bin genproduct --locked` (offline, from
spec/cloud.json): exactly three `secret: false` -> `true`, all `value`.
Also: the hidden prompt now names the full command (product, nodes, verb,
through one helper shared with `flags_not_data`), where it used to say
`hanzo environment set` or `hanzo kms create`; and the empty-input hint no
longer names a kms command.
Known gaps this change does not close (still plain flags): `websearch ... key
replace --key`, `sources accounts create --value` (and the hand-written
`sources accounts add --key`, src/commands/sources.rs:104), `sandbox lease
--bearer`, `connection credential --oauth.access` and `--oauth.refresh`. The
real fix for all of them is `format: password` on the sealed fields in the
server's document, which the generator already honours first.
Testing: tests first, red then green. genproduct: `value` under the
environment, kms and notify paths is secret; under esign fields, as a query
parameter, and a `credentials` route with no `value` field it is not.
Product tests: the three operations each have exactly one secret field,
`value`, and `--value s` is a parse error; the prompt label names the full
command. tests/refresh.rs runs the shipped binary against a stand-in API and
asserts `printf s | hanzo environment secrets set r N` sends
`PUT /v1/environment/r/secrets/N` with body {"value":"s"}. Whole bin suite
(460), tests/refresh.rs, tests/cli.rs, spec_drift
generated_is_exactly_what_the_spec_derives and clippy -D warnings pass.
Risk: `--value` is gone from these three commands, as it already is for the
35 commands (64 fields) that were stdin secrets on main. A script holding
`hanzo environment secrets set <repo> <name> --value "$S"` now fails to
parse; it becomes `printf %s "$S" | hanzo environment secrets set <repo>
<name>`. At a terminal the command asks for the value, hidden.
How to revert: git revert this commit.
… verify secret non-echo on 403
|
Rebased onto
|
0294507 to
6343d06
Compare
What a customer would see
Three operations store a sealed value under a field named
value, and each took it as a plain flag, so the secret ended up in shell history and the process list:hanzo environment secrets set <repo> <name> --value "$S"hanzo kms secrets create --name N --value "$S"hanzo notify credentials provider set <provider> <key> --value "$S"Cause
The generator marks a field
secret: true(no flag; the value is read from stdin, or asked for hidden on a terminal) byformat: passwordfirst, then by the field's name:is_secretinsrc/bin/genproduct.rs.valuematches no name rule, and the server's document carriesformat: passwordon no field. So all three were generated withsecret: false.Fix
is_secret(path, name, schema): a body string field namedvalueon a path with asecretsorcredentialssegment is a secret. The path is passed fromfields_ofthroughwalk_objectto the one call site. Query fields stay never-secret.walk_objectnow has eight arguments, so it carries#[allow(clippy::too_many_arguments)], aslink.rs,network.rsandchannels.rsalready do.generated.rsregenerated withcargo run --features maintainer --bin genproduct --locked(offline, fromspec/cloud.json). The diff is exactly threesecret: falsetotrue, all onvalue:PUT /v1/environment/{repo}/secrets/{name},POST /v1/kms/secrets,PUT /v1/notify/credentials/{provider}/{key}. No other operation changed.hanzo environment set,hanzo kms create). It now reads, for example, "value forhanzo environment secrets set", built from product, nodes and verb by one helper (command_words) thatflags_not_dataalso uses.printf %s "$V" | hanzo <command>) or run the command at a terminal and type it at the prompt".Breaking change
--valueis gone from these three commands, as it already is for the 35 commands (64 fields) that were stdin secrets on main (38 and 67 with this change).hanzo environment secrets set <repo> <name> --value "$S". It now fails to parse.printf %s "$S" | hanzo environment secrets set <repo> <name>.hanzo environment secrets set".Known gaps this change does not close
These fields are still plain flags:
websearch … key replace --key,sources accounts create --value(and the hand-writtensources accounts add --key,src/commands/sources.rs:104),sandbox lease --bearer,connection credential --oauth.accessand--oauth.refresh,dataroom links create --password(its schema states notype, so the only-a-string check atsrc/bin/genproduct.rs:304drops it) andiam providers create/update --client-secret2(the name does not end in "secret"). This list comes from one read of the generated table and may not be complete. The real fix for all of them isformat: passwordon the sealed fields in the server's document; that is the server's to add and the generator already honours it first.Tests (written first)
Red, before the fix:
tests::the_value_stored_at_a_secrets_route_is_a_secret,tests::the_value_of_a_new_kms_secret_is_a_secretFAILEDtests::the_value_of_a_notify_credential_is_a_secretFAILEDcommands::product::tests::the_value_of_a_stored_secret_has_no_flagFAILEDcommands::product::tests::the_prompt_names_the_command_being_runFAILED (left "value forhanzo environment set")iam::secret::tests::the_empty_input_hint_fits_any_commandFAILEDtests/refresh.rs::a_piped_secret_value_reaches_the_request_bodyFAILED against the old generated code (body was{}, wanted{"value":"s"})Guards that stay green:
a_value_elsewhere_is_not_a_secret(esign field),a_query_value_is_never_a_secret,a_credentials_route_without_a_value_field_is_unaffected(/v1/social/credentials).Green, after: genproduct 14 passed; the whole
hanzobin suite 460 passed;tests/refresh.rs2 passed;tests/cli.rs25 passed;spec_drift::generated_is_exactly_what_the_spec_derivesok;cargo clippy --locked --all-targets -- -D warningsclean.The refresh test runs the shipped binary: it pipes
sintohanzo environment secrets set r Nagainst a stand-in API reached throughHTTP_PROXY(a loopback API origin would start a local host) and asserts the API receivedPUT http://api.secret-store.test/v1/environment/r/secrets/Nwith body{"value":"s"}. It reusesHome,jwtandnow;servethere is the IAM and only answers a refresh, so a small recorderrecordis added beside it.Not tested
spec_drift::the_live_server_contradicts_this_command_tree_in_neither_directionfails, and not because of this change:spec/live.jsonis evidence about an older release than.spec-lockpins. No spec file is touched here.cargo fmt --checkalready reports diffs on main in other places; the lines this PR touches are clean.Risk
Scripts passing
--valueto these three commands stop working and must pipe the value. Avaluefield on a futuresecretsorcredentialsroute is treated as a secret (a false positive costs a value typed on stdin; a false negative writes a credential to shell history).How to revert
git revertthe commit; it is one commit andgenerated.rsreverts with it.Built by one agent; an independent review follows. Nothing merged; production is Zach's call.