Bug 1533964

Summary: sudo skips PAM account module in case NOPASSWD is used in sudoers
Product: Red Hat Enterprise Linux 7 Reporter: Thorsten Scherf <tscherf>
Component: sudoAssignee: Daniel Kopeček <dkopecek>
Status: CLOSED ERRATA QA Contact: Patrik Kis <pkis>
Severity: medium Docs Contact: Mirek Jahoda <mjahoda>
Priority: medium    
Version: 7.4CC: dapospis, lmiksik, mjahoda, mthacker, pkis
Target Milestone: rcKeywords: FutureFeature, Patch, Triaged
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: sudo-1.8.23-1.el7 Doc Type: Enhancement
Doc Text:
*sudo* now runs PAM stack even when no authentication is required With this update, the *sudo* utility runs Pluggable Authentication Module (PAM) account management modules even when the "NOPASSWD" option is configured in the policy. This enables checking for restrictions imposed by PAM modules outside of the authentication phase. As a result, PAM modules, such as `pam_time`, now work properly in the described scenario.
Story Points: ---
Clone Of:
: 1679209 (view as bug list) Environment:
Last Closed: 2018-10-30 11:09:01 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1547974    
Bug Blocks:    
Attachments:
Description Flags
proposed patch
none
upstream fix of a regression related to NOPASSWD PAM stack handling none

Description Thorsten Scherf 2018-01-12 16:35:02 UTC
Description of problem:
sudo skips the PAM account phase and therefore also skips the pam_time module which results in failed time based account restriction.  

sudo should use 'pam_acct_mgmt()' in case no authentication is required. The function is fully independent of 'pam_authenticate()'.

http://www.linux-pam.org/Linux-PAM-html/adg-interface-by-app-expected.html#adg-pam_acct_mgmt

Version-Release number of selected component (if applicable):
all versions of sudo are affected.

How reproducible:

/etc/sudoers:
foobar	 ALL=(ALL)	NOPASSWD: ALL

/etc/pam.d/sudo:
account required pam_time.so

/etc/security/time.conf:
sudo;*;*;!Al0000-24000

sudo still works for the 'foobar' user. Expectation is that sudo is failing.

Steps to Reproduce:
1.
2.
3.

Actual results:


Expected results:


Additional info:

Comment 3 Daniel Kopeček 2018-01-17 08:31:54 UTC
Created attachment 1382271 [details]
proposed patch

Comment 12 Daniel Kopeček 2018-09-24 14:01:25 UTC
Created attachment 1486438 [details]
upstream fix of a regression related to NOPASSWD PAM stack handling

Comment 15 errata-xmlrpc 2018-10-30 11:09:01 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/RHEA-2018:3199