Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: secp256k1 public keys with invalid SEC1 tags are accepted #20406

Open
1 task done
tony-iqlusion opened this issue May 15, 2024 · 0 comments
Open
1 task done

[Bug]: secp256k1 public keys with invalid SEC1 tags are accepted #20406

tony-iqlusion opened this issue May 15, 2024 · 0 comments
Labels

Comments

@tony-iqlusion
Copy link
Member

tony-iqlusion commented May 15, 2024

Is there an existing issue for this?

  • I have searched the existing issues

What happened?

Valid secp256k1 public keys are typically 33-bytes long and begin with a SEC1 tag byte: either 0x02 or 0x03 depending on whether the y-coordinate is odd, followed by the big endian serialization of the x-coordinate, which is 32-bytes.

The current point validation logic only checks the length of the public key and does no validation of the SEC1 tag whatsoever: https://github.com/cosmos/cosmos-sdk/blob/b2e8feb/crypto/keys/secp256k1/secp256k1.go#L203-L211

This has lead to chains accepting public keys with invalid SEC1 tags: informalsystems/tendermint-rs#1419 (comment)

Ideally, if it's possible to retrofit improved validation, the SEC1 tag byte would be checked in addition to the length.

The SEC1 tag byte 0x00 can be used to encode the identity point (with the x-coordinate typically omitted for a 1-byte encoding), though it seems these are currently encoded as 33-bytes of 0x00, which is at least a tolerable encoding: informalsystems/tendermint-rs#1417

Cosmos SDK Version

main

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: 📋 Backlog
Development

No branches or pull requests

1 participant