Wrong repayment amount used in PositionAction::_repay
, forcing users to unexpectedly lose funds
#526
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
edited-by-warden
M-02
primary issue
Highest quality submission among a set of duplicates
🤖_31_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
sufficient quality report
This report is of sufficient quality
Lines of code
https://github.com/code-423n4/2024-07-loopfi/blob/main/src/proxy/PositionAction.sol#L569-L591
Vulnerability details
Impact
PositionAction
allows users to interact with their position in the CDP Vault through a proxy, on top of that it allows users to do certain actions before interacting with the position.An example of this is the
PositionAction::deposit
, which allows users to:This is handled in
PositionAction::_deposit
, where if swap params exist, swap takes place and the returned amount is used when depositing into the position, else the user's specified amount is used.However, in
PositionAction::_repay
, this is not the case, where even if a swap took place, the amount sent to the vault/position is still the one specified by the user, which is wrong and inconsistent with the other functions' API.This can cause unexpected behaviors and reverts when users try to interact with
PositionAction::repay
.Proof of Concept
Add the following in
src/test/integration/IntegrationTestBase.sol
, to create a balancer pool for the underlying token:Add the following POC in
src/test/integration/PositionAction20.t.sol
:Tools Used
Manual review
Recommended Mitigation Steps
Update the moving amount of the underlying token after the swap, and use that value when repaying, which matches the logic in
PositionAction::_deposit
, something similar to the following:Assessed type
Error
The text was updated successfully, but these errors were encountered: