feat(security): read pasted API keys with terminal echo off - #31
Merged
Conversation
Hide echo for `anyr login --paste` and the device-login fallback prompt so live keys do not land in terminal scrollback. Non-TTY stdin still delegates to the existing prompt (pipes and tests unchanged). Windows keeps visible input (pre-existing limitation; no new deps). Manual check: run `anyr login --paste` and confirm keystrokes do not render. Echo-off restore-on-error is in the unix termios path. Closes #21 Co-authored-by: duyet <duyet@users.noreply.github.com>
Contributor
anyr size and startupStartup is wall time for a cold Size budget:
Budget check: ok raw timings[
{
"asset": "anyr-darwin-arm64",
"kind": "native",
"path": "/Users/runner/work/cli/cli/anyr-darwin-arm64",
"bytes": 2803592,
"size": "2.7 MiB",
"version": "0.1.11 (built 2026-08-28 05:26:11)",
"target": "aarch64-apple-darwin",
"os": "macos-latest",
"startup_version": {
"n": 21,
"min_ms": 4.88,
"median_ms": 5.54,
"p95_ms": 8.34,
"mean_ms": 6.04
},
"startup_help": {
"n": 21,
"min_ms": 3.91,
"median_ms": 4.54,
"p95_ms": 7.62,
"mean_ms": 5.22
}
},
{
"asset": "anyr-darwin-x86_64",
"kind": "native",
"path": "/Users/runner/work/cli/cli/anyr-darwin-x86_64",
"bytes": 3014760,
"size": "2.9 MiB",
"version": "0.1.11 (built 2026-08-28 05:25:59)",
"target": "x86_64-apple-darwin",
"os": "macos-latest",
"startup_version": {
"n": 21,
"min_ms": 30.59,
"median_ms": 31.68,
"p95_ms": 45.62,
"mean_ms": 33.37
},
"startup_help": {
"n": 21,
"min_ms": 29.23,
"median_ms": 30.46,
"p95_ms": 35.05,
"mean_ms": 31.29
}
},
{
"asset": "anyr-linux-arm64",
"kind": "native",
"path": "/home/runner/work/cli/cli/anyr-linux-arm64",
"bytes": 2757672,
"size": "2.6 MiB",
"version": "0.1.11 (built 2026-08-28 05:25:25)",
"target": "aarch64-unknown-linux-gnu",
"os": "ubuntu-24.04-arm",
"startup_version": {
"n": 21,
"min_ms": 0.64,
"median_ms": 0.68,
"p95_ms": 0.76,
"mean_ms": 0.69
},
"startup_help": {
"n": 21,
"min_ms": 0.68,
"median_ms": 0.73,
"p95_ms": 0.77,
"mean_ms": 0.72
}
},
{
"asset": "anyr-linux-x86_64",
"kind": "native",
"path": "/home/runner/work/cli/cli/anyr-linux-x86_64",
"bytes": 3113512,
"size": "3.0 MiB",
"version": "0.1.11 (built 2026-08-28 05:25:29)",
"target": "x86_64-unknown-linux-gnu",
"os": "ubuntu-latest",
"startup_version": {
"n": 21,
"min_ms": 1.0,
"median_ms": 1.02,
"p95_ms": 1.07,
"mean_ms": 1.03
},
"startup_help": {
"n": 21,
"min_ms": 1.0,
"median_ms": 1.02,
"p95_ms": 1.15,
"mean_ms": 1.04
}
},
{
"asset": "anyr-windows-x86_64.exe",
"kind": "native",
"path": "D:\\a\\cli\\cli\\anyr-windows-x86_64.exe",
"bytes": 2577920,
"size": "2.5 MiB",
"version": "0.1.11 (built 2026-08-28T05:26:55Z)",
"target": "x86_64-pc-windows-msvc",
"os": "windows-latest",
"startup_version": {
"n": 21,
"min_ms": 8.88,
"median_ms": 9.09,
"p95_ms": 9.33,
"mean_ms": 9.13
},
"startup_help": {
"n": 21,
"min_ms": 9.1,
"median_ms": 9.5,
"p95_ms": 10.38,
"mean_ms": 9.54
}
},
{
"asset": "anyr.wasm",
"kind": "wasm",
"path": "/home/runner/work/cli/cli/target/wasm-pkg/anyr_cli_bg.wasm",
"bytes": 179312,
"size": "175.1 KiB",
"version": "wasm",
"target": "wasm32-unknown-unknown",
"os": ""
}
] |
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.
Summary
anyr login --pasteand the device-login fallback prompted for API keys with terminal echo left on, so the live key landed in scrollback. This addsterm::prompt_secret(libc termios on Unix: clearECHO, always restore, newline on stderr after read) and switches the two paste call sites insrc/auth.rs.prompt()unchanged (pipes/tests).confirm()and non-secret prompts (Command path,New account name) are unchanged.Closes #21
Checklist
Manual check for the maintainer: run
anyr login --pasteand confirm keystrokes do not render.