Repository navigation
Return an error for non-ECDSA cert in SanitizeX509Cert - #5669
Open
amalsaidov wants to merge 1 commit into
Open
amalsaidov wants to merge 1 commit into
amalsaidov wants to merge 1 commit into
Conversation
SanitizeX509Cert unmarshals the certificate signature as ECDSA and then reads the curve order from the certificate's own public key using an unchecked type assertion to *ecdsa.PublicKey. A certificate can carry an ECDSA signature while its subject public key is of a different type, for example an RSA key signed by an ECDSA CA. The signature unmarshals successfully, execution reaches the assertion, and it panics with "interface conversion: ... not *ecdsa.PublicKey". SanitizeX509Cert and SanitizeIdentity run on consenter and node identities taken from channel configuration in the BFT and cluster paths, so a certificate like this would crash the orderer rather than be rejected. Guard the assertion and return an error, which every caller already propagates. Add tests covering a valid ECDSA certificate, a non-PEM input, and the non-ECDSA public key case that previously panicked. Signed-off-by: amalsaidov <amalsaidov@users.noreply.github.com>
|
Tick the box to add this pull request to the merge queue (same as
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Type of change
Description
SanitizeX509Certnormalizes the ECDSA signature of an identity certificate to a low-S value. It unmarshals the signature as ECDSA and then reads the curve order from the certificate's own public key with an unchecked type assertion:A certificate can carry an ECDSA signature while its subject public key is of a different type, for example an RSA key signed by an ECDSA CA. In that case
UnmarshalECDSASignaturesucceeds on the CA signature, execution reaches the assertion, and it panics:SanitizeX509CertandSanitizeIdentityrun on consenter and node identities taken from channel configuration in the BFT and cluster code paths (orderer/consensus/smartbft,orderer/common/cluster), so an identity like this would crash the orderer instead of being rejected with an error.The fix guards the type assertion and returns an error, which every caller already propagates.
Additional details
Tested with
go test ./common/crypto/....Added
common/crypto/sanitize_test.gocovering:AI-assisted; directed, reviewed and tested by the author (amalsaidov).
Related issues
None.