Skip to content

Commit 284f1de

Browse files
vm: add s check back to 7702
1 parent 805c441 commit 284f1de

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

packages/vm/src/runTx.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
BIGINT_1,
1010
KECCAK256_NULL,
1111
MAX_UINT64,
12+
SECP256K1_ORDER_DIV_2,
1213
bytesToBigInt,
1314
bytesToHex,
1415
bytesToUnprefixedHex,
@@ -453,9 +454,15 @@ async function _runTx(vm: VM, opts: RunTxOpts): Promise<RunTxResult> {
453454
// EIPs PR: https://github.com/ethereum/EIPs/pull/8938
454455
continue
455456
}
457+
const s = data[5]
458+
if (bytesToBigInt(s) > SECP256K1_ORDER_DIV_2) {
459+
// Malleability protection to avoid "flipping" a valid signature to get
460+
// another valid signature (which yields the same account on `ecrecover`)
461+
// This is invalid, so skip this auth tuple
462+
continue
463+
}
456464
const yParity = bytesToBigInt(data[3])
457465
const r = data[4]
458-
const s = data[5]
459466

460467
const rlpdSignedMessage = RLP.encode([chainId, address, nonce])
461468
const toSign = keccak256(concatBytes(MAGIC, rlpdSignedMessage))

0 commit comments

Comments
 (0)