Part 2

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

Missing Input Validation for Zero Address in `Swap::load` Function

Summary

The function ``Swap::loadlacks validation for a zero address input, which could lead to unexpected behavior when the function is called with the address0x0` (the zero address).

Vulnerability Details

The Swap::load function is designed to load data associated with a specific account by computing a unique storage location using the account address. However, it does not include a check to ensure that the input address is not the zero address (0x0). Calling this function with a zero address could lead to unintended behavior, such as accessing or modifying incorrect storage locations, resulting in data corruption or failures in the contract.

function load(address account) internal pure returns (Data storage swap) {
bytes32 slot = keccak256(abi.encode(SWAP_LOCATION, account));
assembly {
swap.slot := slot
}
}

Impact

Security Risk: Allowing the zero address to be used could expose the contract to attacks, as it may lead to unintentional changes in storage or improper function execution.
Unexpected Behavior: Operations on the zero address could cause unexpected or incorrect data handling, leading to potential contract vulnerabilities.
Data Corruption: Accessing the zero address might overwrite critical data in contract storage, causing data integrity issues.

Tools Used

Manual code inspection

Recommendations

Add a validation check at the beginning of the function to revert if the account address is the zero address:

require(account != address(0), "Invalid account address");

This check would ensure that only valid addresses can be used to load data, preventing any accidental or malicious use of the zero address.

Updates

Lead Judging Commences

inallhonesty Lead Judge 4 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

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