reject signing certificates not marked for code signing - #648
reject signing certificates not marked for code signing#648Support-itecz wants to merge 1 commit into
Conversation
7cb0871 to
a3bf123
Compare
|
This looks good, but I will want to run some tests against existing signed models, to make sure they can still be verified. Meanwhile, can you solve the conflicts please? |
a3bf123 to
36267a8
Compare
|
Conflicts resolved, rebased onto main. Main picked up its own tests/_signing/certificate_test.py from #649, so I folded the EKU tests into that file instead of keeping two copies; full suite passes locally (203 tests). On the compatibility testing: certs with a codeSigning EKU or with no EKU at all still verify unchanged. The only signatures newly rejected are ones whose cert carries an EKU listing neither codeSigning nor anyExtendedKeyUsage, which is the case the fix targets. |
_verify_certificates treated the digitalSignature key usage bit and a code-signing extended key usage as alternatives, so a certificate whose extended key usage is serverAuth only was accepted as long as digitalSignature was set. A present extended key usage is restrictive per RFC 5280, so a TLS certificate chaining to a trusted root (the default is the certifi bundle) could be used to sign a model that the verifier then accepts. Reject a certificate whose extended key usage lists neither code signing nor anyExtendedKeyUsage, even when the key usage bit is set. Keeping the check in the verifier means every certificate-based verification path is covered without callers validating the chain themselves. Signed-off-by: Itecz Solution <support@itecz.au>
36267a8 to
c1b6c90
Compare
|
Conflicts resolved. Rebased on main and folded my EKU tests into the new tests/_signing/certificate_test.py alongside the SAN pinning ones; full unit suite passes (200). On testing against existing signed models: certificates with no EKU at all are still accepted, only an EKU listing neither codeSigning nor anyExtendedKeyUsage is rejected, and Fulcio-issued leaves carry codeSigning, so already-signed models should verify unchanged. |
Summary
_verify_certificatesdecides a signing certificate is usable when it has the digitalSignature key usage bit or a code-signing extended key usage, treating the two as alternatives. An extended key usage is restrictive when present (RFC 5280 4.2.1.12), so a certificate whose only EKU isserverAuth(an ordinary TLS certificate) is still accepted as long as digitalSignature is set. Because the default trust roots are the certifi bundle, any holder of a publicly trusted TLS certificate can produce a signature this verifier accepts.The fix rejects a certificate whose extended key usage lists neither code signing nor anyExtendedKeyUsage, even when the key usage bit is set. Keeping the check inside the verifier covers every certificate-based verification path without callers validating the chain themselves. Added a regression test that mints a
serverAuth-only leaf under a private root and confirms it is now rejected, along with positive cases for a code-signing leaf and a leaf with no EKU.To reproduce before the fix: build a leaf with
ExtendedKeyUsage([serverAuth])andKeyUsage(digital_signature=True)chaining to a root in the verifier's store, then verify a signature made with its key. Verification passes.Checklist