An attacker can stand up a keylogger using native Linux tools to log for your sudo password. That's why a Yubikey configured as sudo 2FA is an essential defense.
I will let Anthropic's Claude explain it:
==============================================================================================================================
The premise to discard first is that capturing the sudo password requires running a foreign binary. It does not. The dominant vector requires no new executable at all.
1. Shell-level sudo wrapping (the decisive vector). An attacker who can write to the account's shell startup files (~/.bashrc, ~/.bash_profile, ~/.profile, or the equivalent for zsh) can define a shell function or alias named sudo. When you next type sudo, your own shell runs that function instead of the real binary. The function prints a prompt indistinguishable from the genuine one, reads your password into a variable, records it, then transparently calls the real /usr/bin/sudo so nothing looks wrong. No file is executed that fapolicyd could inspect — a shell function is interpreted entirely inside a bash process that must, by definition, be allowed to run for you to have a usable session. Your custom interpreter-deny rules do not touch this, because there is no script file and no exec of anything in a writable path; it is bash reading its own builtins. A PATH-hijack variant using a script named sudo earlier in $PATH could in principle be caught by interpreter-deny rules if they block script execution from writable directories, but the function and alias variants have no such file and cannot be caught that way. This is why a password-only sudo is fundamentally phishable by any code running as your user, and it is the single strongest argument for a hardware second factor.
===============================================================================================================================
So, the wrapped sudo will capture the password and then the attacker can use it whenever he wants.
In other words, if you don't have a fingerprint reader that can be configured to use for sudo, then you should go buy a $27 Yubikey hardware token. Safeguards your Linux, and can be used for Google Advanced Protection of your gmail accounts, and can be used as phish proof 2FA for many web sites.
I cannot supply the PAM modifications required to setup sudo and login because they vary by platform, especially if you don't use Ubuntu which is this thread's focus.(and I know many readers don't ) Go ask your chatgpt. There will be 3-4 PAM files in /etc/pam.d/ to modify: sudo, console-login, graphical-authentication and graphical-login. And you will need to use a console logged in session on the side (ctrl-alt-functionkey) just in case you make a wrong modification and lock yourself out.