Unlocking saved passwords after fingerprint login on Linux
Contents
The first time my Ubuntu lock screen opened with a fingerprint, I thought the project was finished. Five seconds later, a popup asked for my account password anyway so NetworkManager could read my saved Wi-Fi credentials.
That dialog wasn't a bug in elanprintd or the ELAN sensor. Every fingerprint reader on Linux hits the same wall with GNOME Keyring, including models libfprint has supported for years, because a fingerprint scan gives Linux no password to decrypt your stored secrets.
To unlock the keyring without saving my account password on disk, I sealed a random 32-byte secret inside my laptop's TPM 2.0 chip and wrote a small Rust PAM module that hands it over at login. If the TPM ever fails, hangs, or vanishes, the module steps aside so it can never lock me out.
Why a fingerprint cannot open GNOME Keyring
Right after that first fingerprint unlock, I checked the system journal with journalctl. gkr-pam, GNOME Keyring's PAM helper, printed the exact reason:
gdm-fingerprint: gkr-pam: no password is available for user
gdm-fingerprint: pam_unix(gdm-fingerprint:session): session opened for user
gdm-fingerprint: gkr-pam: couldn't unlock the login keyringLogin succeeded and my session opened, but the keyring stayed locked.
On a normal password login, typing your password does double duty. GNOME Keyring encrypts your saved Wi-Fi keys, browser secrets, and online accounts inside ~/.local/share/keyrings/login.keyring using that password. When you sign in, pam_unix.so verifies what you typed and stores a copy in an in-memory PAM slot called PAM_AUTHTOK (item 6 in _pam_types.h). A few lines lower in the PAM stack, pam_gnome_keyring.so reads that slot and unlocks the keyring silently.
A fingerprint scan has no password to put there. My ELAN sensor only sends back 40 00 ("slot 0 matched"), so pam_fprintd.so approves your session and leaves PAM_AUTHTOK empty. When pam_gnome_keyring.so runs next, it finds nothing to decrypt with, and GNOME asks you for your password once the desktop loads.
swipe sideways to see the whole diagram
Windows Hello and Apple Touch ID don't turn your finger into a password either. Both use a hardware security chip (a TPM on Windows, the Secure Enclave on a Mac) as a safe: your fingerprint only tells the chip to unwrap a stored key. Ubuntu's /etc/pam.d/gdm-fingerprint already runs pam_gnome_keyring.so right after pam_fprintd.so, so all Linux needed was one small module in between to fill PAM_AUTHTOK.
Sealing a random key in the TPM
Most modern laptops have a TPM 2.0 chip soldered onto the motherboard. Rather than sealing my real Ubuntu password inside it, I added an opt-in command (elanprint-keyring enable, also available under the Keyring tab of the desktop app) that generates a fresh random secret, seals it with systemd-creds, and re-keys login.keyring to match.
Because your account password is never sealed or written anywhere, extracting that secret would at worst expose the keyring, never your Ubuntu login or sudo password.
swipe sideways to see the whole diagram
Setup enforces a strict order so a broken TPM can never trap your secrets:
- Generate 32 random bytes from
/dev/urandom, hex-encoded into 64 ASCII characters so the secret can never hold aNULbyte or newline. - Seal those bytes to the motherboard TPM via
systemd-creds encrypt --with-key=tpm2 --tpm2-pcrs=, saving the ciphertext to/var/lib/elanprint-rs/keyring.cred(mode 0600, owned by root). - Test-decrypt the blob immediately before touching any PAM file or keyring. If the TPM cannot unseal what it just sealed, setup aborts without touching a single system file.
- Save the recovery key, back up and update
/etc/pam.d/gdm-fingerprint, and make you type back that recovery key to prove you recorded it. - Re-key the login keyring over GNOME's Secret Service D-Bus interface only after confirmation succeeds.
That leaves /etc/pam.d/gdm-fingerprint looking like this:
auth required pam_fprintd.so
auth optional pam_elanprint_keyring.so
auth optional pam_gnome_keyring.soNotice the empty --tpm2-pcrs= flag. On systemd 255.4, systemd-creds encrypt binds sealed secrets by default to PCR 7, a TPM register measuring Secure Boot state. Imagine leaving that default on: everything works today, then next month Ubuntu pushes a routine Secure Boot dbx revocation update through fwupd, PCR 7 changes, and your laptop locks itself out of its own keyring.
Nor does PCR 7 stop someone holding the machine, because an off-the-shelf Microsoft-signed live USB produces the same PCR 7 value anyway. Passing --tpm2-pcrs= empty keeps updates from breaking unlock while still tying decryption to this motherboard's TPM, so pulling the SSD leaves the sealed blob unreadable on any other computer.
swipe sideways to see the whole diagram
At login, pam_elanprint_keyring calls systemd-creds to unseal the key into PAM_AUTHTOK right before pam_gnome_keyring.so runs:
swipe sideways to see the whole diagram
Writing a Rust PAM module that cannot lock you out
Unlike elanprintd, a PAM module doesn't run safely in its own background service. GDM loads pam_elanprint_keyring.so as a C shared library directly inside gdm-session-worker. If that shared library hangs or crashes, your login screen freezes or aborts.
Marking a module
optionalin PAM only ignores non-zero return codes. It won't save you if a child process hangs forever or a Rust panic unwinds across C.
swipe sideways to see the whole diagram
Four guardrails in crates/pam-elanprint-keyring/src/lib.rs ensure the module fails open on every error:
- Every path returns
PAM_IGNORE(25).pam_sm_authenticatenever casts a pass or fail vote on login (pam_sm_setcredreturnsPAM_SUCCESSas PAM requires). If the TPM breaks or the credential file is missing, login still depends strictly onpam_fprintd.soorpam_unix.so. - Catch panics before C sees them. Unwinding a Rust panic across FFI into libpam is undefined behavior and can crash
gdm-session-worker. Keeping Rust's defaultpanic = "unwind"letspam_sm_authenticatetrap any panic insidestd::panic::catch_unwind, log to syslog, and returnPAM_IGNORE. - Enforce a hard 2-second subprocess timeout. When the module spawns
systemd-creds decrypt, two reader threads drain stdout and stderr (capped at 4 KiB each) so a noisy subprocess cannot fill a pipe buffer and stall. If decryption runs past two seconds, the module kills the child and moves on. - Zeroize the secret right after handoff. Linux-PAM copies
PAM_AUTHTOKinternally with_pam_strdup, so as soon aspam_set_itemreturns, the plugin scrubs its temporaryCStringbuffer usingzeroize.
#[no_mangle]
pub unsafe extern "C" fn pam_sm_authenticate(
pamh: *mut c_void,
_flags: c_int,
_argc: c_int,
_argv: *const *const c_char,
) -> c_int {
match catch_unwind(AssertUnwindSafe(|| supply_authtok(pamh))) {
Ok(rc) => rc,
Err(_) => {
log("panicked, keyring left locked");
PAM_IGNORE
}
}
}One easy edge case to miss: what happens tomorrow when you type your account password at the login screen instead of using a finger? Because the login keyring is now encrypted with the 64-character TPM secret instead of your Ubuntu password, pam_unix.so writes the wrong secret into PAM_AUTHTOK and leaves your keyring locked. By default, setup adds pam_elanprint_keyring.so to /etc/pam.d/gdm-password too, overwriting PAM_AUTHTOK with the TPM secret so password logins still unlock your keyring silently. If you'd rather enter the recovery key by hand on password logins, pass --fingerprint-only during setup.
Checking journalctl across three test boots proved the whole chain end to end:
without the module gkr-pam: no password is available for user
gkr-pam: couldn't unlock the login keyring
wired, before the re-key gkr-pam: stashed password to try later in open session
gkr-pam: the password for the login keyring was invalid
after the re-key gkr-pam: stashed password to try later in open session
gkr-pam: unlocked login keyringThat middle boot mattered most. Seeing the password for the login keyring was invalid proved the PAM module had handed a key down to gkr-pam before I re-keyed login.keyring. On the third boot, the keyring opened cleanly and the password prompt stayed gone.
Security trade-off
Keyring auto-unlock ships turned off by default because enabling it widens what a fingerprint scan opens. Once enabled, a matching finger unlocks both your desktop session and every secret stored inside login.keyring.
Inexpensive match-on-chip sensors don't have strong liveness detection, and only the keyring named login auto-unlocks. Any high-value secrets you don't want released by a fingerprint belong in a second password-protected keyring created in Ubuntu's Passwords and Keys app.
Back up your recovery key and clean up the plaintext file. Setup writes the key to /root/keyring-key.txt (mode 0600) so nobody loses access on day one. On a machine without full-disk encryption, anyone who can read the raw disk can read that file, so copy the recovery key somewhere safe and run elanprint-keyring forget-recovery-file. If you ever clear your TPM or move your SSD to another laptop, login still works normally, and GNOME simply prompts for that recovery key to open login.keyring.
What I still don't know
Everything in these three posts comes from one laptop, one sensor running firmware 1.8 on Ubuntu 24.04.4 (GNOME 46, fprintd 1.94.3), and daily use on Ubuntu 26.04.1:
- Other
04f3:0c90units or firmware revisions might drop the arming rule or return 70-bytefinger_inforecords. deletehasn't run under the current daemon code, andwipe_all(40 ff 99) has never run on hardware. Uninstalling leaves templates in flash;--wipe-devicerelies on that untestedwipe_allopcode.- Nothing on the chip reports how many touches enrollment expects. Eight works here (libfprint uses nine on sibling ELAN chips), and you can override it with
ELANPRINT_ENROLL_STAGES. - I don't know the total slot count, and the 0c4c commit sub-ID formula overflows its low nibble from slot 11 upward.
- Greeter login relies on GDM's
/etc/pam.d/gdm-fingerprint. Desktops like KDE, Cinnamon, and XFCE don't ship that file, and KDE'skwallethas the same keyring gap unaddressed here. - One sensor cannot measure a false-accept rate or spoof resistance, so I make no claims about either.
- The TPM seal hasn't been tested across a laptop BIOS or firmware update yet.
Trying it on your own laptop
If you have an 04f3:0c90 sensor on Ubuntu 24.04 or newer (64-bit Intel or AMD), you can install the .deb release from github.com/prawesh-12/elanprint-rs:
lsusb -d 04f3:0c90 # one line back means you have this exact sensor
curl -fsSLO https://github.com/prawesh-12/elanprint-rs/releases/latest/download/elanprint-rs_amd64.deb
sudo apt install ./elanprint-rs_amd64.debVerify that elanprintd is running and owns net.reactivated.Fprint:
systemctl is-active elanprintd
busctl --system status net.reactivated.FprintOpen the elanprint-rs app, enroll a finger, then lock your screen and touch the sensor. Once fingerprint login works, opt into keyring unlock with elanprint-keyring enable (or the app's Keyring tab), back up your recovery key, and remove the plaintext copy with elanprint-keyring forget-recovery-file. To uninstall cleanly later, run sudo apt remove elanprint-rs.

If you test this on firmware other than 1.8, please open an issue at github.com/prawesh-12/elanprint-rs/issues with your lsusb output and the firmware version logged by elanprintd. Next up for the repo: wiring the included polkit policy file instead of raw UID checks, confirming stage counts, and testing on other units.
What I learned
I gave up in 2023 because I jumped straight into C kernel tutorials and tried to swallow the entire driver stack in four days. Coming back in 2026 worked because I broke the job into small questions I could test one at a time: prove userspace USB works, get read-only commands talking, catch why verify hung, mock the wire for 144 offline tests, and solve the PAM keyring gap last.
Every breakthrough came from the same habit. Whenever hardware or Linux disagreed with my assumptions (verify hanging, endpoints flipping mid-enrollment, slot 0 vanishing, UI deadlocking on a property read), I stopped editing code, wrote down every explanation that fit the facts, and ran the smallest test that could rule one out.
References
- depau/elanpoc, the ELAN 0c4c proof of concept that gave me the starting command table (MIT).
- libfprint, especially elanmoc.c and elan.c.
- fprintd and pam_fprintd.c.
- usbmon, the Linux kernel USB capture interface.
pam_set_item(3), for howPAM_AUTHTOKworks.- systemd credentials, for TPM sealing via
systemd-creds. nusb, the pure-Rust USB library used byelanprint-usb.- Reversing a Fingerprint Reader Protocol by Neodyme, a similar project on a different sensor.









