Summary
If I press ctrl-c/ctrl-d when asked for a PIN, the pam_pkcs11 module segfaults.
Details
This issue seems to be caused by
|
cleanse( password, strlen(password) ); |
trying to clear the password buffer when authentication fails. However when you don't enter any PIN at all,
pam_get_pwd
will never initialize the password buffer pointer and as such
cleanse
will try to dereference an uninitialized pointer. On my system this pointer happens to have the value 3 most of the time when running sudo and as such it will segfault.
Locally I'm running version 0.6.12 as packaged with Debian.
This can probably be fixed by adding initializing password to
NULL` at
PoC
$ sudo su
Yubikey found.
Welcome YubiKey PIV Attestation 9a!
Yubikey PIN: ^D
Error 2316: password could not be read
[1] 890566 segmentation fault sudo su
Impact
This could potentially allow privilege escalation given the right circumstances. I presume it will be hard to find the right setuid program and to have the stack initialized in just the right way to allow this though, so realistically there is probably not that much impact other than potentially allowing some daemon that uses PAM to crash.
Summary
If I press ctrl-c/ctrl-d when asked for a PIN, the pam_pkcs11 module segfaults.
Details
This issue seems to be caused by
pam_pkcs11/src/pam_pkcs11/pam_pkcs11.c
Line 797 in bb2e3f3
pam_get_pwd
will never initialize the password buffer pointer and as suchcleanse
will try to dereference an uninitialized pointer. On my system this pointer happens to have the value 3 most of the time when running sudo and as such it will segfault.Locally I'm running version 0.6.12 as packaged with Debian.
This can probably be fixed by adding initializing
password to
NULL` atpam_pkcs11/src/pam_pkcs11/pam_pkcs11.c
Line 211 in bb2e3f3
PoC
Impact
This could potentially allow privilege escalation given the right circumstances. I presume it will be hard to find the right setuid program and to have the stack initialized in just the right way to allow this though, so realistically there is probably not that much impact other than potentially allowing some daemon that uses PAM to crash.