set --secret: ask for a typed secret with echo off #3569
All Vouch review confidence checks passed
Residual risk 0.33 = Change Risk (0.75) × (1 − Review Confidence (0.57)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.75 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.289
Sensitive Paths
sensitive_paths
0.075
Real PR Conversation Timeline
1 comments
"Review active on #3569"
general
weight: 0.35
nick-potts
Closes #3414
Root cause
ployz set PATH --secretread stdin to EOF whatever stdin was. At a terminal that meant no prompt, the terminal's echo still on, and a wait until Ctrl-D. The typed secret showed on screen and stayed in scrollback.The hidden prompt that
recoverandserver enrollalready use (ui::secret, which wraps dialoguerPassword) couldn't simply be reused. console'sread_secureturns off only ECHO, andwhile_promptingmakes SIGINT a no-op. So Ctrl-C was swallowed, andread_linerestarted after the EINTR. The prompt couldn't be cancelled, and Ctrl-D asked again. That bug is on main today forrecoverandserver enroll.Fix
set --secret(handlers/config.rs,read_secret):- stdin is a terminal: asks
Value for PATH:throughui::secret.- stdin is a terminal but the run can't prompt (
--json,CI,TERM=dumb, stderr not a terminal): refuses with a usage error that says why and shows how to pipe the value. It never reads with echo on.- stdin is piped: no change. It reads to EOF, strips one trailing newline, keeps the 32 MiB bound, and keeps the same errors and codes.
ui::secret(ui/prompt.rs): it now reads with its ownrustixtermios reader, with no new dependency or feature. The reader turns off ECHO, ICANON, ISIG and IEXTEN.- Keys: Ctrl-C (anywhere, even inside an unfinished paste) and Ctrl-D on an empty line cancel ("Cancelled. …", exit 130). Ctrl-D after some text ends the line, as it did on main. An empty line asks again, as
Passworddid. Backspace (UTF-8 aware), Ctrl-U and Ctrl-W edit the line.- Pastes: bracketed paste (
ESC[?2004h) is on while the prompt reads, so a paste is read to itsESC[201~end marker however slowly it arrives. A paste with anything after a newline is refused. For a terminal that doesn't bracket pastes, after Enter it also reads on, echo still off, until nothing arrives for 200 ms. If anything other than line endings came, the paste held more than one line, and it is refused (exit 2) rather than cut to its first line. The termios restore usesTCSAFLUSH, so no part of the paste reaches the shell.No message on any path contains the value.
Behaviour change
set --secretat a terminal now promptsValue for PATH:with echo off and takes one line. Before, it read the echoed input until Ctrl-D. A value of several lines must be piped, and a multi-line paste at the prompt is refused.set --secretwith a terminal on stdin, in a run that can't prompt (--json,CI,TERM=dumb, stderr redirected), now exits 2 with a message to pipe the value.set --secret,recoverandserver enroll(exit 130). Before, it was ignored.recoverandenrollsilently kept the first line.docs/user/cli/overview.md.Design bets
docs/agents/landing.md).Proof
Manifest checkout sha = PR head
a21bfee1002b3b7f1bcfa4657ee4b9edaf92f150.core/target/debug/ployzwas built from that tree. Each run used a freshPLOYZ_CONFIGlab dir and dummy values, driven on a real pty with pythonpty.fork.| Case | Screen | Exit | Typed value on screen | Echo restored |
| --- | --- | --- | --- | --- |
| typed, with a backspace |
Value for web.env.M4:, then on to staging (no Cloud in the lab) | 1 (no Cloud) | no | yes || Ctrl-C |
Cancelled. Nothing was staged.| 130 | no | yes || Ctrl-D on an empty line |
Cancelled. Nothing was staged.| 130 | no | yes || Ctrl-D after text | line taken, on to staging | 1 (no Cloud) | no | yes |
| empty line, then Ctrl-C | prompt asked again, then cancelled | 130 | no | yes |
| two-line paste, one write | refused: "That paste held more than one line…" | 2 | no | yes |
| paste split by 30 ms | refused; the parent shell then read 0 bytes of the tail | 2 | no | yes |
| paste split by 150 ms | refused; parent read 0 tail bytes | 2 | no | yes |
| 4 KB line, then a second line | refused; parent read 0 tail bytes | 2 | no | yes |
| bracketed paste split by 350 ms | refused; parent read 0 tail bytes; paste mode turned on and back off | 2 | no | yes |
| Ctrl-C 350 ms into an unfinished bracketed paste |
Cancelled. Nothing was staged.| 130 | no | yes || bracketed single line, Enter 350 ms later | line taken, on to staging | 1 (no Cloud) | no | yes |
| piped
printf %s <dummy> \| ployz set …| read as before, on to staging | 1 (no Cloud) | no | n/a |Secret hygiene (coordinator rule for secret-hygiene lanes): every proof uses dummy values only, and no secret value appears in any output.
sed -E 's/dummy-3414[^[:space:]]*/[REDACTED]/g'.Tests (rung 1, crate unit):
ui::prompt::tests::a_hidden_line_ends_at_enter_and_never_keeps_part_of_a_pastecovers line endings, backspace over UTF-8, Ctrl-U, Ctrl-W, Ctrl-C, Ctrl-D, and a paste in one read.handlers::config::tests::a_secret_is_never_read_from_a_terminal_that_cant_hide_it_nor_named_in_an_errorcovers the refusal, a terminal that is never read, the piped trim, and the error codes. The error text leaves out the sentinel.cargo clippy -p ployz --all-targetsis clean.Review
Round 1 was Codex and Opus on the full diff. Both found the swallowed Ctrl-C. Opus also found that a multi-line paste was truncated, and on the second pass that a paste split across reads was truncated and its tail reached the shell. Codex's second pass found the split-paste case too, and that Ctrl-D after text was ignored. All of these are fixed above, with pty proof.
Round 2 was Codex on the full diff at
96e5a94: no BUG-class findings. The Codex GitHub review then found that a multi-line paste pausing for more than 200 ms was still cut short. This is fixed with bracketed paste inac319b2, Round 3 (Codex, diff of that fix) found that Ctrl-C inside an unfinished paste was swallowed; fixed ina21bfee. Round 4 (Codex, diff of that fix): no BUG-class findings, so review stops here.