Skip to content

Commit 25fdbc7

Browse files
authored
Explicitly only support 65-byte length sigs (#13)
1 parent 9523cc9 commit 25fdbc7

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

src/Paymaster.sol

+2-3
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,8 @@ contract Paymaster is BasePaymaster {
6868
function _validatePaymasterUserOp(UserOperation calldata userOp, bytes32 /*userOpHash*/, uint256 /*requiredPreFund*/)
6969
internal view override returns (bytes memory context, uint256 validationData) {
7070
(uint48 validUntil, uint48 validAfter, bytes calldata signature) = parsePaymasterAndData(userOp.paymasterAndData);
71-
// ECDSA library supports both 64 and 65-byte long signatures.
72-
// we only "require" it here so that the revert reason on invalid signature will be of "Paymaster", and not "ECDSA"
73-
require(signature.length == 64 || signature.length == 65, "Paymaster: invalid signature length in paymasterAndData");
71+
// Only support 65-byte signatures, to avoid potential replay attacks.
72+
require(signature.length == 65, "Paymaster: invalid signature length in paymasterAndData");
7473
bytes32 hash = ECDSA.toEthSignedMessageHash(getHash(userOp, validUntil, validAfter));
7574

7675
// don't revert on signature failure: return SIG_VALIDATION_FAILED

test/Paymaster.t.sol

+3-3
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ contract PaymasterTest is Test {
6464
UserOperation memory userOp = createUserOp();
6565
signUserOp(userOp);
6666

67-
vm.expectRevert(createEncodedValidationResult(false, 57126));
67+
vm.expectRevert(createEncodedValidationResult(false, 57098));
6868
entrypoint.simulateValidation(userOp);
6969
}
7070

@@ -76,7 +76,7 @@ contract PaymasterTest is Test {
7676
userOp.paymasterAndData = abi.encodePacked(address(paymaster), abi.encode(MOCK_VALID_UNTIL, MOCK_VALID_AFTER), r, s, v);
7777
signUserOp(userOp);
7878

79-
vm.expectRevert(createEncodedValidationResult(false, 55126));
79+
vm.expectRevert(createEncodedValidationResult(false, 55098));
8080
entrypoint.simulateValidation(userOp);
8181
}
8282

@@ -86,7 +86,7 @@ contract PaymasterTest is Test {
8686
userOp.paymasterAndData = abi.encodePacked(address(paymaster), abi.encode(MOCK_VALID_UNTIL, MOCK_VALID_AFTER), r, s, v);
8787
signUserOp(userOp);
8888

89-
vm.expectRevert(createEncodedValidationResult(true, 57132));
89+
vm.expectRevert(createEncodedValidationResult(true, 57104));
9090
entrypoint.simulateValidation(userOp);
9191
}
9292

0 commit comments

Comments
 (0)