-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
permitted_dns_domain is applied inconsistently #4863
Comments
It should not require a period to indicate subdomains being allowed Fixes #4863
It should not require a period to indicate subdomains being allowed Fixes #4863
Hey @jefferai, thanks so much for the speedy fix! One follow-up comment, if I may: I have unfortunately already generated root CAs that have a Additionally, if I am understanding correctly the current code would validate |
@ericnorris OK so it turns out that the right thing to do is really actually get rid of that function entirely and let the Go standard library do its thing. I modified the code and tests and it turns out -- this works as expected. Which also means that it doesn't actually match against a self-signed root:
The bit about "final certificate in the path" is rather confusing, because it is either always the last certificate in the path (according to standard validation logic), or it is the only certificate in which case it is first and last, but it's unclear then what the difference is. So I'm passing through the values provided, but leaving it up to downstream crypto stacks to interpret exactly what that actually means. This means test cases that failed before don't now because they're actually correct. This does likely mean you'll need to reissue your root, unfortunately. As for validating DNS names for validity, for the moment I'm leaving that up to the operator needing to provide a valid name. |
My tests aren't working as I expect yet, but I did want to comment after doing a dive into Go's built-in code: it looks like it actually applies constraints from both roots and intermediates, and it does use |
OK, more followup. The real issue here is that the earlier code was attempting to reject generation of child certificates that did not meet criteria. But really it's a verification/validation functionality to check the chain, so Vault was kind of going about this backwards. While the functionality Vault had could allow you to know immediately if something you're issuing is invalid, which I think was kind of the point, it also precludes rolling the issuing cert with one that contains new values (with the Key IDs matching). So, Go doesn't constrain these on issuing, and we shouldn't either, because I think that's the right read. Accordingly, this value is going to basically just be a straight pass-through into the Go x509 issuing logic. |
Thanks for following up and being thorough @jefferai! Appreciate it. |
No problem! I want this stuff to work, it can just be hard to grok all the RFCs right :-) (And it doesn't help that often even if you do various crypto stacks behave differently...) |
Describe the bug
When configuring a CA with
permitted_dns_domains
and a domain without a leading.
, Vault will disallow issuing certificates with aCommon Name
field that are subdomains for the domain. It will, however, allow SANs that it doesn't consider valid as aCommon Name
.To Reproduce
Steps to reproduce the behavior:
permitted_dns_domains
ofexample.com
subdomain.example.com
example.com
and a SAN ofsubdomain.example.com
Expected behavior
I expect both steps 2 and 3 should work, but only step 3 does.
Per the RFC:
My reading of this means that when evaluating a DNS name, any leading subdomains are valid. The Vault documentation and tests seem to be using the following from the RFC:
This, however, is for URIs - not DNS names - and so in my opinion is not appropriate for validating DNS names in the CN field. It's entirely possible I'm mistaken, but I'd appreciate the dialogue regardless.
Environment:
0.10.3
The text was updated successfully, but these errors were encountered: