Sparkn

CodeFox Inc.
DeFiFoundryProxy
15,000 USDC
View results
Submission Details
Severity: low
Valid

The signature does not follow EIP712 and there is no way to revoke a signature.

Summary

The signature does not follow EIP712 and there is no way to revoke a signature.

Vulnerability Details

There is no nonce and EIP712 has a typehash in its signature.
It also says that dynamic types like bytes and string should be keccak256 hashed.
https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct

Impact

  1. If the organizer signed a wrong message, there is no way to revoke the signature.

  2. Other libraries that use EIP712 may not be able to create a proper signature.

Tools Used

Manual review, foundry.

Recommendations

Since the solidity version of the project is 0.8.18, I recommend to use nonces and typehash like OZ v4.8 ERC20Permit.sol
https://github.com/OpenZeppelin/openzeppelin-contracts/blob/release-v4.8/contracts/token/ERC20/extensions/draft-ERC20Permit.sol#L60

I suggest updating ProxyFactory.sol as below.

contract ProxyFactory {
// @audit add typehash and nonces
bytes32 private constant _DISTRIBUTE_TYPEHASH = keccak256("Distribute(uint256 contestId,bytes data,uint256 nonce)");
mapping(address => uint256) private _nonces;
// ...
function deployProxyAndDistributeBySignature(
address organizer,
bytes32 contestId,
address implementation,
bytes calldata signature,
bytes calldata data
) public returns (address) {
// @audit Change this line as below
// - bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(contestId, data)));
bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(_DISTRIBUTE_TYPEHASH, contestId, keccak256(data), _useNonce(organizer))));
// ...
}
// @audit add a way to revoke a signature by incrementing the nonce
function revoke(address organizer, uint256 nonce) public {
require(msg.sender == organizer, "Not organizer");
_nonces[organizer] += 1;
}
// @audit add this function
function _useNonce(address organizer) internal virtual returns (uint256 current) {
uint256 nonce = _nonces[organizer];
current = nonce;
nonce += 1;
}

Support

FAQs

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