Skip to content

plugins/auth/pam: don't echo terminal input during the PAM fail delay - #568

Merged
millert merged 1 commit into
sudo-project:mainfrom
ElenaFri:main
Oct 17, 2026
Merged

millert merged 1 commit into
sudo-project:mainfrom
ElenaFri:main

Conversation

@ElenaFri

Copy link
Copy Markdown
Contributor

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

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 millert left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@millert
millert merged commit 1622f52 into sudo-project:main Oct 17, 2026
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