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

Incorrect bit manipulation leads to inaccurate `lastTimestamp` values

Summary

The readLastReserves function in the smart contract has an error in the way it extracts the values of n (number of reserves) and lastTimestamp from the storage slot. This error results in the lastTimestamp containing the n value due to incorrect bit manipulation.

Vulnerability Details

temp := sload(slot)
n := shr(248, temp) // Correctly extracts the first 8 bits as `n`.
lastTimestamp := shr(208, temp) // Incorrectly includes the 8 bits of `n`.

The issue arises because shr(208, temp) shifts the entire 48 first bits right by 208 bits. This includes the first 8 bits of n into the lastTimestamp, which should only contain the subsequent 40 bits.

Impact

The lastTimestamp incorrectly contains bits from n, leading to a inacurate timestamp value.

Tools Used

Manual review

Recommendations

Consider the followin change :

lastTimestamp := shr(216, shl(8, temp))
Updates

Lead Judging Commences

giovannidisiena Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement
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.