RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1736110 - lookup identity does not work in some cases
Summary: lookup identity does not work in some cases
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: sssd
Version: 7.8
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Pavel Březina
QA Contact: sssd-qe
URL:
Whiteboard: sync-to-jira
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2019-08-01 14:45 UTC by Ondrej
Modified: 2020-09-29 19:49 UTC (History)
14 users (show)

Fixed In Version: sssd-1.16.5-1.el7
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-09-29 19:49:11 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github SSSD sssd issues 5033 0 None closed IFP: GetUserAttr does not search by UPN 2020-12-14 11:10:13 UTC
Red Hat Product Errata RHBA-2020:3904 0 None None None 2020-09-29 19:49:41 UTC

Description Ondrej 2019-08-01 14:45:37 UTC
Description of problem:
We have a webserver on a system joined to AD.
We honor RFC2307, hence using following SSSD configuration:

[sssd]
    services = autofs, nss, pam, ifp
#    services = autofs, nss, pam
    config_file_version = 2
    debug_level = 0x1FF

    domains = mydomain.com
[nss]

[domain/mydomain.com]
    ldap_id_mapping = False
    ad_domain = MYDOMAIN.COM
    id_provider = ad
    auth_provider = ad
    chpass_provider = ad
    autofs_provider = ad
    cache_credentials = True
# let's use uid instead of sAMAccountName
    ldap_user_name = uid
    krb5_renew_interval = 3600
# request renewable Kerberos tickets
    krb5_renewable_lifetime = 30d

# future use of mod_identity_lookup
[ifp]
    	debug_level = 9
	allowed_uids = webserv, root
	user_attributes = +mail, +telephoneNumber, +givenname, +sn

... and the following Apache config snippet to set Proxy-User-Uid header:

        <Location />
                AuthType GSSAPI
                AuthName "SVN Login"
                require valid-user
...
#       Use mod_lookup_identity to fetch UID (can't use REMOTE_USER as Kerberos UPN can be different)
                LookupUserAttr name REMOTE_USER_UID " "

                RequestHeader set Proxy-User-Uid %{REMOTE_USER_UID}e
...
        </Location>

Now, this works OK (meaning REMOTE_USER_UID env variable is set) for all authenticated users which has sAMAccountName = uid.
Fow users, whose Windows identity (i.e. sAMAccountName) is NOT the same to the Unix one (defined by the UID attribute), the env above is NOT set.

Version-Release number of selected component (if applicable):
mod_lookup_identity-1.0.0-1.el7.x86_64

How reproducible:
always

Comment 2 Ondrej 2019-08-01 14:54:29 UTC
In Apache error log I see:
[Thu Aug 01 15:01:47.605707 2019] [lookup_identity:error] [pid 88999] [client 192.168.45.4:42115] Error dbus calling GetUserAttr(first.last, name): org.freedesktop.DBus.Error.Failed: No such user\n
happens for user where:
sAMAccountName = first.last
uid = firstl

Now (interestingly enough) both commands:
# sssctl user-checks first.last
# sssctl user-checks firstl

correctly displays the identity of the user in question

Comment 3 Ondrej 2019-08-01 15:12:27 UTC
Ok, as test with dbus-send fails (unable to detect user first.last) I guess it is rather a bug in SSSD, not sure.
What is important here that REMOTE_USER env variable usually contains the Kerberos User Principal.
Kerberos identity != Unix identity, see above.

Comment 4 Ondrej 2019-08-08 07:57:24 UTC
Update: not sAMAccountName, but userPrincipalName attribute (which is by default same as sAMAccountName) is not causing this.
if userPrincipalName != uid, then mod_lookup_identity fails to resolve the authenticated user.

Comment 6 Pavel Březina 2019-08-19 12:33:18 UTC
Thank you for the bug report. I can confirm that it is a bug in SSSD not in mod_lookup_identity.

The problem is that SSSD D-Bus method GetUserAttr parses the username on its own, instead of leaving it on underlying cache_req interface and therefore it will not try to search by principal name.

Comment 7 Pavel Březina 2019-08-19 12:41:18 UTC
Upstream ticket:
https://pagure.io/SSSD/sssd/issue/4065

Comment 8 Pavel Březina 2019-08-19 12:57:37 UTC
Upstream PR:
https://github.com/SSSD/sssd/pull/868

Comment 9 Pavel Březina 2019-08-19 12:58:25 UTC
Ondřej, I can build you a test build if you want on. Just tell me which version should I build.

Comment 10 Ondrej 2019-08-19 13:05:30 UTC
I am currently running sssd-1.16.2-13.el7_6.8.x86_64
but any version suitable for RHEL-7  would do.
Thanks!

Comment 11 Ondrej 2019-08-21 06:54:32 UTC
I am bit worried about the fix implementation.
Imagine situation:
sssd.conf:
[sssd]
  ...
  domains = example.com

[domain/example.com]
  ...
  id_provider = ad
  ldap_user_name = uid # Let's honor RFC2307, but if we use sAMAccountName, it would be the same situation

Now, let's have 2 users:
A:
  UPN = user1
  uid = usrlinux

B:
  UPN = user2
  uid = user1

Now, which result is "sssctl user-checks user1" going to return?
I think the Dbus API (by a bare minimum) needs to be extended by some other function like GetUserByUPN or something like that.

Or am I missing something?

Comment 12 Pavel Březina 2019-08-21 09:56:19 UTC
SSSD first looks up user by username (uid in your case), if it is not found and it is fully qualified name, it will try to search by UPN. So in your example, it will return uid=user1.

Comment 13 Pavel Březina 2019-08-21 10:10:10 UTC
Here is the test build: https://pbrezina.fedorapeople.org/scratch/1736110/

Comment 14 Ondrej 2019-08-21 16:18:16 UTC
(In reply to Pavel Březina from comment #12)
> SSSD first looks up user by username (uid in your case), if it is not found
> and it is fully qualified name, it will try to search by UPN. So in your
> example, it will return uid=user1.

Ok, that means that if we hit a situation as per the example above (and the "A" authenticates via mod_auth_gssapi for example), then the mod_lookup_identity might return wrong identity (i.e. user "B") - correct?

Comment 15 Pavel Březina 2019-09-02 09:35:21 UTC
Yes. Sumit, is there anything we can do about it?

Comment 16 Sumit Bose 2019-09-02 10:31:30 UTC
Hi,

I think currently there is no way other than choosing the LDAP attributes so that there is no such conflict. A GetUserByUPN as suggested would help here, but it should not be used by mod_auth_identity but better by SSSD's localauth plugin for MIT Kerberos so that mod_auth_gssapi can properly use 'GssapiLocalName on' to translate the principal to a local name. I think it would be worth to track such RFE in a separate ticket.

Btw, I think there will be no issue with AD because even as in the example the UPN is set to 'user1' the canonical principal in the Kerberos ticket and hence the one see by mod_auth_gssapi should be the one based on sAMAccountName 'usrlinux'.

bye,
Sumit

Comment 17 Ondrej 2019-09-02 13:42:32 UTC
Phew, that's weird, but I confirm that changing UPN attribute of the user has no effect to the Kerberos tickets generated by AD - they are still based on (as per the Sumit's comment above) the sAMAccountName.
If it is really true, then:
1. I am lucky because it does not affect my business (we have uid == sAMAccountName for real user accounts)
2. I still think the issue outlined here (i.e. situations where uid != sAMAccountName && RFC2307 being used) should be addressed somehow, but if you don't want to fix it, I am fine for this bug to be closed as won't fix

Ondrej

Comment 18 Sumit Bose 2019-09-02 14:02:16 UTC
Hi,

good to hear that due to Kerberos canonicalization helps to get around the issue.

Nevertheless we should use this ticket to track Pavel's fix. Additionally it would be nice if you can open a RFE to add the 'GetUserByUPN' functionality.

bye,
Sumit

Comment 20 Pavel Březina 2019-09-12 07:45:39 UTC
* `master`
    * 18611d70e2916138103a099d45861252d6323366 - ifp: let cache_req parse input name so it can fallback to upn search

Comment 21 Pavel Březina 2019-09-20 08:29:53 UTC
* `sssd-1-16`
    * cc7b9366fe7969edbc5694c6b6557d49567abb0d - ifp: call tevent_req_post in case of error in ifp_user_get_attr_send
    * c097e2b913f0ca7091bc1f9aa95af8c987bc7e7a - ifp: let cache_req parse input name so it can fallback to upn search

Comment 27 Madhuri 2020-05-28 11:50:07 UTC
Reproduce with 
[root@ci-vm-10-0-154-131 ~]# rpm -qa sssd
sssd-1.16.4-37.el7_8.3.x86_64

1. Configure sssd with AD

2. Set  UPN using the following command on the AD server
Set-ADUser -UserPrincipalName abc -Identity adtestuser1

2. Run 
[root@ci-vm-10-0-154-131 ~]# dbus-send --print-reply --system --dest=org.freedesktop.sssd.infopipe /org/freedesktop/sssd/infopipe org.freedesktop.sssd.infopipe.GetUserAttr string:abc array:string:name
Error org.freedesktop.DBus.Error.Failed: Failed to read user attribute

Update sssd to latest,

[root@ci-vm-10-0-154-131 ~]# rpm -qa sssd
sssd-1.16.5-7.el7.x86_64

3. Run the command again

[root@ci-vm-10-0-154-131 ~]#  dbus-send --print-reply --system --dest=org.freedesktop.sssd.infopipe /org/freedesktop/sssd/infopipe org.freedesktop.sssd.infopipe.GetUserAttr string:abc array:string:name
method return time=1590666131.469439 sender=:1.138 -> destination=:1.137 serial=5 reply_serial=2
   array [
      dict entry(
         string "name"
         variant             array [
               string "adtestuser1"
            ]
      )
   ]

Username found in after upgrade,
thus from above marking this as verified.

Comment 29 errata-xmlrpc 2020-09-29 19:49:11 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 (sssd bug fix and enhancement update), 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:3904


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