Bug 1741452 - pam_sss: empty smart card pin registers as authentication attempt
Summary: pam_sss: empty smart card pin registers as authentication attempt
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: sssd
Version: 8.1
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: 8.0
Assignee: SSSD Maintainers
QA Contact: sssd-qe
URL:
Whiteboard: sync-to-jira
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2019-08-15 08:05 UTC by adam winberg
Modified: 2020-05-02 19:12 UTC (History)
10 users (show)

Fixed In Version: sssd-2.2.3-2.el8
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-04-28 16:56:04 UTC
Type: Bug
Target Upstream Version:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github SSSD sssd issues 5036 0 None None None 2020-05-02 19:12:27 UTC
Red Hat Product Errata RHBA-2020:1863 0 None None None 2020-04-28 16:56:17 UTC

Description adam winberg 2019-08-15 08:05:02 UTC
Description of problem:
Providing an empty smart card PIN (for example by just pressing ENTER on pin prompt) is registered by SSSD as an authentication attempt. This will fail and increase the failed pin count on the card. 

Empty PIN inputs should not register as an authentication attempt. In other pam modules such as pam_unix and pam_pkcs11 this behaviour is configurable with the 'nullok' parameter. 

Version-Release number of selected component (if applicable):
sssd-2.2.0-1.el8.x86_64

How reproducible:
Always

Steps to Reproduce:
1. Trigger a smart card authentication with for example sudo or session login
2. Press ENTER without inputting PIN
3.

Actual results:
SSSD tries to unlock smart card with the empty PIN which fails and increase the failed pin count on the card.

Expected results:
SSSD should ignore the authentication attempt.

Additional info:

Comment 1 Sumit Bose 2019-08-20 10:10:53 UTC
Upstream ticket:
https://pagure.io/SSSD/sssd/issue/4068

Comment 2 Sumit Bose 2019-08-23 18:09:47 UTC
Master:
 - 945970088209a1a8a75a94e600a4587fb6e8f48c
 - 6e759010ae43c039eeaff6a4390beb72af0d0e8e

Comment 3 adam winberg 2019-11-14 10:52:22 UTC
This fix does not seem to be included in 8.1?

Comment 4 Alexey Tikhonov 2019-11-14 11:00:06 UTC
(In reply to adam winberg from comment #3)
> This fix does not seem to be included in 8.1?

Right, it didn't get into 8.1.

Comment 11 Scott Poore 2020-01-13 19:01:29 UTC
Verified.

Version ::

sssd-2.2.3-6.el8.x86_64

Results ::

With full IPA Smart Card setup, I tested using an Aventra MyEID smart card.


##################### First show successful authentication with PIN


[root@client emptypin]# su - ipauser1 -c 'su - ipauser1 -c whoami'
PIN for sctest (MyEID): 
ipauser1

[root@client emptypin]# journalctl -xel --no-pager|tail -5
Jan 13 12:43:28 client.ipa.test su[11712]: (to ipauser1) root on pts/0
Jan 13 12:43:28 client.ipa.test su[11712]: pam_systemd(su-l:session): Cannot create session: Already running in a session or user slice
Jan 13 12:43:28 client.ipa.test su[11712]: pam_unix(su-l:session): session opened for user ipauser1 by root(uid=1815000132)
Jan 13 12:43:28 client.ipa.test su[11712]: pam_unix(su-l:session): session closed for user ipauser1
Jan 13 12:43:28 client.ipa.test su[11711]: pam_unix(su-l:session): session closed for user ipauser1

[root@client emptypin]# pkcs11-tool -T
Available slots:
Slot 0 (0x0): SCM Microsystems Inc. SCR 3310 [CCID Interface] (53311651713564)
  token label        : sctest (MyEID)
  token manufacturer : Aventra Ltd.
  token model        : PKCS#15
  token flags        : login required, rng, token initialized, PIN initialized
  hardware version   : 0.0
  firmware version   : 40.0
  serial num         : 7055056447986431
  pin min/max        : 4/8



##################### Next Show 2 failed attempts to authentication with incorrect PIN

### badpin 1
[root@client emptypin]# su - ipauser1 -c 'su - ipauser1 -c whoami'
PIN for sctest (MyEID): 
su: Authentication failure

[root@client emptypin]# journalctl -xel --no-pager|tail -5
Jan 13 12:44:30 client.ipa.test [sssd[krb5_child[11831]]][11831]: Pre-authentication failed: Preauthentication failed
Jan 13 12:44:30 client.ipa.test su[11797]: pam_sss(su-l:auth): authentication failure; logname=root uid=1815000132 euid=0 tty=pts/0 ruser=root rhost= user=ipauser1
Jan 13 12:44:30 client.ipa.test su[11797]: pam_sss(su-l:auth): received for user ipauser1: 17 (Failure setting user credentials)
Jan 13 12:44:32 client.ipa.test su[11797]: FAILED SU (to ipauser1) root on pts/0
Jan 13 12:44:33 client.ipa.test su[11796]: pam_unix(su-l:session): session closed for user ipauser1

[root@client emptypin]# pkcs11-tool -T
Available slots:
Slot 0 (0x0): SCM Microsystems Inc. SCR 3310 [CCID Interface] (53311651713564)
  token label        : sctest (MyEID)
  token manufacturer : Aventra Ltd.
  token model        : PKCS#15
  token flags        : login required, rng, token initialized, PIN initialized
  hardware version   : 0.0
  firmware version   : 40.0
  serial num         : 7055056447986431
  pin min/max        : 4/8

### badpin 2

[root@client emptypin]# su - ipauser1 -c 'su - ipauser1 -c whoami'
PIN for sctest (MyEID): 
su: Authentication failure

[root@client emptypin]# journalctl -xel --no-pager|tail -5
Jan 13 12:45:10 client.ipa.test [sssd[krb5_child[11881]]][11881]: Pre-authentication failed: Preauthentication failed
Jan 13 12:45:10 client.ipa.test su[11847]: pam_sss(su-l:auth): authentication failure; logname=root uid=1815000132 euid=0 tty=pts/0 ruser=root rhost= user=ipauser1
Jan 13 12:45:10 client.ipa.test su[11847]: pam_sss(su-l:auth): received for user ipauser1: 17 (Failure setting user credentials)
Jan 13 12:45:12 client.ipa.test su[11847]: FAILED SU (to ipauser1) root on pts/0
Jan 13 12:45:13 client.ipa.test su[11846]: pam_unix(su-l:session): session closed for user ipauser1

[root@client emptypin]# pkcs11-tool -T
Available slots:
Slot 0 (0x0): SCM Microsystems Inc. SCR 3310 [CCID Interface] (53311651713564)
  token label        : sctest (MyEID)
  token manufacturer : Aventra Ltd.
  token model        : PKCS#15
  token flags        : login required, rng, token initialized, final user PIN try, PIN initialized
  hardware version   : 0.0
  firmware version   : 40.0
  serial num         : 7055056447986431
  pin min/max        : 4/8

^^^ We can see "final user PIN try" in token flags after 2 failed attempts ^^^

##################### Now show 5 attempts with no/empty pin

### no pin 1

[root@client emptypin]# su - ipauser1 -c 'su - ipauser1 -c whoami'
PIN for sctest (MyEID): 
su: Authentication failure

[root@client emptypin]# journalctl -xel --no-pager|tail -5
Jan 13 12:45:31 client.ipa.test su[11888]: (to ipauser1) root on pts/0
Jan 13 12:45:31 client.ipa.test su[11888]: pam_systemd(su-l:session): Cannot create session: Already running in a session or user slice
Jan 13 12:45:31 client.ipa.test su[11888]: pam_unix(su-l:session): session opened for user ipauser1 by root(uid=0)
Jan 13 12:45:46 client.ipa.test su[11889]: FAILED SU (to ipauser1) root on pts/0
Jan 13 12:45:47 client.ipa.test su[11888]: pam_unix(su-l:session): session closed for user ipauser1

[root@client emptypin]# pkcs11-tool -T
Available slots:
Slot 0 (0x0): SCM Microsystems Inc. SCR 3310 [CCID Interface] (53311651713564)
  token label        : sctest (MyEID)
  token manufacturer : Aventra Ltd.
  token model        : PKCS#15
  token flags        : login required, rng, token initialized, final user PIN try, PIN initialized
  hardware version   : 0.0
  firmware version   : 40.0
  serial num         : 7055056447986431
  pin min/max        : 4/8


### no pin 2

[root@client emptypin]# su - ipauser1 -c 'su - ipauser1 -c whoami'
PIN for sctest (MyEID): 
su: Authentication failure

[root@client emptypin]# journalctl -xel --no-pager|tail -5
Jan 13 12:46:09 client.ipa.test su[11935]: (to ipauser1) root on pts/0
Jan 13 12:46:09 client.ipa.test su[11935]: pam_systemd(su-l:session): Cannot create session: Already running in a session or user slice
Jan 13 12:46:09 client.ipa.test su[11935]: pam_unix(su-l:session): session opened for user ipauser1 by root(uid=0)
Jan 13 12:46:22 client.ipa.test su[11936]: FAILED SU (to ipauser1) root on pts/0
Jan 13 12:46:23 client.ipa.test su[11935]: pam_unix(su-l:session): session closed for user ipauser1

[root@client emptypin]# pkcs11-tool -T
Available slots:
Slot 0 (0x0): SCM Microsystems Inc. SCR 3310 [CCID Interface] (53311651713564)
  token label        : sctest (MyEID)
  token manufacturer : Aventra Ltd.
  token model        : PKCS#15
  token flags        : login required, rng, token initialized, final user PIN try, PIN initialized
  hardware version   : 0.0
  firmware version   : 40.0
  serial num         : 7055056447986431
  pin min/max        : 4/8


### no pin 3

[root@client emptypin]# su - ipauser1 -c 'su - ipauser1 -c whoami'
PIN for sctest (MyEID): 
su: Authentication failure

[root@client emptypin]# journalctl -xel --no-pager|tail -5
-- Unit dnf-makecache.service has finished starting up.
-- 
-- The start-up result is RESULT.
Jan 13 12:46:51 client.ipa.test su[11984]: FAILED SU (to ipauser1) root on pts/0
Jan 13 12:46:52 client.ipa.test su[11982]: pam_unix(su-l:session): session closed for user ipauser1

[root@client emptypin]# pkcs11-tool -T
Available slots:
Slot 0 (0x0): SCM Microsystems Inc. SCR 3310 [CCID Interface] (53311651713564)
  token label        : sctest (MyEID)
  token manufacturer : Aventra Ltd.
  token model        : PKCS#15
  token flags        : login required, rng, token initialized, final user PIN try, PIN initialized
  hardware version   : 0.0
  firmware version   : 40.0
  serial num         : 7055056447986431
  pin min/max        : 4/8


### no pin 4

[root@client emptypin]# su - ipauser1 -c 'su - ipauser1 -c whoami'
PIN for sctest (MyEID): 
su: Authentication failure

[root@client emptypin]# journalctl -xel --no-pager|tail -5
Jan 13 12:47:09 client.ipa.test su[12027]: (to ipauser1) root on pts/0
Jan 13 12:47:09 client.ipa.test su[12027]: pam_systemd(su-l:session): Cannot create session: Already running in a session or user slice
Jan 13 12:47:09 client.ipa.test su[12027]: pam_unix(su-l:session): session opened for user ipauser1 by root(uid=0)
Jan 13 12:47:21 client.ipa.test su[12028]: FAILED SU (to ipauser1) root on pts/0
Jan 13 12:47:22 client.ipa.test su[12027]: pam_unix(su-l:session): session closed for user ipauser1

[root@client emptypin]# pkcs11-tool -T
Available slots:
Slot 0 (0x0): SCM Microsystems Inc. SCR 3310 [CCID Interface] (53311651713564)
  token label        : sctest (MyEID)
  token manufacturer : Aventra Ltd.
  token model        : PKCS#15
  token flags        : login required, rng, token initialized, final user PIN try, PIN initialized
  hardware version   : 0.0
  firmware version   : 40.0
  serial num         : 7055056447986431
  pin min/max        : 4/8


### no pin 5

[root@client emptypin]# su - ipauser1 -c 'su - ipauser1 -c whoami'
PIN for sctest (MyEID): 
su: Authentication failure

[root@client emptypin]# journalctl -xel --no-pager|tail -5
Jan 13 12:47:33 client.ipa.test su[12074]: (to ipauser1) root on pts/0
Jan 13 12:47:33 client.ipa.test su[12074]: pam_systemd(su-l:session): Cannot create session: Already running in a session or user slice
Jan 13 12:47:33 client.ipa.test su[12074]: pam_unix(su-l:session): session opened for user ipauser1 by root(uid=0)
Jan 13 12:47:54 client.ipa.test su[12075]: FAILED SU (to ipauser1) root on pts/0
Jan 13 12:47:55 client.ipa.test su[12074]: pam_unix(su-l:session): session closed for user ipauser1

[root@client emptypin]# pkcs11-tool -T
Available slots:
Slot 0 (0x0): SCM Microsystems Inc. SCR 3310 [CCID Interface] (53311651713564)
  token label        : sctest (MyEID)
  token manufacturer : Aventra Ltd.
  token model        : PKCS#15
  token flags        : login required, rng, token initialized, final user PIN try, PIN initialized
  hardware version   : 0.0
  firmware version   : 40.0
  serial num         : 7055056447986431
  pin min/max        : 4/8


So with no/empty pin passed to sssd, I see no particular error from sssd_pam and it doesn't lock the card while showing "final user PIN try".

Now to confirm that the card should be locked:

### good first
[root@client emptypin]# su - ipauser1 -c 'su - ipauser1 -c whoami'
PIN for sctest (MyEID): 
ipauser1

[root@client emptypin]# pkcs11-tool -T
Available slots:
Slot 0 (0x0): SCM Microsystems Inc. SCR 3310 [CCID Interface] (53311651713564)
  token label        : sctest (MyEID)
  token manufacturer : Aventra Ltd.
  token model        : PKCS#15
  token flags        : login required, rng, token initialized, PIN initialized
  hardware version   : 0.0
  firmware version   : 40.0
  serial num         : 7055056447986431
  pin min/max        : 4/8

### 2 bad next 

[root@client emptypin]# su - ipauser1 -c 'su - ipauser1 -c whoami'
PIN for sctest (MyEID): 
su: Authentication failure

[root@client emptypin]# su - ipauser1 -c 'su - ipauser1 -c whoami'
PIN for sctest (MyEID): 
su: Authentication failure

### check status

[root@client emptypin]# pkcs11-tool -T
Available slots:
Slot 0 (0x0): SCM Microsystems Inc. SCR 3310 [CCID Interface] (53311651713564)
  token label        : sctest (MyEID)
  token manufacturer : Aventra Ltd.
  token model        : PKCS#15
  token flags        : login required, rng, token initialized, final user PIN try, PIN initialized
  hardware version   : 0.0
  firmware version   : 40.0
  serial num         : 7055056447986431
  pin min/max        : 4/8

### 3rd bad pin

[root@client emptypin]# su - ipauser1 -c 'su - ipauser1 -c whoami'
PIN for sctest (MyEID): 
su: Authentication failure

### check final status

[root@client emptypin]# pkcs11-tool -T
Available slots:
Slot 0 (0x0): SCM Microsystems Inc. SCR 3310 [CCID Interface] (53311651713564)
  token label        : sctest (MyEID)
  token manufacturer : Aventra Ltd.
  token model        : PKCS#15
  token flags        : login required, rng, token initialized, PIN initialized, user PIN locked
  hardware version   : 0.0
  firmware version   : 40.0
  serial num         : 7055056447986431
  pin min/max        : 4/8
[root@client emptypin]# 


So it does change flags when a final bad pin is received to "user PIN locked".

Comment 13 errata-xmlrpc 2020-04-28 16:56:04 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2020:1863


Note You need to log in before you can comment on or make changes to this bug.