Beginner FriendlyFoundry
100 EXP
View results
Submission Details
Severity: high
Valid

Missing check inside _validateSignature if the signature was signed by the owner

Summary

The absence of a check to verify that the owner of the contract is the signer of a transaction in the _validateSignature function introduces a significant vulnerability. This oversight allows any address to forge a signature that appears to come from the owner, potentially leading to unauthorized actions being performed on behalf of the owner.

Vulnerability Details

The _validateSignature function is designed to validate the authenticity of a signature attached to a PackedUserOperation. It does so by hashing the userOpHash and then attempting to recover the signer's address from the signature using the ECDSA.recover function. However, the function does not perform any checks to ensure that the recovered address matches the expected owner of the contract. This means that an attacker could generate a signature that appears to be from the owner but is actually forged, allowing them to bypass the signature validation and potentially execute malicious actions.

Impact

The primary impact of this vulnerability is the potential for unauthorized actions to be performed on the contract. An attacker who can forge a signature could manipulate the contract in ways that the owner did not intend, such as transferring funds, changing contract settings, or executing other actions that require the owner's approval. This could lead to financial loss, loss of control over the contract, or other negative consequences for the owner and users of the contract.

Tools Used

Hardhat

Recommendations

Check if the recoveredAddress matches the owner address

function _validateSignature(PackedUserOperation calldata userOp, bytes32 userOpHash)
internal
returns (uint256 validationData)
{
bytes32 hash = MessageHashUtils.toEthSignedMessageHash(userOpHash);
address recoveredAddress = ECDSA.recover(hash, userOp.signature);
if (recoveredAddress != owner()) {
return SIG_VALIDATION_FAILED;
}
return SIG_VALIDATION_SUCCESS;
}
Updates

Lead Judging Commences

inallhonesty Lead Judge about 1 year ago
Submission Judgement Published
Validated
Assigned finding tags:

ECDSA.recover should check against sender

`_validateSignature` SHOULD return SIG_VALIDATION_FAILED (and not revert) on signature mismatch.

Support

FAQs

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