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

unsafe cast from `uint256 timestamp` to `uint40(s.season.timestamp)` without using `safeCast` library

Vulnerability Details

Casting from a larger integer type to a smaller integer type without checking for overflow can result in data loss LibWellMinting::twaDeltaB() function when we try to cast uint256 timestamp to uint40 this not safe without safeCast library

s.season.timestamp is of type uint256, which has a larger range than uint40. If the value of s.season.timestamp is larger than the maximum value that can be represented by uint40, then casting it to uint40 will result in truncation of the value and overflow.

try ICumulativePump(pumps[0].target).readTwaReserves( // @note Reads the current cumulative reserves from the Pump
well,
lastSnapshot,
wellOracleSnapshots[well];
@>> uint40(s.season.timestamp),
pumps[0].data
) returns (uint[] memory twaReserves, bytes memory snapshot) {

Tools Used

Manual Review

Recommendations

To avoid this issue, it is recommended to use a safe casting library, such as SafeCast, to perform the cast safely. SafeCast provides functions for performing safe casts between different integer types, including checking for overflows and underflows.

Updates

Lead Judging Commences

giovannidisiena Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

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