DeFiHardhat
12,000 USDC
View results
Submission Details
Severity: low
Invalid

Improper storage slot handling leading to data misalignment

Summary

The error involves incorrect slot addressing, leading to potential data misalignment. This is due to the improper handling of storage slot increments based on the index maxI.

Vulnerability Details

The function in question attempts to store data in Ethereum storage slots by incrementing the base slot address with the index maxI directly, without accounting for the 32 byte size of each slot. This leads to misaligned accesses where the add(slot, maxI) operation does not correctly calculate the 32-byte boundary of eth storage slots :

assembly {
sstore(
add(slot, maxI),
add(mload(add(reserves, add(iByte, 32))), shr(128, shl(128, sload(add(slot, maxI)))))
)
}

In the previous block maxI is not scaled by 32.

Impact

This can lead to misaligned data handling where incomplete data is stored

Tools Used

Manual review

Recommendations

Consider the following changes :

assembly {
sstore(
add(slot, mul(maxI, 32)),
add(mload(add(reserves, add(iByte, 32))), shl(128, shr(128, sload(add(slot, mul(maxI, 32))))))
)
}
Updates

Lead Judging Commences

giovannidisiena Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement
Assigned finding tags:

Informational/Invalid

Support

FAQs

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