DeFiFoundry
60,000 USDC
View results
Submission Details
Severity: low
Valid

Potential `EIP712` violation in multiple cases

Summary

CustomReferralConfiguration & Refferal contracts do not implement EIP712 correctly.

Vulnerability Details

According to EIP712 Standard:

The dynamic values bytes and string are encoded as a keccak256 hash of their contents.

However, in CustomReferralConfiguration:load(), the hashing is done as follows:

>> string internal constant CUSTOM_REFERRAL_CONFIGURATION_DOMAIN = "fi.zaros.CustomReferralConfiguration";
>> function load(string memory customReferralCode)
internal
pure
returns (Data storage customReferralConfigurationTestnet)
{
>> bytes32 slot = keccak256(abi.encode(CUSTOM_REFERRAL_CONFIGURATION_DOMAIN, customReferralCode));
assembly {
customReferralConfigurationTestnet.slot := slot
}
}

As seen, both CUSTOM_REFERRAL_CONFIGURATION_DOMAIN and customReferralCode are string values. However, the hashing (slot) encodes these values directly and not the keccak256 hash of their contents as required by the standard.

The same is in Referral:load():

>> string internal constant REFERRAL_DOMAIN = "fi.zaros.Referral";
function load(address accountOwner) internal pure returns (Data storage referralTestnet) {
>> bytes32 slot = keccak256(abi.encode(REFERRAL_DOMAIN, accountOwner));
assembly {
referralTestnet.slot := slot
}
}

Here also, REFERRAL_DOMAIN is a string but it is encoded as is.

Impact

Non-compliance with EIP712 can cause problems with integrators and potentially lead to denial of service.

Tools Used

Manual Review

Recommendations

Correct this as follows:

// CustomReferralConfiguration:load()
- bytes32 slot = keccak256(abi.encode(CUSTOM_REFERRAL_CONFIGURATION_DOMAIN, customReferralCode));
+ bytes32 slot = keccak256(abi.encode(keccak256(CUSTOM_REFERRAL_CONFIGURATION_DOMAIN), keccak256(customReferralCode)));
// Referral:load()
- bytes32 slot = keccak256(abi.encode(REFERRAL_DOMAIN, accountOwner));
+ bytes32 slot = keccak256(abi.encode(keccak256(REFERRAL_DOMAIN), accountOwner));
Updates

Lead Judging Commences

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

Storage computation formula of ERC7201 is not followed. ERC7201 non compliance.

Support

FAQs

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