Repository navigation
fix: keep sudo-rs passwords out of the command history - #81
Merged
LukeGus merged 2 commits intoNov 16, 2026
Merged
Conversation
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
|
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 |
LukeGus
previously approved these changes
Nov 16, 2026
LukeGus
approved these changes
Nov 16, 2026
2 tasks done
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.
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
pwfeedbackset) by typingabcat the prompt:sudo-rs echoes a
*per typed character and erases it with backspace, space, backspace. The terminal recomputespasswordInputReffrom 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.isAtPasswordPromptnow 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 asls *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 inandroid-ime.test.tsandios-rapid-typing.test.tsand fail the same way on a cleandev-1.4.1.