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

fix: handle invalid high bits in ECRecover v value #1602

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions frame/evm/precompile/simple/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ impl LinearCostPrecompile for ECRecover {
sig[32..64].copy_from_slice(&input[96..128]); // s
sig[64] = input[63]; // v

// v can only be 27 or 28 on the full 32 bytes value.
// https://github.com/ethereum/go-ethereum/blob/a907d7e81aaeea15d80b2d3209ad8e08e3bf49e0/core/vm/contracts.go#L177
// Check if any high bits are set in v value (bytes 32-62 must be 0)
// and v (byte 63) can only be 27 or 28
if input[32..63] != [0u8; 31] || ![27, 28].contains(&input[63]) {
return Ok((ExitSucceed::Returned, [0u8; 0].to_vec()));
}
Expand Down
Loading