Submitted by ladboy233
Note: This audit was preceded by a Code4rena Test Coverage competition. While auditing was not the purpose of the testing phase, relevant and valuable findings reported during that phase were eligible to be judged. This finding [H-07] was discovered during that period and is being included here for completeness.
Users claim and sync_lender will be griefed at low cost.
These two functions lack access control, the caller is never validated, meaning anyone can call this function.
The market is not validated to see if the market is whitelisted or not.
The timestamp is never validated, the is_valid_epoch(_forwardTimestampLimit) is insufficient.
The user can just pick a past timestamp as the _forwardTimestampLimit.
For example, if we set _forwardTimestampLimit to 0.
Then for example in _checkpoint_market
We set the lendingMarketTotalBalanceEpoch[_market] to 0.
Then if the next call of the _checkpoint_market, the for loop would never run because the lastMarketUpdateEpoch is 0.
Over time, even when the for loop inside _checkpoint_market does run, the caller are forced to pay very high gas fee.
Same issue applies to _checkpoint_lender as well.
User can decrease lendingMarketBalancesEpoch, even to 0.
Basically, if a malicious actor call these two function with forwardTimestampLimit 0.
Then the _checkpoint_lender and _checkpointmarket would never run inside sync\ledger and claim reward.
Because users reward can be griefed to 0 and stated are failed to updated properly.
POC 1:
If we run the POC, we get the normal result, user can claim and get 6 ETH as reward.
If we uncomment:
The claimed reward goes to 0.
Add access control to checkpoint_market and checkpoint_lender.
OpenCoreCH (veRWA) confirmed and commented:
