doas icon indicating copy to clipboard operation
doas copied to clipboard

password is read from stdin, not TTY

Open dw opened this issue 6 years ago • 7 comments
trafficstars

repro: echo foo | doas cat

This breaks piping something to a command via doas, and breaks tools (dw/mitogen) expecting it to behave like the BSD version

dw avatar Mar 10 '19 21:03 dw

I've tested this and it works as expected on FreeBSD.

On Linux it was echoing the password when a pipe was used, which is obviously not good. I've fixed that.

On Linux piped data is not being forwarded to the command run by doas, it is intercepted by doas. Will look into that further.

slicer69 avatar Mar 10 '19 22:03 slicer69

Is there any progress about this, as mentioned above?

linuxergr avatar Sep 11 '20 08:09 linuxergr

No, and there probably won't be until someone submits a patch for Linux compatibility that doesn't break other platforms.

slicer69 avatar Sep 11 '20 11:09 slicer69

it doesn't seem like this does any tty or pty handling at all?

This is the basic stuff needed for securely reading the password AFAIK: https://github.com/sudo-project/sudo/blob/9e111eae57524ca72002ad1db36eb68ccd50b167/src/tgetpass.c#L110-L284

I don't think that is linux specific.

sandsmark avatar Feb 06 '21 12:02 sandsmark

This is Linux specific, the other platforms just handle this, basically automatically.

slicer69 avatar Feb 06 '21 12:02 slicer69

Quoting my suggested solution from https://github.com/Duncaen/OpenDoas/issues/21

It turns out i found a pretty good workaround for this by using expect for automatically entering input on interactive prompts, i ended up with something like this:

#!/usr/bin/expect
spawn doas -- pacman --noconfirm -U yay-bin-10.2.3-1-x86_64.pkg.tar.zst
expect "Password: " {send -- "password\r"}
expect eof

Hope it helps someone :)

henriquehbr avatar Jun 04 '21 13:06 henriquehbr

This is not a strictly problem in doas. This is a difference between the basic default "glass TTY" conversation functions supplied by LinuxPAM on Linux, by OpenPAM on the BSDs, and by doas itself.

It wouldn't be hard to adapt the Illumos pam_tty_conv() to Linux, and make it better for Illumos as a side-effect. But that would only fix this problem for "doas" and not fix it for everything else that uses LinuxPAM and hits the same problem for the same reason.

There's no bug filed about this at the LinuxPAM bug tracker directly nor at the Debian bug tracker nor at the Ubuntu bug tracker. The LinuxPAM bug tracker is definitely the place for you to go with this, @dw. (-:

jdebp avatar May 18 '23 15:05 jdebp