-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When entering (correct) password, then waiting for timeout, password gets copied on CLI! #545
Comments
This is "typeahead". If you type text at a prompt, but the program that is doing the prompting exits before it receives anything from standard input (and if standard input is in line-buffered mode, then it won't receive any input until you press Return, which you didn't do), then the text you typed remains in some internal buffer and is made available to the next process that tries to read from the terminal - which, in this case, is the shell. Mechanically this is quite similar to what happens if you:
But obviously this is not what you want when the text being entered is a password. Probably the component that is doing the prompting (it's not 100% clear to me whether this is
|
This is a known issue on which I spent some time investigating.
Exactly. The difference between sudo and pkttyagent (where the prompt happens) is that while sudo scans for every character (IIRC), pkttyagent uses PAM stack which asks for the entire stdin line.
The problem is that polkit doesn't own the data until 'enter' is hit and when the timeout happens, pkttyagent is killed abruptly by a signal coming from PAM stack and then it's late. Maybe I could delete the line from a signal handler, but... vv
... the characters are probably in the terminal emulator's buffer! I already tried to flush the STDIN, it doesn't work. While having you all here, please let's discuss the next password-showing-related things somewhere else as mentioned in the README |
Since the issue was already "out in the open" as per https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1093276 I didn't think it would make sense to pretend it was confidential at this point. Do you disagree? |
Yeah, that. If the original reporter had reported this privately to the Debian security team, rather than to the public bug tracker, then I expect it would also have been forwarded upstream privately... but that didn't happen, so the cat is already out of the bag. |
I verified this on Ubuntu. Ubuntu 22.04 (Jammy) is not affected. 24.04, 24.10, and devel are affected. Both Ubuntu 24.04 Desktop and Server are affected. Any text not submitted will be returned--not just a correct password. To test, I started a fresh VM and logged in as the default user in either a virtual console (Ubuntu Desktop) or SSHd in (Ubuntu Server), and ran On Ubuntu, the version of |
I can confirm that 0.105-31+deb11u1 as shipped in Debian oldstable/bullseye does not exhibit this problem. |
The bug report on Ubuntu is https://bugs.launchpad.net/ubuntu/+source/policykit-1/+bug/2095001 To check if this affects a non-Debian based system I setup Fedora Workstation 41 (GNOME) and could not reproduce the issue. This hints that Debian's version of polkit is the source of the issue. My laptop running Ubuntu Server 24.04 and sway is not affected by this. I have polkitd installed, but not policykit-1 (nor gdm/gnome). |
If I'm reading correctly, Ubuntu devel has polkitd (policykit-1) version 126-2, which doesn't apply any Debian/Ubuntu-specific patches any more; if that's the case then it seems unlikely that a Debian-specific patch to polkit is causing this. Could this be a difference in some lower-level component, like perhaps PAM?
If pkttyagent uses PAM for prompting, could this be a behaviour difference between Fedora and Debian/Ubuntu PAM? |
Upstream has contacted me privately (I hope it's ok to reveal that), saying that this is a known issue. EDIT: actually, @jrybar-rh already mentioned that this is a known issue in #545 (comment) |
I just tested a F41 VM and could reproduce the problem there. An interesting observation: |
Forwarded from https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1093276
When, as a normal user, I call a command that requires root privileges on the command line, instead of getting rejected, I'm asked for root/admin password. I think the tool used to do that is polkit. That's why I post here.
When I enter my (correct) password, but then DO NOT validate it by hitting return, then let the login/polkit TIMEOUT trigger, then my actual password get copy-pasted on the command line!!!!
When I use "sudo" directly, there is no timeout, thus it does not happen.
Example:
The text was updated successfully, but these errors were encountered: