-
Notifications
You must be signed in to change notification settings - Fork 38
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
Fix certificate validation #86
Conversation
- Remove X509ChainPolicy usage. It was there to avoid CRL lookups, but it caused validation to always fail. Just using X509Certificate2::Verify() just works, even if the CA references an unavailable CRL. - Verify that the LDAP host name matches the certificate CN or one of its SubjectAltName. Failure to do that leaves pGina vulnerable to Man In The Middle setups, where the attacker just use a certificate signed by a valid CA for another machine. Since the Windows stores contain mainy CA, thie setup si quite easy to acheive.
You do verify the Ldap host-name against the certificate DN, but that proofs nothing. I would go this way:
and add your ldap-cert in the local-machine cert-store under personal. |
Indeed an attacker can make up its own CA, and issue a certificate with a CN that matches. But that CA will not be in the trusted certificate store, and hence that rogue certificate will not be validated. I tested this scenario with the code I submitted and it behaves correctly. Or do you suggest an attacked could convince a trusted CA to sign a certificate for a CN in someone else's domain? Indeed this is a possible attack, but a quite rare one, as it is precisely CA's business to take care of what certificate they sign. You suggest adding the LDAP server certificate to the store, but that does not scales very well if there are many clients, and multiple LDAP servers for which certificates changes on expiration time. This approach means constantly updating the stores of many clients, CA were created to avoid that kind of trouble. |
The problem with all that stolen and unverified certs is, it has already happened in the past. You are right there is always a downside to each approach, but the code must work for everyone.
|
Indeed there have been stolen certs, but the CA model is still considered robust enough for online commerce and banking. But that is not the problem here, since my change only tighten certificate validation. I agree software must work for any case, and that tighten checks may annoy someone else., Hence what about adding a configuration option for the extra checks? Something along "check certificate name matches LDAP hostname" I agree I overlooked the wildcard case. I can work on it if that is the only thing that restrains you from merging the change. |
Your approach is appropriate. The option is called verification.... |
Remove X509ChainPolicy usage. It was there to avoid CRL
lookups, but it caused validation to always fail. Just using
X509Certificate2::Verify() just works, even if the CA
references an unavailable CRL.
Verify that the LDAP host name matches the certificate CN or
one of its SubjectAltName. Failure to do that leaves pGina
vulnerable to Man In The Middle setups, where the attacker
just use a certificate signed by a valid CA for another machine.
Since the Windows stores contain mainy CA, this setup is quite
easy to achieve.