Skip to content

EIP2 check#1700

Closed
Dinonard wants to merge 2 commits intopolkadot-evm:masterfrom
Dinonard:feat/eip2-check
Closed

EIP2 check#1700
Dinonard wants to merge 2 commits intopolkadot-evm:masterfrom
Dinonard:feat/eip2-check

Conversation

@Dinonard
Copy link
Copy Markdown
Contributor

@Dinonard Dinonard commented Jul 1, 2025

Description

Add a missing check EIP2 related check to the pallet-frontier's signature recovery.

@Dinonard Dinonard requested a review from sorpaas as a code owner July 1, 2025 13:03
fn recover_signer(transaction: &Transaction) -> Option<H160> {
// EIP-2 related
// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-2.md#specification
const SECP256K1N_HALF: H256 = H256([
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding some more context:

Suggested change
const SECP256K1N_HALF: H256 = H256([
/// The order of the secp256k1 curve, divided by two.
///
/// Signatures that should be checked according to EIP-2 should have an S value less than or equal to this:
///
/// `57896044618658097711785492504343953926418782139537452191302581570759080747168`
const SECP256K1N_HALF: H256 = H256([

Copy link
Copy Markdown
Collaborator

@RomarQ RomarQ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member

@sorpaas sorpaas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't necessary. The check happens in TransactionSignature in the ethereum crate. https://github.com/rust-ethereum/ethereum/blob/master/src/transaction/legacy.rs#L103

We already make sure the signature is valid when decoding the value.

But like @RomarQ said, it would be really great to add more docs/tests on this.

@sorpaas
Copy link
Copy Markdown
Member

sorpaas commented Jul 1, 2025

I think the issue is the EIP-7702 implementation? It doesn't seem to be using TransactionSignature type but just raw values.

@sorpaas
Copy link
Copy Markdown
Member

sorpaas commented Jul 1, 2025

Ah, and EIP-1559 and EIP-2930. Only the legacy transaction type is implemented correctly!

@sorpaas
Copy link
Copy Markdown
Member

sorpaas commented Jul 1, 2025

I'll take over the fixes (it needs to happen on ethereum crate but not here). I'll also issue a security advisory because it's a specification deviation.

  • Low severity for Frontier, because signature malleability itself is not actually a security issue. The advise is simply to upgrade the runtime following normal schedule.
  • High severity for Ethereum ecosystem for those who use the ethereum crate, because it's a specification deviation.

@sorpaas
Copy link
Copy Markdown
Member

sorpaas commented Jul 1, 2025

See rust-ethereum/ethereum#67

@Dinonard
Copy link
Copy Markdown
Contributor Author

Dinonard commented Jul 2, 2025

Thank you.
I'll close the PR since it'll be handled in the ethereum crate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants