Closed Bug 1601035 Opened 5 years ago Closed 5 years ago

new certificate viewer doesn't handle certificates with an AuthorityKeyIdentifier without a keyIdentifier

Categories

(Firefox :: Security, defect, P2)

71 Branch
defect

Tracking

()

VERIFIED FIXED
Firefox 74
Tracking Status
firefox-esr68 --- unaffected
firefox72 --- wontfix
firefox73 --- verified
firefox74 --- verified

People

(Reporter: luke, Assigned: camporter1)

References

(Blocks 1 open bug)

Details

Attachments

(1 file, 1 obsolete file)

User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:71.0) Gecko/20100101 Firefox/71.0

Steps to reproduce:

  1. Visit an HTTPS site with a certificate not issued by a builtin CA, for instance https://mail.tghost.co.uk/.

  2. Try to view the certificate using the new certificate viewer in Firefox 71.

Note 1: The same behaviour happens whether or not the issuer is currently trusted by adding the issuer certificate to the certificate store.

Note 2: Since this stops you viewing the certificate on an "untrusted certificate!" warning page, I consider to be to security flaw.

Actual results:

The about:certificate tab is opened, but it contains:

"Certificate

Something went wrong.

We were unable to find the certificate information, or the certificate is corrupted. Please try again."

Expected results:

The certificate and its issuer should have been shown.

I forgot to add, the address of the about:certificate tab from the example above (https://mail.tghost.co.uk/) looks valid and just like the other sites which work fine:

about:certificate?cert=MIIGdjCCBF6gAwIBAgIBJjANBgkqhkiG9w0BAQsFADB0MQswCQYDVQQGEwJKRTEPMA0GA1UECAwGSmVyc2V5MRUwEwYDVQQKDAx0Z2hvc3QuY28udWsxFTATBgNVBAMMDHRnaG9zdC5jby51azEmMCQGCSqGSIb3DQEJARYXcG9zdG1hc3RlckB0Z2hvc3QuY28udWswHhcNMTkxMTE4MjE1NjAwWhcNMjAxMTE3MjE1NjAwWjBRMQswCQYDVQQGEwJKRTEPMA0GA1UECAwGSmVyc2V5MRUwEwYDVQQKDAx0Z2hvc3QuY28udWsxGjAYBgNVBAMMEW1haWwudGdob3N0LmNvLnVrMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA0CS0dR6hyjv4o6s4%2FI2VT43DCf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fsNX6WryQ4geR786VObcUhKTaofcaX%2FE4J9AVzL864fJ%2FDB%2FPSqhYrtskiG6PT9Ngu20ejvgAVk5aJ%2F%2F5Swsjyg6EBl%2BdwJepq2xzI313ZkwCg2pp6oqLDlxf%2Fh585Bsqke39Ax%2B42NWNM14cethcJ7jgyZoEaL3T%2BQ3O%2Bj9XEe5FbvkKtSgMIA6f0FneA4vbF8%2FECPMEi7k3k04gU1gZSR%2FGA63GPEK%2FCLqeh%2BYVgBGKDPinnMEV%2FuBrTUDQFBlDEHlELk7F9o93lxQNs6WOGQSfybfHhySla3nqoYV2phyeZZsJ%2BxMovWWIydJhVN%2F37v0fYTZhnlquGenXHvC5MHrMq2vjUY0Uy637AzXWVNWveNyQmmn9tL4jygELHQu%2Bint4GRybH7rThcslv63D5s4zZza7cITIFjmqZ%2BPrTSVKL%2BlnQLjEMpSdfB86Y2JnMimaOyv%2BbZp1QMB5fYh0PTsjYATi9We%2BDFD42c5H7Su0vFAwCTP11AiKzfbj2oBKVVwwJj3FmkYQ%3D%3D

That is the correct certificate chain, and OpenSSL will happily decode both of them once split up, URL decoded, and formatted as PEM files.

Bugbug thinks this bug should belong to this component, but please revert this change in case of error.

Component: Untriaged → Security: PSM
Product: Firefox → Core

With a bit of logging added in, I get TypeError: "aKID.keyIdentifier is undefined" from certDecoder.js:225. Looks like RFC 5280 says the keyIdentifier field of AuthorityKeyIdentifier is optional, so we can't rely on it being defined.

Component: Security: PSM → Security
Product: Core → Firefox
Summary: New Certificate Viewer can't show certificates from non-builtin issuers → new certificate viewer doesn't handle certificates with an AuthorityKeyIdentifier without a keyIdentifier
Blocks: cert-viewer
Status: UNCONFIRMED → NEW
Ever confirmed: true
Priority: -- → P2
Attached patch bug_1601035.patch (obsolete) — Splinter Review

I was running into this issue recently, so I took a quick stab at a patch that might help with specific cases where certificates are either missing a keyIdentifier, or are missing extensions altogether. It seems like PKI.js would include the default of an empty array for extensions, but doesn't when returned from toJSON. I'm a newcomer, so feel free to ignore/change the patch.

That patch solves it for me with the few example websites I have tested. Thanks very much.

Flags: needinfo?(jhofmann)

Hi camporter1, thank you for the patch, that seems good to me. Would you like to submit the patch for "proper" review in Phabricator, our code review tool? If so, please follow this set-up guide https://moz-conduit.readthedocs.io/en/latest/phabricator-user.html

If you don't have time for that please let me know and I'll submit it :)

Thanks!

Flags: needinfo?(jhofmann) → needinfo?(camporter1)

When viewing certificates with certificateviewer that have an authority x509 extension
but do not have an authority key identifier, parsing the certificate fails.
Since the authority key identifier is optional in RFC 5280,
check if it exists before trying to set the key identifier.

Also check that x509 extensions are defined before setting up the critical and unsupported extensions.

Hello :johannh, thank you for the info and patience. I've opened a phabricator review, but I'm most likely missing some things on it.

Flags: needinfo?(camporter1) → needinfo?(jhofmann)
Assignee: nobody → camporter1
Status: NEW → ASSIGNED

Thank you for the patch, would you be up for writing a new test that ensures that we're not regressing this again? It should be fairly straightforward, you can take on of the existing tests, e.g. https://searchfox.org/mozilla-central/source/toolkit/components/certviewer/tests/browser/browser_checkOCSP.js and change the about:certficate URL to one that was affected by this bug, then maybe simplify the assertions to only ensure that we're correctly loading the certificate.

The test can go in the same patch or a new patch, as you prefer.

Flags: needinfo?(jhofmann) → needinfo?(camporter1)

(Happy to help if you have any questions)

Updated with tests around the authority key section and making sure that the cert viewer still loads other sections if no authority key is set. Let me know if there's anything that doesn't look right!

Flags: needinfo?(camporter1)
Pushed by jhofmann@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/b7fdc1dd49d6
Check for the key identifier in an authority x509 extension before trying to use it since it is optional for some certificates. Check that there are x509 extensions before trying to get critical or unsupported extensions. r=johannh
Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 74

Comment on attachment 9119561 [details]
Bug 1601035 - Check for the key identifier in an authority x509 extension before trying to use it since it is optional for some certificates. Check that there are x509 extensions before trying to get critical or unsupported extensions.

Beta/Release Uplift Approval Request

  • User impact if declined: about:certificate is not correctly displaying some certificates
  • Is this code covered by automated tests?: Yes
  • Has the fix been verified in Nightly?: Yes
  • Needs manual test from QE?: Yes
  • If yes, steps to reproduce: See comment 0
  • List of other uplifts needed: None
  • Risk to taking this patch: Low
  • Why is the change risky/not risky? (and alternatives if risky): Simple patch that guards on a field being undefined, has tests
  • String changes made/needed: None
Attachment #9119561 - Flags: approval-mozilla-beta?
Flags: qe-verify+
Attachment #9118259 - Attachment is obsolete: true
QA Whiteboard: [qa-triaged]

Comment on attachment 9119561 [details]
Bug 1601035 - Check for the key identifier in an authority x509 extension before trying to use it since it is optional for some certificates. Check that there are x509 extensions before trying to get critical or unsupported extensions.

Fixes some situations where about:certificate shows incorrect information. Approved for 73.0b5.

Attachment #9119561 - Flags: approval-mozilla-beta? → approval-mozilla-beta+

I was able to reproduce this bug using the steps from comment 0, on an affected build (Beta 73.0b4).

The issue is verified as fixed on latest Nightly 74.0a1, Beta 73.0b5 across OSes: Windows 10 x64, macOS 10.13 and Ubuntu 18.04 x64.

Status: RESOLVED → VERIFIED
Flags: qe-verify+

Out of curiosity, why is this marked WONTFIX for firefox72? Isn't this a somewhat serious regression, not being able to verify certificates?

(In reply to Christian Kujau from comment #19)

Out of curiosity, why is this marked WONTFIX for firefox72? Isn't this a somewhat serious regression, not being able to verify certificates?

It only applies to some certificates and 73 is going out to release very soon. This is not worth making a dot release for, in our opinion.

I created my self-signed SSL certificate using default options of openssl, and was hit with this bug. So I would say the "some certificates that are hit with this bug" are actually "most self-signed certificates". And, according to https://wiki.mozilla.org/Release_Management/Calendar Firefox 73 will be released on Feb 11, which is about 20 days from now. Please re-consider shipping the fix sooner. Thanks.

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

Attachment

General

Creator:
Created:
Updated:
Size: