Skip to content

fix(product): a stored secret's value is read from stdin, never a flag - #99

Merged
zeekay merged 2 commits into
mainfrom
job/secret-values
Nov 27, 2026
Merged

zeekay merged 2 commits into
mainfrom
job/secret-values

Conversation

@jamessburnss1313-dev

@jamessburnss1313-dev jamessburnss1313-dev commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

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) by format: password first, then by the field's name: is_secret in 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(path, name, schema): 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. walk_object now has eight arguments, so it carries #[allow(clippy::too_many_arguments)], as link.rs, network.rs and channels.rs already do.
  • generated.rs regenerated with cargo run --features maintainer --bin genproduct --locked (offline, from spec/cloud.json). The diff is exactly three secret: false to true, all on value: PUT /v1/environment/{repo}/secrets/{name}, POST /v1/kms/secrets, PUT /v1/notify/credentials/{provider}/{key}. No other operation changed.
  • The hidden prompt named the wrong command (hanzo environment set, hanzo kms create). It now reads, for example, "value for hanzo environment secrets set", built from product, nodes and verb by one helper (command_words) that flags_not_data also uses.
  • The empty-input hint no longer names a kms command: "no value on stdin — pipe it in (printf %s "$V" | hanzo <command>) or run the command at a terminal and type it at the prompt".

Breaking change

--value is 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).

  • Old call that scripts hold: hanzo environment secrets set <repo> <name> --value "$S". It now fails to parse.
  • Replacement: printf %s "$S" | hanzo environment secrets set <repo> <name>.
  • At a terminal the command now asks for the value at a hidden prompt, "value for 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-written sources accounts add --key, src/commands/sources.rs:104), sandbox lease --bearer, connection credential --oauth.access and --oauth.refresh, dataroom links create --password (its schema states no type, so the only-a-string check at src/bin/genproduct.rs:304 drops it) and iam 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 is format: password on 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_secret FAILED
  • tests::the_value_of_a_notify_credential_is_a_secret FAILED
  • commands::product::tests::the_value_of_a_stored_secret_has_no_flag FAILED
  • commands::product::tests::the_prompt_names_the_command_being_run FAILED (left "value for hanzo environment set")
  • iam::secret::tests::the_empty_input_hint_fits_any_command FAILED
  • tests/refresh.rs::a_piped_secret_value_reaches_the_request_body FAILED 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 hanzo bin suite 460 passed; tests/refresh.rs 2 passed; tests/cli.rs 25 passed; spec_drift::generated_is_exactly_what_the_spec_derives ok; cargo clippy --locked --all-targets -- -D warnings clean.

The refresh test runs the shipped binary: it pipes s into hanzo environment secrets set r N against a stand-in API reached through HTTP_PROXY (a loopback API origin would start a local host) and asserts the API received PUT http://api.secret-store.test/v1/environment/r/secrets/N with body {"value":"s"}. It reuses Home, jwt and now; serve there is the IAM and only answers a refresh, so a small recorder record is added beside it.

Not tested

  • A real call against the live API.
  • The hidden prompt on a real terminal (the label is tested, the tty prompt is not).
  • spec_drift::the_live_server_contradicts_this_command_tree_in_neither_direction fails, and not because of this change: spec/live.json is evidence about an older release than .spec-lock pins. No spec file is touched here.
  • cargo fmt --check already reports diffs on main in other places; the lines this PR touches are clean.

Risk

Scripts passing --value to these three commands stop working and must pipe the value. A value field on a future secrets or credentials route 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 revert the commit; it is one commit and generated.rs reverts with it.

Built by one agent; an independent review follows. Nothing merged; production is Zach's call.

@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-26T02:41:58.917785Z
We couldn’t complete this review. Comment @codex review to try again.
5fc9b50 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

zeekay commented Nov 27, 2026

Copy link
Copy Markdown
Member

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.

jamessburnss1313-dev and others added 2 commits November 26, 2026 19:38
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.
@zeekay

zeekay commented Nov 27, 2026

Copy link
Copy Markdown
Member

Rebased onto main (f44110dc) and verified security & spec gates at 6343d061:

  • Verified genproduct (14/14), spec_drift::generated_is_exactly_what_the_spec_derives (1/1), product::* (57/57, including the_value_of_a_stored_secret_has_no_flag, a_terminal_is_prompted_and_never_read_as_a_pipe, a_stdin_secret_can_never_reach_argv, the_prompt_names_the_command_being_run), iam::secret::tests (5/5), and shipped-binary tests/refresh.rs (2/2, including non-echo of piped secret on 403 error responses).
  • Modularized genproduct.rs, product/mod.rs, and product/tests*.rs so every hand-authored file stays <= 1,000 LOC.
  • cargo clippy --locked --all-targets -- -D warnings: 0 warnings.

@zeekay
zeekay merged commit 8028ad7 into main Nov 27, 2026
@zeekay
zeekay deleted the job/secret-values branch November 27, 2026 03:50
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