Hardcoded incorrect getLidoData timestamp, resulting in incorrect base point Apr. Loans can be validated with a substantially low baseRate interest
Submitted by oakcobalt
In LidoEthBaseInterestAllocator.sol, getLidoData is initialized with an incorrect timestamp, causing subsequent baseApr to be incorrect.
In constructor, getLidoData is initialized with 0 timestamp. This should be block.timestamp instead. As a result, baseApr updates will be much lower:
//src/lib/pools/LidoEthBaseInterestAllocator.sol
struct LidoData {
uint96 lastTs;
uint144 shareRate;
uint16 aprBps;
}
...
constructor(
address _pool,
address payable __curvePool,
address payable __weth,
address __lido,
uint256 _currentBaseAprBps,
uint96 _lidoUpdateTolerance
) Owned(tx.origin) {
...
//@audit 0-> block.timestamp
|> getLidoData = LidoData(0, uint144(_currentShareRate()), uint16(_currentBaseAprBps));
...
For example, in _updateLidoValue(), _lidoData.aprBps is calculated based on delta shareRate, divided by delta timespan. (_BPS * _SECONDS_PER_YEAR * (shareRate - _lidoData.shareRate) / _lidoData.shareRate/ (block.timestamp - _lidoData.lastTs)) shareRate and _lidoData.shareRate are associated with current timestamp, and deployment timestamp respectively. But timespan would be (block.timestamp - 0). This deflated _lidoData.aprBps value, which is used to validate Loan offers in Pool.sol during loan initiation.
In PoolOfferHandler.sol, this allows loan offers with substantially low aprBps to pass the minimal apr check.
//src/lib/pools/PoolOfferHandler.sol
function validateOffer(uint256 _baseRate, bytes calldata _offer)
external
view
override
returns (uint256 principalAmount, uint256 aprBps)
{
...
if (offerExecution.offer.aprBps < _baseRate + aprPremium || aprPremium == 0) {
revert InvalidAprError();
}
...
Loans with invalid aprs can be created.
Recommended Mitigation Steps
Use block.timestamp to initialize getLidoData.
Assessed type
Error
0xA5DF (judge) decreased severity to Medium and commented:
Marking as Medium since this only impacts interest and it’s limited to the initial phase of the contract.
Set right value for
getLidoDatatimestamp.
Status: Mitigation confirmed. Full details in reports from oakcobalt, minhquanym and bin2chen.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
What is known
A medium-severity business logic bug in Gondi Invitational. Code4rena made it public on 25 July 2024. Found in the 2024-04-gondi audit contest (finding M-20).
About Business logic
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.