Skip to content

reject non-DNS subjectAltName values in cupsSignCredentialsRequest - #227

Open
tanjiroK-coder wants to merge 1 commit into
OpenPrinting:masterfrom
tanjiroK-coder:sign-csr-san-types
Open

tanjiroK-coder wants to merge 1 commit into
OpenPrinting:masterfrom
tanjiroK-coder:sign-csr-san-types

Conversation

@tanjiroK-coder

Copy link
Copy Markdown
Contributor

cupsSignCredentialsRequest is documented to run every subjectAltName in the request through the SAN callback, but the OpenSSL backend only passes dNSName entries to it and skips every other GeneralName type, then copies the request's subjectAltName extension into the new certificate. A CSR for CN=printer with DNS:printer,IP:192.168.1.1 (or a URI, email address or UPN otherName) is therefore signed by the site CA, and openssl verify -CAfile _site_.crt -verify_ip 192.168.1.1 accepts the result, so anyone who can get a request signed, for example with cups-x509 ca, gets a certificate trusted for addresses and identities the callback never saw, while the same request with DNS:www.example.com is refused. The same loop also stopped validating when an element ran past the extension, accepted an empty dNSName without calling the callback, and validated a dNSName only up to an embedded NUL. I found it reading the SAN loop next to the common name check and confirmed it by signing those CSRs with a _site_ CA built from this tree (LibreSSL 4.0): the IP, URI, email and UPN requests are signed on master and refused with "Bad subjectAltName extension in X.509 certificate request." with this change, while DNS:printer,DNS:printer.local still signs. Since the callback only takes host names, the fix rejects anything that is not a non-empty dNSName without NUL bytes and says so in the function documentation; cupsCreateCredentialsRequest only writes DNS names, so libcups' own requests are unaffected. The GnuTLS loop had the same gap (only GNUTLS_SAN_DNSNAME was checked, and any error or more than 100 entries ended validation). Its certificates do not carry the request extensions today, but I changed it the same way so both backends refuse the same requests.

The new testcreds case signs an embedded CN=altprinter, DNS:altprinter,IP:192.168.1.1 request; it fails on master ("Expected a failure") and passes with this change. I ran testcreds on a Windows/LibreSSL build, where the only other failures are the POSIX key file permission checks, the same before and after. I have not run the GnuTLS build, so that hunk is only compile-checked.

Proposed changelog entry:

  • Fixed cupsSignCredentialsRequest to reject requests with subjectAltName values other than DNS names.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant