Skip to content
Business logic Audit finding Intermediate

Liquidation reward sent to msg.sender instead of recipient

The liquidation function sent the liquidator's reward to the caller's address rather than the recipient address supplied in the parameters. An attacker could direct rewards to themselves instead of the intended recipient, breaking any external logic that depends on the recipient receiving the funds.

Giorgio Follow with thank_you

Originally disclosed on Code4rena

Submitted by Giorgio, also found by thank_you

https://github.com/code-423n4/2024-03-revert-lend/blob/435b054f9ad2404173f36f0f74a5096c894b12b7/src/V3Vault.sol#L1078-L1080

Vulnerability details

When performing liquidation the liquidator will fill the LiquidateParams containing the liquidation details. The issue here is that instead of sending the liquidation rewards to the LiquidateParams.recipient, the rewards will be sent to msg.sender.

Impact

The liquidation rewards will be sent to msg.sender instead of the recipient, any external logic that relies on the fact that the liquidation rewards will be sent to recipient won’t hold; this will influence the protocol’s composability.

Proof of Concept

In order to keep the system safe the liquidator can and is incentivised to liquidate unhealthy positions. To do so the liquidate() function will be fired with the appropriate parameters. One of those parameters is the address recipient;; the name is quite intuitive for this one, this is where the liquidation rewards are expected to sent.

But if we follow the liquidation() function logic, the rewards will not be sent to recipient address. This piece of code handles the reward distribution.

(amount0, amount1) =
            _sendPositionValue(params.tokenId, state.liquidationValue,
@>  state.fullValue, state.feeValue, msg.sender);

We can see that msg.sender is being used instead of params.recipient.

Recommended Mitigation Steps

The mitigation is straight forward. Use params.recipient instead of msg.sender for that specific call.

     (amount0, amount1) =
            _sendPositionValue(params.tokenId, state.liquidationValue,
 --    state.fullValue, state.feeValue, msg.sender);
 ++    state.fullValue, state.feeValue, params.recipient);

Assessed type

Context

kalinbas (Revert) confirmed

Revert mitigated:

Fixed here.

Status: Mitigation confirmed. Full details in reports from b0g0, thank_you and ktg.


The original report as published on Code4rena, by Giorgio. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

The code passed msg.sender to the reward-sending function instead of the recipient field from the liquidation parameters.

Impact

Liquidation rewards could be sent to the caller rather than the intended recipient, which may break external logic that relies on the recipient receiving the rewards.

What the attacker needed

Ability to call liquidate()

The fix

The code was fixed to use params.recipient instead of msg.sender when sending the liquidation reward.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

In a lending protocol, when someone liquidates an unhealthy loan they earn a reward. The code was supposed to send that reward to an address the caller specifies, but it sent it to whoever called the function instead. This means the reward could go to the wrong person, which matters if other contracts expect the reward to arrive at the specified address.

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.

More from Revert Lend

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.