pam_touchid icon indicating copy to clipboard operation
pam_touchid copied to clipboard

pam_touchid appears to break sudo over SSH

Open modest opened this issue 7 years ago • 8 comments

I haven't fully tested this scenario, but at first pass, it seems like pam_touchid prevents a remote SSH user from using sudo on a Mac with pam_touchid installed. The GUI prompt appears and never gives up without GUI user input.

Are there some possible mitigations here?

  • Checking the tty being used (does PAM expose this?) and immediately falling back to password authentication if the user is coming from a remote terminal
  • or: Adding a timeout so that the Touch ID prompt automatically aborts after 5 seconds, causing a fallback to password authentication.

modest avatar Dec 19 '16 18:12 modest

Interesting, I hadn't thought of that.

Does it work if you add something like:

if (getenv("SSH_TTY"))  
    return PAM_IGNORE;

to the very top of pam_sm_authenticate?

I can't test it at the moment, but hopefully that will make it fallback to the default authentication method when run from ssh (assuming you kept the opendirectory line intact in the ssh pam.d entry)

hamzasood avatar Dec 19 '16 20:12 hamzasood

Just tested it. I can confirm it works.

fraimondo avatar Jan 06 '17 11:01 fraimondo

I think also that XPC_SERVICE_NAME will be set if running a shell locally - but that might depend on if you are using Terminal.app or an alternative. Neither way seem that great as a proxy for detecting if the user is local or not but I can't think of a better way.

cqexbesd avatar Jan 06 '17 22:01 cqexbesd

@cqexbesd what if I have a GUI app that spawns a sudo command? Will I see the XPC_SERVICE_NAME then?

barry-scott avatar Jan 28 '17 18:01 barry-scott

if (getenv("SSH_TTY"))
return PAM_IGNORE;

@hamzasood I can also confirm it works. Why don't you merge it into code?

ITJesse avatar Jun 03 '17 23:06 ITJesse

Looks like this project may be abandoned, sadly... in the meantime, @BenKesselring has a fork with this bug fixed: https://github.com/BenKesselring/pam_touchid/

caesar avatar Aug 22 '17 06:08 caesar

@caesar didn't have a chance to check, did he include if (getenv("SSH_TTY")) return PAM_IGNORE; into his fork/master?

AdnanHodzic avatar Aug 22 '17 06:08 AdnanHodzic

@AdnanHodzic yes. He also opened a PR (#4) to merge that fix into this project but @hamzasood unfortunately never merged it.

caesar avatar Aug 22 '17 06:08 caesar