You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Just wanted to ping this bug - Is this something that you're planning to add soon? We're planning to update prod Fulcio soon and I'd like to avoid breaking any clients.
If you want to test against a live instance, staging Fulcio uses embedded SCTs now. It's accessible at fulcio.sigstage.dev, and verification key material is accessible on GCS, gs://tuf-root-staging.
Just wanted to ping this bug - Is this something that you're planning to add soon? We're planning to update prod Fulcio soon and I'd like to avoid breaking any clients.
Yes, we can prioritize it now. @tetsuo-cpp I saw you self-assigned, feel free to pri and I'll take over #62 🙂.
I think I have the necessary changes for cryptography. My issue right now is that the staging Fulcio is signing with an RSA key as opposed to an ECDSA one like prod. I see some changes that went into cosign recently to support different key types so that explains why.
The verify method exposed by cryptography's key types takes different arguments for different key types so it's not possible to just call verify blindly without knowing what kind of key it is. This compared with this.
I think I'm going to follow up with a separate PR for the different key types.
This is unfortunately something I've taken for granted in Go vs. other languages, the cryto.PublicKey abstraction layer. We were previously assuming ECDSA keys in all of the infrastructure, but when staging was set up with an RSA key (which is a valid configuration for a CT log), we removed the remaining assumptions around ECDSA keys.
It's also worth noting that Fulcio accepts ECDSA, RSA, or ED25519 keys in its issued certificates also.
Leaving an update on how this is going. At the moment, I'm trying to put together the digitally signed portion and get SCT verification to pass again.
The less straightforward part of that is that the signing certificate has to be manipulated before being DER encoded. So the CT poison extension has to be removed and I believe the issuer has to be changed (still figuring out why/how this works). The Go equivalent is here.
We'll need to get another change into cryptography in order for this to work. So at the moment, certificates have a property called tbs_certificate_bytes that give the DER encoding of the TBS certificate. But we'll also need a property to access the one with the extension removed, issuer changed, etc. Not sure how easy that will be to get in. The code that does this manipulation to the TBS certificate can't be in our application as it's the Rust internals that have access to this information.
This is just for embedded SCTs, since the precertificate is what's included in the transparency log, and the client has to reconstruct the original merkle tree leaf that was included in the log.
This might be a misreading on my part, but 6962 seems to say that the hash of the issuer's pubkey is adjacent to the TBSCertificate, not embedded within it:
"issuer_key_hash" is the SHA-256 hash of the certificate issuer's
public key, calculated over the DER encoding of the key represented
as SubjectPublicKeyInfo. This is needed to bind the issuer to the
final certificate.
"tbs_certificate" is the DER-encoded TBSCertificate (see [RFC5280])
component of the Precertificate -- that is, without the signature and
the poison extension. If the Precertificate is not signed with the
CA certificate that will issue the final certificate, then the
TBSCertificate also has its issuer changed to that of the CA that
will issue the final certificate. Note that it is also possible to
reconstruct this TBSCertificate from the final certificate by
extracting the TBSCertificate from it and deleting the SCT extension.
Also note that since the TBSCertificate contains an
AlgorithmIdentifier that must match both the Precertificate signature
algorithm and final certificate signature algorithm, they must be
signed with the same algorithm and parameters. If the Precertificate
is issued using a Precertificate Signing Certificate and an Authority
Key Identifier extension is present in the TBSCertificate, the
corresponding extension must also be present in the Precertificate
Signing Certificate -- in this case, the TBSCertificate also has its
Authority Key Identifier changed to match the final issuer.
It's not ready yet, but I've pushed up #84 just for visibility. To my knowledge, I've covered everything but something isn't right.
Again, I'm hitting SCT verification errors so I'm at that stage where I'm poring over the relevant RFCs and comparing with the Go source trying to spot the difference. Will continue fiddling around with this and hopefully figure it out.
Haven't noticed anything wrong with the digitally signed payload yet. Tried fiddling around with the format, tried different certificates in the chain as the issuer, etc... but no luck. At the moment, I'm trying to build a test program that uses certificate-transparency-go so I can compare it to what sigstore-python is assembling.
The TBS certificate is probably the most suspicious part since we're having to do some manipulation on the extensions. So I'm planning to dump the issuing certificate from sigstore-python into a file, get the defanged TBS from the Go libs and then compare it to what we got from cryptography.
I have a Go program using certificate-transparency-go to try to generate the TBS PreCert. I seem to be hitting this line because the PreCert Poison doesn't appear in the extension list. At the very least, this made me realise that I put the Rust code in the wrong spot so I need to fix that too.
If I remove that call, it produces the same DER encoded TBS PreCert as sigstore-python so that's good. I'm assuming that I'm misunderstanding how the Go code works though because I'm assuming that cosign doesn't hit this error. Will investigate more over the weekend.
You'll want to construct the TBS Certificate like in this function - The other function builds the merkle tree leaf from the precertificate before appending to the tree, so it must remove the poison extension. Whereas at this point, you have a valid certificate with an SCT list - The SCT list must be removed.
Activity
Hayden-IO commentedon May 3, 2022
Just wanted to ping this bug - Is this something that you're planning to add soon? We're planning to update prod Fulcio soon and I'd like to avoid breaking any clients.
If you want to test against a live instance, staging Fulcio uses embedded SCTs now. It's accessible at fulcio.sigstage.dev, and verification key material is accessible on GCS, gs://tuf-root-staging.
woodruffw commentedon May 3, 2022
Yes, we can prioritize it now. @tetsuo-cpp I saw you self-assigned, feel free to pri and I'll take over #62 🙂.
woodruffw commentedon May 5, 2022
Blocked on: pyca/cryptography#7198
tetsuo-cpp commentedon May 8, 2022
I think I have the necessary changes for
cryptography. My issue right now is that the staging Fulcio is signing with an RSA key as opposed to an ECDSA one like prod. I see some changes that went intocosignrecently to support different key types so that explains why.The
verifymethod exposed bycryptography's key types takes different arguments for different key types so it's not possible to just callverifyblindly without knowing what kind of key it is. This compared with this.I think I'm going to follow up with a separate PR for the different key types.
Hayden-IO commentedon May 8, 2022
This is unfortunately something I've taken for granted in Go vs. other languages, the
cryto.PublicKeyabstraction layer. We were previously assuming ECDSA keys in all of the infrastructure, but when staging was set up with an RSA key (which is a valid configuration for a CT log), we removed the remaining assumptions around ECDSA keys.It's also worth noting that Fulcio accepts ECDSA, RSA, or ED25519 keys in its issued certificates also.
tetsuo-cpp commentedon May 9, 2022
Leaving an update on how this is going. At the moment, I'm trying to put together the digitally signed portion and get SCT verification to pass again.
The less straightforward part of that is that the signing certificate has to be manipulated before being DER encoded. So the CT poison extension has to be removed and I believe the issuer has to be changed (still figuring out why/how this works). The Go equivalent is here.
We'll need to get another change into
cryptographyin order for this to work. So at the moment, certificates have a property calledtbs_certificate_bytesthat give the DER encoding of the TBS certificate. But we'll also need a property to access the one with the extension removed, issuer changed, etc. Not sure how easy that will be to get in. The code that does this manipulation to the TBS certificate can't be in our application as it's the Rust internals that have access to this information.Hayden-IO commentedon May 9, 2022
For the issuer, this is the key hash of the issuer public key - https://datatracker.ietf.org/doc/html/rfc6962#section-3.2
This is just for embedded SCTs, since the precertificate is what's included in the transparency log, and the client has to reconstruct the original merkle tree leaf that was included in the log.
woodruffw commentedon May 10, 2022
This might be a misreading on my part, but 6962 seems to say that the hash of the issuer's pubkey is adjacent to the TBSCertificate, not embedded within it:
Hayden-IO commentedon May 10, 2022
Yes, it's for rebuilding the merkle tree leaf.
woodruffw commentedon May 10, 2022
Gotcha -- so in that case the TBSCertificate itself doesn't need to have its issuer rewritten, right? It only needs to have its extensions filtered?
Hayden-IO commentedon May 10, 2022
Correct!
tetsuo-cpp commentedon May 11, 2022
It's not ready yet, but I've pushed up #84 just for visibility. To my knowledge, I've covered everything but something isn't right.
Again, I'm hitting SCT verification errors so I'm at that stage where I'm poring over the relevant RFCs and comparing with the Go source trying to spot the difference. Will continue fiddling around with this and hopefully figure it out.
tetsuo-cpp commentedon May 12, 2022
Haven't noticed anything wrong with the digitally signed payload yet. Tried fiddling around with the format, tried different certificates in the chain as the issuer, etc... but no luck. At the moment, I'm trying to build a test program that uses
certificate-transparency-goso I can compare it to whatsigstore-pythonis assembling.The TBS certificate is probably the most suspicious part since we're having to do some manipulation on the extensions. So I'm planning to dump the issuing certificate from
sigstore-pythoninto a file, get the defanged TBS from the Go libs and then compare it to what we got fromcryptography.woodruffw commentedon May 12, 2022
@tetsuo-cpp For debugging, you might
ascii2derandder2asciihelpful as well: https://github.com/google/der-ascii(Thanks to @reaperhulk for showing me these.)
woodruffw commentedon May 16, 2022
The code for this has landed upstream: pyca/cryptography#7207
We just need a release on their side. In the mean time, we can probably use
pip'sgitsupport on the development branch.tetsuo-cpp commentedon May 20, 2022
I have a Go program using
certificate-transparency-goto try to generate the TBS PreCert. I seem to be hitting this line because the PreCert Poison doesn't appear in the extension list. At the very least, this made me realise that I put the Rust code in the wrong spot so I need to fix that too.If I remove that call, it produces the same DER encoded TBS PreCert as
sigstore-pythonso that's good. I'm assuming that I'm misunderstanding how the Go code works though because I'm assuming thatcosigndoesn't hit this error. Will investigate more over the weekend.Hayden-IO commentedon May 20, 2022
You'll want to construct the TBS Certificate like in this function - The other function builds the merkle tree leaf from the precertificate before appending to the tree, so it must remove the poison extension. Whereas at this point, you have a valid certificate with an SCT list - The SCT list must be removed.