Part 2

Zaros
PerpetualsDEXFoundrySolidity
70,000 USDC
View results
Submission Details
Severity: low
Valid

Incorrect ERC-7201 standard implementation

Summary

Several local constant values in the leaf libraries do not comply with the ERC-7201 standard. For example, the ASSET_SWAP_STRATEGY_LOCATION constant in the AssetSwapPath library does not comply with the ERC-7201 standard due to incorrect storage slot derivation. This deviation introduces risks of storage collisions and unintended data corruption when interacting with other contracts or libraries that follow the ERC-7201 standard.

Vulnerability Details

ERC-7201 mandates that storage slots must be aligned to 256-byte boundaries by clearing the last byte (via & ~bytes32(uint256(0xff))). However, the current implementation omits this step, resulting in a storage slot that may not align with the standard. For example, the ASSET_SWAP_STRATEGY_LOCATION constant in the AssetSwapPath library does not comply with the ERC-7201 standard

bytes32 internal constant ASSET_SWAP_STRATEGY_LOCATION =
keccak256(abi.encode(uint256(keccak256("fi.zaros.market-making.AssetSwapPath")) - 1));

It lacks & ~bytes32(uint256(0xff))

The same issue exists in Collateral, CreditDelegation , DexSwapStrategy , LiveMarkets , Market , MarketMakingEngineConfiguration , StabilityConfiguration , Swap , UsdTokenSwapConfig , Vault , and WithdrawalRequest .

Reference:

https://eips.ethereum.org/EIPS/eip-7201

Impact

Incorrect ERC-7201 standard implementation will introduce risks of storage collisions and unintended data corruption when interacting with other contracts.

The impact is High, the likelihood is Low, so the severity is Medium.

Tools Used

Manual Review

Recommendations

Consider including the asset into the id and adding & ~bytes32(uint256(0xff)) to ensure the slot aligns with 256-byte boundaries. For example:

function load(address asset) internal pure returns (Data storage assetSwapPath) {
bytes32 name = abi.encodePacked("fi.zaros.market-making.AssetSwapPath.",asset);
bytes32 location = keccak256(abi.encode(uint256(keccak256(name)) - 1)) & ~bytes32(uint256(0xff));
bytes32 slot = location;
assembly {
assetSwapPath.slot := slot
}
}
Updates

Lead Judging Commences

inallhonesty Lead Judge 6 months ago
Submission Judgement Published
Validated
Assigned finding tags:

ERC7201 implemented incorrectly

Support

FAQs

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