Bug 1653165 - certmap fails when Issuer DN has comma in name
Summary: certmap fails when Issuer DN has comma in name
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: 389-ds-base
Version: 8.0
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: 8.0
Assignee: mreynolds
QA Contact: RHDS QE
URL:
Whiteboard:
Depends On: 1653163
Blocks:
TreeView+ depends on / blocked
 
Reported: 2018-11-26 06:30 UTC by Fraser Tweedale
Modified: 2019-11-23 22:38 UTC (History)
10 users (show)

Fixed In Version: 389-ds-base-1.4.0.20-1.module+el8+2553+e9a4c637
Doc Type: Bug Fix
Doc Text:
Cause: Using a certificate with a subject that has an embedded comma which not properly escaped by the server Consequence: The certificate mapping to a user entry fails Fix: Correct the subject DN processing to properly handle embedded commas. Result: Certificate mapping works even when the subject DN contains commas.
Clone Of: 1653163
Environment:
Last Closed: 2019-06-14 02:03:46 UTC
Type: Bug
Target Upstream Version:


Attachments (Terms of Use)

Comment 1 Fraser Tweedale 2018-11-26 06:34:56 UTC
Patch has been merged to 389-ds-base upstream master (70bdd335d151e58e227fc2263ece9aedc0803152).  Moving to POST.

Comment 3 Viktor Ashirov 2019-02-04 19:53:14 UTC
Hi Fraser,

could you please provide a specific certmap configuration that triggers the failure? I tried your example from the description, but it works on the older build without your fix.

Thanks!

Comment 4 Fraser Tweedale 2019-02-05 03:38:06 UTC
Victor,

I was able to reproduce by running:

  ipa-server-install --subject-base "O=Acme\, Inc.,ST=Massachusetts,C=US"

which resulted in the following certmap.conf contents:

  certmap default         default
  #default:DNComps
  #default:FilterComps    e, uid
  #default:verifycert     on
  #default:CmapLdapAttr   certSubjectDN
  #default:library        <path_to_shared_lib_or_dll>
  #default:InitFn         <Init function's name>
  default:DNComps
  default:FilterComps     uid
  certmap ipaca           CN=Certificate Authority,O=Acme\, Inc.,ST=Massachusetts,C=US
  ipaca:CmapLdapAttr      seeAlso
  ipaca:verifycert        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2SvkmbraVKl7SKxiRwtnHDzOX/jrBXFd+UBihI0d9dErZsBF1qUDyKP/
g0GKfRdhw+JC36w4uDbIG0iTeUTYhn6QBGi1jAnui6k3G8feiAZPISxSCSjAhRXJ
ZQTMmJ6Q0hLk4ygbwcmrYA1idXxsfO9AR9Kxnn+URnXhJzNbBmKvpD7L5Wu0c1hx
0WiLHEzeoAb6p/R8jdG4jWZ9DRYWruj/b5sEZb5QK77cZ5Tl3lwRA5l3aJhy17oT
tc95ePG6IZkXqorjMJmVoOYQH6SU
-----END CERTIFICATE-----

HTH,
Fraser

Comment 5 thierry bordaz 2019-02-05 09:24:07 UTC
Hi Fraser,

Looking at the old version where Viktor ran the successful test I wonder if the testcase may not run into your fix (ldapu_issuer_certinfo)
The certmap_listinfo was defined but empty, so ldapu_issuer_certinfo failed to retrieve a certmap for the issuer and ldapu_cert_to_ldap_entry fall back to a default_certmap_info.
This fallback looks to be good enough to make the testcase successful.

Note, I am not familiar with that part of code and this update may make no sense.

Comment 6 Fraser Tweedale 2019-02-05 10:10:36 UTC
So you really need a CA with a Subject DN that will cause problems, e.g. one with a comma in
one of the attribute values.  There are other ways to trigger a failure but this is the best way.

The bug was due to (sometimes) incorrect parsing of the DN in the certmap file and
(always) incorrect comparison of DNs (i.e. it performed strncmp instead of a proper
DN comparison subroutine).  So to trigger the issue you need a CA certificate with
a subject DN such that the comparison with the DN from the certmap file fails.

Of course if it falls back to the default certmap and the default certmap will work, then
there will not be an authentication failure.

I recommend to test this via IPA, using my instructions above, because that sets everything
up "just right" to trigger the bug (for affected version) and verify the fixed version.
To clarify further, with the affected version, ipa-server-install will fail during CA setup
(one of the later steps, when it imports certificate profiles).

Hope that helps!

Comment 7 Fraser Tweedale 2019-02-05 10:15:28 UTC
See the description of https://pagure.io/freeipa/issue/7347 for a transcript of
what you would see when running ipa-server-install with an affected version of
389, using a subject base DN that would trigger the issue.

Comment 8 Viktor Ashirov 2019-02-05 13:05:03 UTC
Fraser,

I'm using the following command:

# ipa-server-install -a password -p password -r EXAMPLE.COM --subject-base "O=Acme\, Inc.,ST=Massachusetts,C=US" -U

And it fails with:

  [24/28]: migrating certificate profiles to LDAP
  [error] RemoteRetrieveError: Failed to authenticate to CA REST API
Failed to authenticate to CA REST API
The ipa-server-install command failed. See /var/log/ipaserver-install.log for more information

with various versions of ipa-server, pki-base and 389-ds-base on RHEL 7, RHEL 8 and Fedora 29.


The issue you mentioned is still open, and it mentions that the fix should be in multiple components. Is it fixed in every affected component?

Thanks!

Comment 9 Fraser Tweedale 2019-02-05 23:12:19 UTC
Victor, that is the expected failure when 389DS does not include the fix.  Could you please give exact package
versions you encountered this with?

The FreeIPA issue is still open because there is one related certmonger bug, but that bug does not affect
installation, only certificate renewal.

Comment 10 Viktor Ashirov 2019-02-06 20:47:41 UTC
On RHEL8
ipa-server-4.7.1-10.module+el8+2699+aa606a46.x86_64
pki-base-10.6.9-1.module+el8+2694+429d2b2b.noarch
389-ds-base-1.4.0.20-7.module+el8+2750+1f4079fb.x86_64
certmonger-0.79.6-5.el8

On Fedora29:
freeipa-server-4.7.2-1.fc29.x86_64
pki-base-10.6.9-1.fc29.noarch
389-ds-base-1.4.0.21-1.fc29.x86_64
certmonger-0.79.6-3.fc29.x86_64

On Fedora30:
freeipa-server-4.7.2-1.fc30.x86_64
pki-base-10.6.9-1.fc30.noarch
389-ds-base-1.4.1.1-1.fc30.1.x86_64
certmonger-0.79.6-4.fc30.x86_64

Comment 11 Fraser Tweedale 2019-02-07 05:11:55 UTC
Victor, thanks for the details.  Something, somewhere has regressed.  Not sure yet if it's DS
or some other component.  I'm looking into it.

Comment 12 mreynolds 2019-02-07 13:28:23 UTC
(In reply to Fraser Tweedale from comment #11)
> Victor, thanks for the details.  Something, somewhere has regressed.  Not
> sure yet if it's DS
> or some other component.  I'm looking into it.

Well the fix was not correctly applied in rhel 7.6.z, but this was just recently fixed in 389-ds-base-1.3.8.4-23.  But upstream and in RHEL 8 it should be there as the PR was merged upstream.

Comment 13 Fraser Tweedale 2019-02-07 23:32:00 UTC
After preliminary investigation, it seems the regression is in Dogtag or possibly FreeIPA,
not 389.  But it is holding up the testing so feel free to fail QA, or just shelve the testing
for now, until the other issue is fixed.

Comment 14 Fraser Tweedale 2019-02-11 06:39:12 UTC
Quick update: the certmonger issue that I thought was only a problem on renewal, is
a problem during installation as well.  Anyhow I'll find a procedure for verifying
this DS fix indepdently of FreeIPA, and add steps here (tomorrow, most likely).

Comment 15 Viktor Ashirov 2019-02-13 08:49:50 UTC
Thank you Fraser for the investigation!
If you can provide steps to reproduce outside of IPA context, that would great, since we can include this in our regression test suite.

In the meantime I did a build of certmonger with a patch from https://pagure.io/certmonger/pull-request/108 and verified that with this fix IPA server installation completes.

Builds tested:
ipa-server-4.7.1-10.module+el8+2699+aa606a46.x86_64
pki-base-10.6.9-2.module+el8+2728+a4ad6bba.noarch
389-ds-base-1.4.0.20-7.module+el8+2750+1f4079fb.x86_64
certmonger-0.79.6-5.bz1653165.el8.x86_64

Marking as VERIFIED.

Comment 16 Fraser Tweedale 2019-02-13 12:00:59 UTC
Viktor, very nice!  Thank you for taking the initiative.  I put a TODO on my list to develop
the repro steps outside of IPA.  It is far from my highest priority but neither will I
forget about it :)

P.S. I keep writing your name "Victor".  My apologies!


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