Skip to content

fix: keep sudo-rs passwords out of the command history - #81

Merged
LukeGus merged 2 commits into
Termix-SSH:dev-1.4.1from
ZacharyZcR:fix/sudo-rs-password-history
Nov 16, 2026
Merged

LukeGus merged 2 commits into
Termix-SSH:dev-1.4.1from
ZacharyZcR:fix/sudo-rs-password-history

Conversation

@ZacharyZcR

Copy link
Copy Markdown
Member

Fixes #68: with sudo-rs, the password typed at the sudo prompt is saved to the command history and offered in autocomplete.

Captured on Ubuntu 26.04.1 (sudo-rs 0.2.13-0ubuntu1.2, no pwfeedback set) by typing abc at the prompt:

[sudo: authenticate] Password: ***^H ^H^H ^H^H ^H^M

sudo-rs echoes a * per typed character and erases it with backspace, space, backspace. The terminal recomputes passwordInputRef from the last line of recent output on every chunk (isAtPasswordPrompt). After the first keystroke that line is [sudo: authenticate] Password: *. It no longer ends in the colon, so the flag turned false, and the command tracker recorded the keystrokes and Enter as a command. The prompt text itself was already matched. Classic sudo is unaffected because it echoes nothing.

isAtPasswordPrompt now reads the last line as it is shown before matching: it applies backspaces and drops a trailing run of * feedback. The prompt text still has to match, so a command line such as ls * is not taken for a prompt. Broadcast and password fill read the same flag, so they also keep treating the line as a password prompt while typing.

Validation: new tests use the captured sequence. They cover the flag staying true while typing and after erasing, false once the password is sent, true again on sudo-rs's retry prompt, and ls * at a shell prompt staying false. The first two fail before the change. Typecheck, build, manifest validation and prettier pass. In the full suite, 705 pass. The 3 failures are in android-ime.test.ts and ios-rapid-typing.test.ts and fail the same way on a clean dev-1.4.1.

sudo-rs, the default sudo on Ubuntu 26.04, echoes a * for each typed
character and erases it with backspaces. The prompt line then ends in
"Password: ***" instead of the colon, so the terminal stopped treating
itself as at a password prompt with the first keystroke, and the typed
password was saved to the command history and offered in autocomplete.

The last line is read as shown, applying backspaces and dropping trailing
feedback asterisks, before matching the prompt.

Fixes Termix-SSH#68
@termix-triage-bot

termix-triage-bot Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

AI review | Looks safe to merge

The PR fixes a bug where sudo-rs password feedback characters break prompt detection, preventing passwords from leaking into command history. The change is localized, safe, and well-tested with no issues found.

Reviewed 2584018. AI can be wrong, a maintainer still decides. Comment /termix review to run it again.

LukeGus
LukeGus previously approved these changes Nov 16, 2026
@LukeGus
LukeGus merged commit 30354f1 into Termix-SSH:dev-1.4.1 Nov 16, 2026
4 checks passed
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