Borrowers can avoid the payment of an interest share fee by setting themselves as a fee_receipient
The repay_sol function allows the borrower to specify an arbitrary fee_receipient account, so a borrower can set themselves as the recipient and avoid paying the 20% interest share fee. This deprives the intended fee recipient of the fee.
Arabadzhiev Follow with Arabadzhiev, DadeKuma and 2 others
Originally disclosed on Code4rena
Submitted by Arabadzhiev, also found by Arabadzhiev, DadeKuma, Koolex, and rvierdiiev
src/processor/swapback.rs#L185
src/processor/swapback.rs#L192
src/context/repay_sol.rs#L23
Impact
Borrowers can avoid the payment of the 20% interest share fee on their accumulated interest.
Proof of Concept
The current implementation of the repay_sol function sends a 20% interest share fee to the specified fee_receipient account that is passed in to it. However, as it can be seen, that account is a user specified one:
let transfer_instruction3 = system_instruction::transfer(
&ctx.accounts.trader.key(),
&ctx.accounts.fee_receipient.key(),
interest_share,
);
anchor_lang::solana_program::program::invoke(
&transfer_instruction3,
&[
ctx.accounts.trader.to_account_info(),
ctx.accounts.fee_receipient.to_account_info(),
],
)?;
/// CHECK: We just want the value of this account
#[account(mut)]
pub fee_receipient: UncheckedAccount<'info>,
What this means, is that the user can take advantage of that and avoid the payment of an interest share fee by simply passing in a public key that is controlled by them for that value. It is unclear who exactly is supposed to be the on the receiving end for the fee payment, but what’s important is that that they can easily be easily be prevented from receiving it.
Recommended Mitigation Steps
Apply some restrictions on the fee_receipient public key value. For example, you can make it be a property of the Pool struct that is set on the creation of each new trading pool by its operator.
Assessed type
Invalid Validation
piske-alex (Lavarage) confirmed
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 fee_receipient account is user-supplied and not validated against a trusted pool-configured address.
What the attacker needed
A borrower repaying a loan; ability to pass an arbitrary fee_receipient
The fix
The fee_receipient should be restricted, for example by making it a property of the Pool struct set at pool creation.
How it was found
- Borrower calls repay_sol and passes their own public key as fee_receipient.
- The 20% interest share fee is transferred to the borrower's own account instead of the intended recipient.
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.
When repaying a loan, the code sends a 20% cut of the interest to a fee recipient. But the borrower chooses who that recipient is, so they can just pick their own account and keep the fee. This means the fee never reaches the intended party.
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.