Skip to content

feat(security): read pasted API keys with terminal echo off - #31

Merged
duyetbot merged 1 commit into
mainfrom
cursor/006-secret-prompt-noecho-4f55
Aug 28, 2026
Merged

feat(security): read pasted API keys with terminal echo off#31
duyetbot merged 1 commit into
mainfrom
cursor/006-secret-prompt-noecho-4f55

Conversation

@duyet

@duyet duyet commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Summary

anyr login --paste and the device-login fallback prompted for API keys with terminal echo left on, so the live key landed in scrollback. This adds term::prompt_secret (libc termios on Unix: clear ECHO, always restore, newline on stderr after read) and switches the two paste call sites in src/auth.rs.

  • Non-TTY stdin still uses prompt() unchanged (pipes/tests).
  • Windows keeps visible input (pre-existing limitation; no new deps).
  • confirm() and non-secret prompts (Command path, New account name) are unchanged.

Closes #21

Checklist

  • Version stays on 0.1.x (do not introduce 0.2 / 1.0)
  • Do not auto-merge release-please PRs

Manual check for the maintainer: run anyr login --paste and confirm keystrokes do not render.

Open in Web Open in Cursor 

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>
@duyet
duyet marked this pull request as ready for review August 28, 2026 05:26
@duyetbot
duyetbot merged commit d6359c8 into main Aug 28, 2026
7 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

anyr size and startup

Startup is wall time for a cold anyr --version / anyr --help (median of 21 runs). Size is the stripped release binary, or the .wasm for the browser demo.

Size budget: anyr-linux-x86_64 must stay ≤ 4.0 MiB (4194304 bytes) stripped.

Asset Kind Size --version median --help median
anyr-darwin-arm64 native 2.7 MiB 5.54 ms 4.54 ms
anyr-darwin-x86_64 native 2.9 MiB 31.68 ms 30.46 ms
anyr-linux-arm64 native 2.6 MiB 0.68 ms 0.73 ms
anyr-linux-x86_64 native 3.0 MiB 1.02 ms 1.02 ms
anyr-windows-x86_64.exe native 2.5 MiB 9.09 ms 9.5 ms
anyr.wasm wasm 175.1 KiB

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": ""
  }
]

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.

Plan 006: Disable terminal echo when prompting for API keys

3 participants