Function Pool.validateOffer()
does not work correctly in case principalAmount > currentBalance
#63
Labels
2 (Med Risk)
Assets not at direct risk, but function/availability of the protocol could be impacted or leak value
bug
Something isn't working
downgraded by judge
Judge downgraded the risk level of this issue
M-04
primary issue
Highest quality submission among a set of duplicates
🤖_21_group
AI based duplicate group recommendation
satisfactory
satisfies C4 submission criteria; eligible for awards
selected for report
This submission will be included/highlighted in the audit report
sponsor confirmed
Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
Lines of code
https://github.com/code-423n4/2024-04-gondi/blob/b9863d73c08fcdd2337dc80a8b5e0917e18b036c/src/lib/pools/Pool.sol#L411
Vulnerability details
Impact
In Pool contract, undeployed funds could be deposited to Aave or Lido to earn base yield. When an offer of Pool is accepted from MultiSourceLoan, the function
validateOffer()
is called to validate the terms and also to pull the undeployed funds back in case the contract balance is insufficient.However, the input params of
reallocate()
are incorrect, resulting in the contract balance might still be insufficient for the loan after calling the function.Proof of Concept
Consider the scenario
currentBalance = 500
,baseRateBalance = 1000 usdc
andprincipalAmount = 700 usdc
.reallocate()
will be called with inputreallocate()
shown in the code snippet below, we can see that in case_currentIdle > _targetIdle
, the contract even deposits more funds to AavePool instead of withdrawing.Tools Used
Manual Review
Recommended Mitigation Steps
Call
reallocate(0, principalAmount - currentBalance, true)
instead.Assessed type
Other
The text was updated successfully, but these errors were encountered: