Repository navigation
plugins/auth/pam: don't echo terminal input during the PAM fail delay - #568
Merged
Merged
Conversation
After tgetpass() reads the password it restores the terminal to its original state, which re-enables echo. When authentication fails, the PAM stack typically sleeps for a short time (the fail delay applied by pam_unix) before pam_authenticate() returns. Any input the user typed during that delay, such as re-entering the password before the next prompt, was echoed to the terminal in the clear. Disable terminal echo in the PAM conversation function once the password has been read and restore it after pam_authenticate() returns, with a safety net in sudo_pam_cleanup() to also cover the pam_chauthtok() and pam_acct_mgmt() paths. Fixes GitHub issue sudo-project#530
millert
approved these changes
Oct 17, 2026
millert
left a comment
Collaborator
There was a problem hiding this comment.
This looks like a reasonable approach and I appreciate that you used sudo_term_* instead of using tcsetattr() directly. There's always going to be a small window where a character could be echoed between tgetpass() returning disabling echo again but this is probably the best we can do.
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.
After tgetpass() reads the password it restores the terminal to its original state, which re-enables echo. When authentication fails, the PAM stack typically sleeps for a short time (the fail delay applied by pam_unix) before pam_authenticate() returns. Any input the user typed during that delay, such as re-entering the password before the next prompt, was echoed to the terminal in the clear.
Disable terminal echo in the PAM conversation function once the password has been read and restore it after pam_authenticate() returns, with a safety net in sudo_pam_cleanup() to also cover the pam_chauthtok() and pam_acct_mgmt() paths.
Fixes GitHub issue #530