omarchy icon indicating copy to clipboard operation
omarchy copied to clipboard

sudo without a terminal waits on an invisible fingerprint prompt, then fails

Open cad0p opened this issue 1 month ago • 5 comments

System details

Apple MacBook Pro (16-inch, M1 Pro, 2021), Asahi-based kernel, Omarchy 4.0.3rc4-2, fingerprint set up with omarchy-setup-security-fingerprint

What's wrong?

With fingerprint set up, /etc/pam.d/sudo runs pam_fprintd.so first. When sudo has no terminal (a coding agent's tool call, a launcher, a background job), nothing appears on screen. pam_fprintd's Place your finger on the fingerprint reader goes to the calling process's own output, which the user isn't looking at. sudo then waits for a touch the user doesn't know is wanted; pam_fprintd's default timeout is 30 seconds. After that it falls back to a password prompt it has no terminal to read, and the command fails. Each failed attempt also counts toward pam_faillock's lockout (deny=10).

Steps: set up fingerprint, then run sudo true from a process without a terminal, such as a coding agent's shell tool. No prompt appears anywhere, and sudo fails unless the user happens to touch the sensor in time.

Expected: a visible prompt. The polkit dialog the shell already shows for pkexec accepts fingerprint or password.

cad0p avatar Oct 24 '26 04:10 cad0p

Additional data point from a different stack, and it diverges from the report: the failure is not the only outcome here. On this machine sudo from a tty-less caller usually ends up authenticated, with no finger and no password.

Setup: Omarchy 4.5.0-3, fprintd 1.94.5-2, an enrolled Goodix MOC sensor, lid open, called from a coding agent's shell tool (no tty, prompts go nowhere the user is looking). Same 30 s Verification timed out stall as reported.

The outcome flips on how stdin is plumbed to the child, alternating in the same second with nothing else differing:

stdin = agent's pipe (immediate EOF, 0 bytes)  -> root, and no `pam_unix(sudo:auth)` failure line at all
stdin = /dev/null                              -> `sudo: no password was provided`, denied
stdin = empty process-substitution pipe        -> denied, same messages
stdin = pipe containing "x" or "\n"            -> `1 incorrect password attempt`, denied

3/3 of the first shape authenticated; 0/5 of the others did.

pam_fprintd returns PAM_AUTHINFO_UNAVAIL on timeout (pam/pam_fprintd.c, lines 607-609), so as a sufficient module it falls through to pam_unix.so try_first_pass nullok in system-auth, and on that stdin shape pam_unix then succeeds without ever having been given a password. A lone empty line is rejected, so this is not an empty-password acceptance: the difference is between "no token at all" and "an empty token", and it is per-call, not per-machine.

Both consequences are worse than the reported one:

  1. The caller gets root silently after the stall, so privilege escalation looks like it works while nothing was confirmed with the user. The same shape reaches pkexec here: it returns root in ~2 s with no dialog, because the sensor is claimed and fprintd logs Device was already claimed for the polkit helper — that is #13748's territory, and #9558 shows the agent can also wedge in the other direction.
  2. Because those calls "succeed", the faillock counting above only bites the shapes that do fail. Each of those burns the full 30 s and a slot, so repeated agent calls drift towards deny=10 on the path that was supposed to degrade gracefully.

Expected: either the prompt is reachable (a #13748-style polkit dialog, or an askpass the caller can drive), or the fallback fails closed — not a coin flip on stdin plumbing.

4lleviate avatar Nov 06 '26 14:11 4lleviate

I read the report, the follow-up about authentication succeeding without a prompt, and the current fingerprint PAM setup and privilege-escalation guidance. No runtime reproduction was attempted, so the follow-up’s passwordless-elevation claim remains unverified.

GPT-6 in Codex performed this review (reasoning effort is not exposed to this session). I proposed a bug classification, but the separate classification model returned no usable category. No substantive second review ran; this is waiting for the classification review to be completed before verification continues.

omarchybot avatar Nov 18 '26 16:11 omarchybot

Reproduced deterministically on a second machine, with the auth chain captured. Two things worth correcting from my earlier comment: today the passwordless-success path did not reproduce, and stdin plumbing turned out not to be the variable.

Machine: Omarchy 4.5.0-3, fprintd 1.94.5-2, Goodix MOC, enrolled print (fprintd-list: right-index-finger), caller has no tty, nobody at the sensor.

/etc/pam.d/sudo as shipped here:

auth      [success=1 default=ignore] pam_exec.so quiet /usr/bin/omarchy-hw-laptop-closed
auth      sufficient pam_fprintd.so
#%PAM-1.0
auth      include   system-auth
...

No NOPASSWD in /etc/sudoers.d/ (sudo -n true → sudo: a password is required), so sudoers cannot explain any success.

Timing, five runs, stdin varied (</dev/null, printf '' |, <&-), all identical: ~32.3 s to rc=1. sudo -n true: 53 ms, no fprintd attempt.

journalctl for one run, abridged to the relevant lines:

sudo[3250997]: pam_exec(sudo:auth): /usr/bin/omarchy-hw-laptop-closed failed: exit code 1
sudo[3250997]: pam_unix(sudo:auth): conversation failed
sudo[3250997]: pam_unix(sudo:auth): auth could not identify password for [[REDACTED]]

Ordering and shape of the failure:

  1. pam_exec laptop-closed check fails with a lid open, so success=1 does not fire and evaluation falls through — fprintd is reached on every open-lid invocation.
  2. pam_fprintd waits its default 30 s. Nothing is printed to anything the caller's user can see; no pam_fprintd timeout line is logged at all, so the 30 s is only visible as the gap between the pam_exec line at 17:29:03 and the pam_unix line at 17:29:34.
  3. pam_unix then tries to ask for a password and cannot: conversation failed, no tty. sudo exits 1 after ~32 s.

Consequence for the reporter's framing: with a lid open and the user not looking, the invocation is not merely silent — it is a guaranteed 30 s stall followed by a hard failure, and the diagnosis is available only from the journal afterwards.

Open question I can't settle without a human: whether presenting a finger during that window succeeds, and whether the goodix/fprintd path on 4.5.0-3 differs from 4.0.3rc4. My earlier "usually authenticates with no finger" was recorded on 4.5.0-3 on 6 Nov; today six attempts all failed, so the divergence is unresolved rather than refuted.

4lleviate avatar Nov 18 '26 17:11 4lleviate

Follow-up that closes the open question, and corrects one line from my previous comment. A finger does authenticate on a tty-less caller, so the sensor path is not broken and "guaranteed hard failure" was too strong.

Procedure: 12 back-to-back setsid -w sudo true </dev/null, finger on the sensor during the window. Result alternates:

1 17:34:53 rc=0
2 17:35:03 rc=1
3 17:35:05 rc=0
4 17:35:07 rc=1
...

The first invocation took the full path and succeeded — pam_exec laptop-closed fails on an open lid → fprintd reached → authenticated after ~10 s → rc=0. Nothing was printed anywhere the caller could see, which is the actual defect: the touch is required and unannounced.

Two further things the run exposed:

Concurrent calls collide. The successful attempt holds the device, so the next invocation gets

fprintd[..]: Authorization denied to :1.4430 to call method 'Claim' for device 'Goodix MOC Fingerprint Sensor': Device was already claimed

and fails immediately (pam_unix: conversation failed) rather than waiting its turn. Any agent or script that runs sudo while another elevation is still in flight fails without a touch being relevant at all. A short retry would cover it.

pam_faillock compounds the stall. From the eighth repetition onward:

pam_faillock(sudo:auth): User [REDACTED] is temporarily locked out due to 10 consecutive failed login attempts

Ten silent tty-less timeouts are enough to reach the lockout threshold, after which even a normally-presented finger lands in a worse state. Worth considering whether pam_fprintd timeouts should count toward the fail count at all.

So the ranking of causes on 4.5.0-3, lid open: (1) no visible cue that a touch is wanted, (2) device-claim collision on concurrent calls, (3) faillock accumulation from (1). The 30 s stall is the symptom of (1), not a defect of its own.

4lleviate avatar Nov 18 '26 17:11 4lleviate

One more datum after the run: sudo -n true immediately after a successful finger auth still returns sudo: a password is required — a tty-less caller gets no timestamp ticket, so every call re-authenticates. That is what makes the device-claim collision above frequent rather than incidental, and it means an agent pays a finger per command with no batching. faillock holds only V records afterwards, so the lockout cleared itself with the successes.

4lleviate avatar Nov 18 '26 17:11 4lleviate