Closed howlbot-integration[bot] closed 1 month ago
This fundamentally misunderstands what is happening here. secondsRemainingWithPenalty
does not permanently become zero if the current time delta is zero - it just means that interest is only charged as time actually elapses. If the borrower is 30 days past the grace period and then cures their delinquency, waits 15 days and updates the state, they will have incurred penalties for the previous 15 days, and also for the next 15 days.
Invalid: misunderstanding of the code involved
3docSec marked the issue as unsatisfactory: Invalid
Lines of code
https://github.com/code-423n4/2024-08-wildcat/blob/fe746cc0fbedc4447a981a50e6ba4c95f98b9fe1/src/libraries/FeeMath.sol#L121
Vulnerability details
Impact
The penalty APR that is meant to be incurred can potentially be manipulated. In certain scenarios, a borrower or another party could deliberately manipulate the timing of these updates to minimize the penalty.
Description
The
delinquency
penalty retuned can be manipulated potentially by the borrower.The function
updateScaleFactorAndFees
is called within thegetUpdatedState
function to accrue interest and calculate penalties, including the penalty APR, which is applied when a market enters delinquency.The problem, however, lies within the
updateDelinquency
function, where a borrower or another party can manipulate the delinquency penalty. This is because when theupdateTimeDelinquentAndGetPenaltyTime
function returns thetimeWithPenalty
, it uses amin
value calculation, meaning the penalty time will be based on the smallest value betweensecondsRemainingWithPenalty
andtimeDelta
.https://github.com/code-423n4/2024-08-wildcat/blob/fe746cc0fbedc4447a981a50e6ba4c95f98b9fe1/src/libraries/FeeMath.sol#L120C4-L121C66
The issue is that
timeDelta
is the time difference between the last update timestamp and the current timestamp, and this can be manipulated. Consider the following scenario:_writeState
function to update the state and mark the market as no longer delinquent.updateState
shortly after the repayment to ensure thattimeDelta
(the time difference) is less thansecondsRemainingWithPenalty
.By calling the function early, the borrower can reduce the calculated penalty time, thereby manipulating the penalty that would otherwise be applied.
Tools Used
Manual review
Recommended Mitigation Steps
The issue can be mitigated by implementing restrictions on the call to
updateState
, ensuring that it can only be invoked after a set period following any significant protocol interaction, like repayment, borrowing, or similar actions. This would prevent users from calling the function too frequently and manipulating the penalty APR by reducing thetimeDelta
.An additional solution is to make
updateState
an internal function. This will ensures that penalties are applied fairly and consistently based on the actual time elapsed and the borrower’s actions, rather than being subject to user-driven timing exploits.Assessed type
Access Control