HardhatFoundry
30,000 USDC
View results
Submission Details
Severity: medium
Invalid

Signature Malleability in K1Validator Contract

Summary

K1Validator is vulnerable to signature malleability, which allows an attacker to produce multiple valid signatures for the same message. This can cause replay attacks if the system does not properly handle nonces or other mechanisms to ensure the uniqueness of each signature.

Vulnerability Details

The K1Validator contract relies on Solady's SignatureCheckerLib to verify that the signature provided is valid. However, the SignatureCheckerLib does not check if a signature is non-malleable. This means that an attacker can create another valid signature for the same message, potentially bypassing restrictions that rely on the uniqueness of the signature.

ValidateUserOp:

function validateUserOp(PackedUserOperation calldata userOp, bytes32 userOpHash) external view returns (uint256) {
address owner = smartAccountOwners[userOp.sender];
if (
owner.isValidSignatureNow(ECDSA.toEthSignedMessageHash(userOpHash), userOp.signature) ||
owner.isValidSignatureNow(userOpHash, userOp.signature)
) {
return VALIDATION_SUCCESS;
}
return VALIDATION_FAILED;
}

isValidSignatureWithSender:

function isValidSignatureWithSender(address, bytes32 hash, bytes calldata data) external view returns (bytes4) {
address owner = smartAccountOwners[msg.sender];
// Validate the signature using SignatureCheckerLib
if (SignatureCheckerLib.isValidSignatureNowCalldata(owner, hash, data)) {
return ERC1271_MAGICVALUE;
}
if (SignatureCheckerLib.isValidSignatureNowCalldata(owner, MessageHashUtils.toEthSignedMessageHash(hash), data)) {
return ERC1271_MAGICVALUE;
}
return ERC1271_INVALID;
}

Impact

An attacker can create multiple valid signatures for the same message and then bypassing restrictions that rely on the uniqueness of the signature and leading to replay attacks.

Tools Used

Manual review

Recommendations

Add a check to ensure that the s value of the signature is within the valid bounds to avoid signature malleability.
Another way could be to either use the ECSDA lib from Openzeppelin which checks signature malleability or implement a nonce system.

Updates

Lead Judging Commences

0xnevi Lead Judge 11 months ago
Submission Judgement Published
Validated
Assigned finding tags:

finding-replay-attack-malleable

Valid medium, although all issues lack a little detail on some form of protocol specific impact here. See similar reference finding [here](https://github.com/sherlock-audit/2024-04-titles-judging/issues/279)

Appeal created

0xnevi Lead Judge 11 months ago
Submission Judgement Published
Invalidated
Reason: Other
Assigned finding tags:

finding-replay-attack-malleable

Valid medium, although all issues lack a little detail on some form of protocol specific impact here. See similar reference finding [here](https://github.com/sherlock-audit/2024-04-titles-judging/issues/279)

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.