Skip to content

Conversation

@justin-stephenson
Copy link
Contributor

@justin-stephenson justin-stephenson commented Jun 3, 2025

PIN attempts message is only shown when <= 3

justin@fedora:~$ su - pkuser
Insert your passkey device, then press ENTER.
Enter PIN:
You have 3 PIN attempts remaining

In addition, refactored a lot of PAM passkey child related code

@justin-stephenson justin-stephenson force-pushed the passkey_call_preflight branch from ec79320 to 4b46d79 Compare June 3, 2025 14:22
@justin-stephenson justin-stephenson changed the title Add passkey preflight operation PAM: Add passkey preflight operation Jun 3, 2025
@justin-stephenson justin-stephenson force-pushed the passkey_call_preflight branch 3 times, most recently from 496c4e9 to ee7e765 Compare June 5, 2025 14:46
@ikerexxe
Copy link
Contributor

ikerexxe commented Jun 6, 2025

I did not check the code, but went straight to testing. There is one thing that caught my attention. When the number of attempts remaining is less than 3 the user is supposed to get that number before asking for the PIN, so that they are aware that they are in a risky situation. Something like:

$ su - iker@ipa.test
Insert your passkey device, then press ENTER.
You have 3 PIN attempts remaining
Enter PIN:
su: Authentication failure

In general terms, passkey preflight should be run during preauth stage. I don't know how hard it would be to implement it this way but it would make more sense.

@justin-stephenson justin-stephenson force-pushed the passkey_call_preflight branch from ee7e765 to 49fe0bd Compare June 6, 2025 12:27
@justin-stephenson
Copy link
Contributor Author

I did not check the code, but went straight to testing. There is one thing that caught my attention. When the number of attempts remaining is less than 3 the user is supposed to get that number before asking for the PIN, so that they are aware that they are in a risky situation. Something like:

$ su - iker@ipa.test
Insert your passkey device, then press ENTER.
You have 3 PIN attempts remaining
Enter PIN:
su: Authentication failure

In general terms, passkey preflight should be run during preauth stage. I don't know how hard it would be to implement it this way but it would make more sense.

It is run during preauth stage, I just had to move around the pam_sss code which sends the message to the console. Please try again.

Copy link
Contributor

@ikerexxe ikerexxe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, now the testing worked as expected:

su - iker@ipa.test
Insert your passkey device, then press ENTER.
You have 3 PIN attempts remaining

Enter PIN:
su: Authentication failure

I didn't check all the code, but there is something that caught my eye. See inline.

@justin-stephenson
Copy link
Contributor Author

@ikerexxe Please confirm these are the appropriate backport labels to use also

@alexey-tikhonov
Copy link
Member

@ikerexxe Please confirm these are the appropriate backport labels to use also

What RHEL versions do you target?

@ikerexxe
Copy link
Contributor

ikerexxe commented Jul 1, 2025

This PR supersedes #7631

@justin-stephenson justin-stephenson force-pushed the passkey_call_preflight branch from 65beeac to 810da7b Compare July 1, 2025 19:53
Copy link
Contributor

@ikerexxe ikerexxe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some minor comments. By the way, I forgot to mention that I tested it and it works as expected

@justin-stephenson
Copy link
Contributor Author

I've left a bunch of (pretty cosmetic) comments inline.

But I'm only reading code, I can't actually test this.

Thus I'll add @madhuriupadhye as additional reviewer (to actually test this and also fix passkey tests that are broken by this PR).

Thank you for the review. I addressed comments related to my code, and will let Iker address his commits when he returns from PTO.

ikerexxe and others added 4 commits August 5, 2025 12:00
Account both for time consumed by `fido_dev_info_manifest()` and
`sleep()`, which can return in no time if interrupted.

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
Expand the passkey_child to detect whether a FIDO2 device needs a PIN
and the number of attempts left for the PIN. This is needed to improve
the overall user experience by providing a way for SSSD to detect these
features before the user is requested to interact with them.

Expected input to run passkey_child: `--preflight`, `--domain` and
`--key-handle`.

Output: whether PIN is needed (boolean) and number of PIN attempts left
(integer) in JSON. Example:
{"pin_required": true, "attempts": 8}

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
When performing a passkey authentication and the PIN is entered 3 times
incorrectly the FIDO2 device requires a power cycle (disconnect and
reconnect the device to the USB port). libfido2 recognizes this with a
special error code and the passkey child should return it so that the
SSSD responder is aware of it.

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
Also refactor PAM passkey child related operations
@ikerexxe ikerexxe force-pushed the passkey_call_preflight branch from 966e36b to 2b2bd2a Compare August 5, 2025 10:09
@ikerexxe
Copy link
Contributor

ikerexxe commented Aug 5, 2025

I've updated the code to address Alexey's concerns

@alexey-tikhonov
Copy link
Member

@ikerexxe, thanks for updates.

Do I understand correctly that the only point of passkey: timeout argument refactor patch is to use 'timeout = 1' for preflight()?

I think it's not enough.

'sssd_pam' should provide timeout as a command line argument to 'passkey_child' and this (perhaps decreased by 1) should be used instead of TIMEOUT define (see 'p11_child' as example).

What about this ^^?

@ikerexxe
Copy link
Contributor

ikerexxe commented Aug 5, 2025

Do I understand correctly that the only point of passkey: timeout argument refactor patch is to use 'timeout = 1' for preflight()?
I think it's not enough.
'sssd_pam' should provide timeout as a command line argument to 'passkey_child' and this (perhaps decreased by 1) should be used instead of TIMEOUT define (see 'p11_child' as example).

Unless you plan to provide a way for this to be configurable I don't see any difference between the actual implementation and your proposal. Thus, I'd prefer to keep it as it is.

@alexey-tikhonov
Copy link
Member

Do I understand correctly that the only point of passkey: timeout argument refactor patch is to use 'timeout = 1' for preflight()?
I think it's not enough.
'sssd_pam' should provide timeout as a command line argument to 'passkey_child' and this (perhaps decreased by 1) should be used instead of TIMEOUT define (see 'p11_child' as example).

Unless you plan to provide a way for this to be configurable

It is already configurable via sssd.conf::passkey_child_timeout option.

I don't see any difference between the actual implementation and your proposal.

The issue is that 'passkey_child' doesn't use it.

@ikerexxe
Copy link
Contributor

ikerexxe commented Aug 6, 2025

There are two distinct timeouts happening here: the timeout you're referring to controls how long the PAM responder will wait for the passkey_child process to complete. The other, separate timeout determines how much time the user has to physically connect their FIDO2 token.

@alexey-tikhonov
Copy link
Member

There are two distinct timeouts happening here: the timeout you're referring to controls how long the PAM responder will wait for the passkey_child process to complete. The other, separate timeout determines how much time the user has to physically connect their FIDO2 token.

They should be related. At the very least 2nd can't be greater than 1st.
Take 'p11_child' as an example: all internal child timeouts should be less than governing sssd_pam timeout.

@ikerexxe
Copy link
Contributor

ikerexxe commented Aug 7, 2025

Agreed to tackle the timeout topic on a different PR.

Copy link
Contributor

@thalman thalman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@justin-stephenson
Copy link
Contributor Author

@ikerexxe @madhuriupadhye @alexey-tikhonov Hi, can you approve the PR if you have no further comments/concerns?

@ikerexxe
Copy link
Contributor

CI, and more specifically the system tests, are in the red, and I believe this is due to our changes. I have asked Madhuri to review them.

@alexey-tikhonov
Copy link
Member

@ikerexxe @madhuriupadhye @alexey-tikhonov Hi, can you approve the PR if you have no further comments/concerns?

IIUC, we need tests to be updated alongside with this PR.
I don't care if it's part of this PR or a separate PR, but it should be ready.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants