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

Incorrect Hashing Implementation

Summary

Zaros contract fails to implement the EIP712 in several cases.

Vulnerability Details

According to the EIP712 Standard:

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

However, in the function CustomReferralConfiguration(), the hashing process is handled 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 observed, both CUSTOM_REFERRAL_CONFIGURATION_DOMAIN and customReferralCode are string values. The hashing (slot) directly encodes these values instead of using the keccak256 hash of their contents as mandated by the standard.

A similar issue is present in the function Referral
:

>> 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 too, REFERRAL_DOMAIN is a string that is encoded as is.

Impact

Failure to comply with EIP712 can lead to integration issues and potentially cause a denial of service.

Tools Used

Manual Review

Recommendations

Here is the correct implementation:

// CustomReferralConfiguration:load()
- bytes32 slot = keccak256(abi.encode(CUSTOM_REFERRAL_CONFIGURATION_DOMAIN, customReferralCode));
+ bytes32 slot = keccak256(abi.encode(keccak256(CUSTOM_REFERRAL_CONFIGURATION_DOMAIN), keccak256(customReferralCode)));
// Refferal: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.