Information
The visiblepw sudo option controls whether sudo will prompt for a password on a terminal that cannot disable local echo. When not enabled (the default), sudo refuses to run rather than prompt for a password that would be displayed as it is typed.
If visiblepw is enabled, sudo prompts for a password even when the terminal cannot suppress echo (for example, a command run over SSH without a pseudo-terminal). The password is then entered in cleartext where it can be observed, captured in a screen or session recording, or written to logs. Leaving visiblepw disabled ensures a password is only requested when it can be entered without being displayed.
Solution
Ensure sudo will not prompt for a password on a terminal where it would be displayed. Edit the appropriate sudoers file with visudo and remove any line that enables visiblepw, or explicitly disable it:
# visudo
Add or correct the line:
Defaults !visiblepw
Impact:
Automated or non-interactive workflows that invoke sudo without a pseudo-terminal will fail with a password-prompt error rather than exposing the password. Allocate a pseudo-terminal (for example, ssh -t ) for such workflows, or use an appropriate documented exception.