Skip to content

Commit

Permalink
sig malleability detection
Browse files Browse the repository at this point in the history
  • Loading branch information
Filipp Makarov authored and Filipp Makarov committed Nov 8, 2024
1 parent dfc03c3 commit d76cc51
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/ERC7739Validator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@ abstract contract ERC7739Validator {
}
}

// sig malleability prevention
bytes32 s;
assembly {
// same as `s := mload(add(signature, 0x40))` but for calldata
s := calldataload(add(signature.offset, 0x20))
}
if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
return 0xffffffff;
}

bool success = _erc1271IsValidSignatureViaSafeCaller(sender, hash, signature)
|| _erc1271IsValidSignatureViaNestedEIP712(hash, signature)
|| _erc1271IsValidSignatureViaRPC(hash, signature);
Expand Down

0 comments on commit d76cc51

Please sign in to comment.