Skip to content

Change system-auth auth sufficient order - #336

Closed
LecrisUT wants to merge 3 commits into
authselect:masterfrom
LecrisUT:fix/system-auth-order
Closed

LecrisUT wants to merge 3 commits into
authselect:masterfrom
LecrisUT:fix/system-auth-order

Conversation

@LecrisUT

Copy link
Copy Markdown

When the user has set both a yubikey and a fingerprint sensor, the former fails quick when no suitable device is present, while the latter awaits the user input and retries.

A sensible order is then to try the yubikey first and then the fingerprint.

Note that it is ambiguous when the user has a setup of with-pam-u2f-2fa and with-fingerprint, i.e. does the user want:

  • successfully login if fingerprint only is present
  • require yubikey present, but can login either via fingerprint or password

I suspect that the latter was done even without the reordering of auth required pam_u2f.so cue, but I am not familiar enough to confirm this, or to know how can one configure it for the first scenario

@pbrezina

Copy link
Copy Markdown
Member

Hi, thank you for your contribution. What you say make sense to me. password-auth certainly should not contain fingerprint, this is used by gdm to try parallel login at once (i.e. fprint, password, smartcard). I'm not currently sure if pam_u2f should be there.

@ikerexxe Can you please look at this once as you did some work in pam_u2f area?

@LecrisUT

Copy link
Copy Markdown
Author

But for none gnome configuration, KDE's sddm simply uses auth substack password-auth. And without it, it would not be picked up as auth sufficient pam_fprintd. Any ideas on how to make both compatible?

@pbrezina

Copy link
Copy Markdown
Member

But for none gnome configuration, KDE's sddm simply uses auth substack password-auth. And without it, it would not be picked up as auth sufficient pam_fprintd. Any ideas on how to make both compatible?

Hmm. Probably the best solution would be for KDE to switch to system-auth. Password-auth should be really reserved just for password or password-like authentication, so you don't only miss fingerprint but smartcards as well. Can you report a bug against Fedora KDE spin and lets see what happens there.

@LecrisUT

Copy link
Copy Markdown
Author

Ok, I'll try to get a hold of KDE devs about this.

Password-auth should be really reserved just for password or password-like authentication

I am confused about this then. Why is this line in password-auth

auth        sufficient                                   pam_u2f.so cue                                         {include if "with-pam-u2f"}

This one would pass through the password-like authentication so stuff like gnome-keyring will not work because no password is passed.

@ikerexxe

Copy link
Copy Markdown

@LecrisUT can you define what's the exact workflow that you are looking for? I'm specially concerned as to what should happen when enabling with-pam-u2f-2fa and the FIDO2 isn't present? When should the workflow fail?

@LecrisUT

Copy link
Copy Markdown
Author

@ikerexxe with regards to system-auth:

  • with-pam-u2f-2fa should be exclusive with with-pam-u2f, where the former requires the the FIDO device while the latter allows to authenticate with only one of them
  • with-pam-u2f-2fa + with-fingerprint: must have FIDO device and then try fingerprint and if fails, allow password as well. This should fail immediately if FIDO is not present. I don't know if it works as expected with the current or previous order
  • with-pam-u2f + with-fingerprint: first try to find FIDO device, then try fingerprint, then try password

With regards to password-auth, it is unclear why it is allowed to use with-pam-u2f.

@ikerexxe

Copy link
Copy Markdown
* `with-pam-u2f-2fa` + `with-fingerprint`: must have FIDO device and then try fingerprint and if fails, allow password as well. This should fail immediately if FIDO is not present. I don't know if it works as expected with the current or previous order

If that is so, then I think that you need to change the auth required pam_u2f.so... to auth requisite pam_u2f.so..., so that the authentication fails immediately if the FIDO2 token authentication factor fails.

@LecrisUT

LecrisUT commented Mar 28, 2023 •

Copy link
Copy Markdown
Author

How does it work if the user did not setup FIDO for that account? Will it return error? But from my reading of required vs requisite, it only differs in that it is fail fast or not.

Edit: Well, I've confirmed that you are not locked-out, and indeed requisite is a better workflow here. One issue is that error message is non-descriptive. It should give you the reason for login failure, but it only shows up as login invalid. That is a pam-u2f issue though.

@ikerexxe

Copy link
Copy Markdown

How does it work if the user did not setup FIDO for that account? Will it return error? But from my reading of required vs requisite, it only differs in that it is fail fast or not.

Yes, it will return an error and I think the fail fast approach is better for this case.

@pbrezina have I addressed your concern?

@LecrisUT

Copy link
Copy Markdown
Author

Btw, I should add the link to Fedora KDE issue on this. As for the CI, anything I should do to make it run?

@pbrezina

Copy link
Copy Markdown
Member

Hi, I'm sorry for the delay, I was side tracked with other tasks, I will look into this during this or the next week.

LecrisUT added 3 commits July 18, 2023 12:32
When the user has set both a yubikey and a fingerprint sensor, the former fails quick when no suitable device is present, while the latter awaits the user input and retries.

A sensible order is then to try the yubikey first and then the fingerprint
This will ensure that the authenthication will fail fast if no FIDO device is present
@pbrezina
pbrezina force-pushed the fix/system-auth-order branch from 0d0407d to 70fe1bc Compare July 18, 2023 10:32
@pbrezina

Copy link
Copy Markdown
Member

Hi, in general, I agree with the patch. But I still don't think that pam_fprintd should be used in password-auth as that is definitely not how it should be used in Gnome. I don't know much about KDE, I know there are/were other issues related to pam_u2f. I need to reach and connect KDE and Gnome developers and talk to them about how exactly are they using different PAM stacks and what are the differences between these two.

Gnome has three dconf settings that say what auth type is enabled (password, smartcard, fingerprint) and it loads the pam stack based on this information. I need to dig deeper to the original pull request to see why we kept pam_u2f in password-auth. Doesn't it work similar to password? I.e. you press button on the token and it writes stuff to stdin?

About requisite, if pam_u2f fails then pam_faillock does not run, so imho it should stay on required.

@pbrezina

Copy link
Copy Markdown
Member

Unfortunately, I don't have any token so adding changes to pam_u2f is always difficult for me as I don't have any means to test it.

@LecrisUT

Copy link
Copy Markdown
Author

So the main is d2d621d. Feel free to drop any of the other 2. I have tried to get in touch with Fedora KDE packagers, but they wouldn't respond on this. If you could try and contact them, that would be wonderful.

About the requisite, iirc this is specifically for pam-u2f-2fa where it would still run the other authentications even though the yubikey was not present. I need to re-test this to confirm the beaviour.

Doesn't it work similar to password? I.e. you press button on the token and it writes stuff to stdin?

As far as I know, no it goes through the specific pam library. The key is that it has to be there for calls like sudo, not just for logins.

@pbrezina

Copy link
Copy Markdown
Member

I just initiated the discussion with Gnome people, I yet need to lookup contact person for KDE.

@halfline

Copy link
Copy Markdown

As a GNOME person, I'll say we don't use system-auth ~at all (except for from polkit), so changes to it won't really affect us. It makes sense to me to try the thing that fails fast first. I do wonder if it will slow things down for people who have yubikeys in their system 24/7 for different use cases than pam-u2f-2fa but 🤷🏽‍♂️

As the person who originally added password-auth I can say password-auth definitely shouldn't have pam_fprintd in it. password-auth and fingerprint-auth were created to have just the service in the name (and system-auth was left to be the aggregate service).

pam_u2f.so being in password-auth is kind of wrong too for the same reason, but it's more defensible because we don't currently have any other way to wedge it into the login experience if password-auth is getting used. so it's the best place for it, for now, I suppose.

@LecrisUT

Copy link
Copy Markdown
Author

It's been a while since the debugging session on this. I don't remember what it was that had me make the commit to add fprint_d to password-auth, might have been related to the sudo.

My setup is that I have my work pc password saved in a keepass and use it only in case of emergencies. Otherwise I would prefer to use the yubikey or fingerprint authentication for all access. And this PR is mostly to make the interaction between all 3 methods more accessible.

It might be that the KDE or Fedora KDE pam stack is misusing the password-auth and such configuration. It would really be necessary to get people together and discuss how each component should be used across the OSs.

@pbrezina

Copy link
Copy Markdown
Member

Thanks for the explanation. So let's leave it in system-auth and password-auth for now, remove commit that adds fprintd do password-auth.

I'm not sure about the requisite change. How does it behave if

  • the user has u2f auth enabled but no token is inserted
  • the user has u2f auth enabled and token is inserted
  • the user does not have u2f auth enabled and no token is inserted
  • the user does not have u2f auth enabled but token is inserted

If I understand it correctly, requisite will reject other means of authentication if user has u2f enabled, right?

It might be that the KDE or Fedora KDE pam stack is misusing the password-auth and such configuration. It would really be necessary to get people together and discuss how each component should be used across the OSs.

Yes. With current and emerging authentication standards, it is needed to agree on some common handling of non-password authentication. It is no longer just smartcard and fingerprint, but SSSD now also supports OAuth2 and passkey. But that is out of authselect scope.

@pbrezina

Copy link
Copy Markdown
Member

Closing for inactivity.

@pbrezina pbrezina closed this Jan 14, 2025
@LecrisUT

Copy link
Copy Markdown
Author

Would still love to have at least the concept of this implemented, but I don't have enough expertise to understand the intricacies. But maybe d2d621d is sufficient and it can be cherry-picked in, with some minor adjustment that local also needs this change. I at the very least am doing only the system-auth change and it seems to be ok.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants