Skip to content
Business logic Audit finding Intermediate

If the counterparty happens to be their own referrer, the protocol does not take the referral fee into account during the risk check.

The protocol's risk check for a trade omits the referral fee that a counterparty may receive when they are also the referrer, so a trade that would be safe after accounting for that fee can be wrongly rejected. An attacker cannot exploit this; it is a correctness issue that may cause valid trades to fail.

shaflow1 Follow

Originally disclosed on Immunefi

Informational View original
  • Disclosed after under an hour

#47318 [SC-Insight] If the counterparty happens to be their own referrer, the protocol does not take the referral fee into account during the risk check.

Submitted on Jun 12th 2025 at 15:04:43 UTC by @shaflow1 for IOP | Paradex

Description

Brief/Intro

Suppose in a trade, the taker's referrer happens to be the maker, or the maker's referrer happens to be the taker. Then at the end of the trade, the taker or maker will receive a referral fee from the counterparty. However, this fee is not considered in the is_risky check, which can cause some otherwise valid trades to fail.

Vulnerability Details

Rust
            let maker_token_balance = *maker_state
                .token_balances
                .at(maker_state.settlement_token_index);
            let taker_token_balance = *taker_state
                .token_balances
                .at(taker_state.settlement_token_index);
            // Note: _fee_payments will also write maker and taker token balance into the storage to
            // include pnl and funding previously calculated
            self
                ._fee_payments(
                    maker_account,
                    @maker_token_balance,
                    maker_trade_fee_in_settlement_token,
                    maker_referrer,
                    maker_fee_commission_in_settlement_token,
                    taker_account,
                    @taker_token_balance,
                    taker_trade_fee_in_settlement_token,
                    taker_referrer,
                    taker_fee_commission_in_settlement_token,
                );

Suppose in a trade, the maker happens to be the taker's referrer. Then, in the fee_payment step, the maker will receive a referral fee from the taker. However, this referral fee is not considered in the earlier is_risky check. Since a potential source of funds is omitted from the check, this may cause a trade that should be executable to be incorrectly rejected.

Impact Details

A trade that could have been executed may become non-executable due to the referral fee being omitted from consideration.

References

https://github.com/tradeparadex/audit-competition-may-2025/blob/0eb81b26a67666c399b4e16b39a96c19848ab7fd/paraclear/src/paraclear/paraclear.cairo#L1911

Proof of Concept

Proof of Concept

  1. In a trade, the taker's referrer is the maker.
  2. The maker is supposed to pay a total fee of fee1, and the taker is supposed to pay fee2. Since the maker is the taker's referrer, the taker needs to pay an additional referral fee fee3 to the maker.
  3. However, in the is_risky check for the maker, the protocol only uses account_value - fee1 - margin_requirement, whereas it should actually use account_value - fee1 + fee3 - margin_requirement.

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

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

Likely the risk check computes the account value using only the trade fee and margin requirement, without adding any referral fee that the account will receive from the counterparty.

Impact

A trade that could have been executed may become non-executable due to the referral fee being omitted from consideration.

What the attacker needed

Taker's referrer is the maker, or vice versa

The fix

The risk check should include the referral fee that the account will receive from the counterparty when computing the account value.

How it was found

  1. In a trade, the taker's referrer is the maker.
  2. The maker pays a trade fee and the taker pays a trade fee plus a referral fee to the maker.
  3. The risk check for the maker ignores the incoming referral fee, so the trade may be rejected.

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 two people trade, one may pay a small referral fee to the other if they were referred by them. The system checks if each trader has enough money to cover the trade, but it forgets to include that incoming referral fee for the person receiving it. So a trade that would actually be affordable gets blocked because the check thinks they have less money than they really will.

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 by shaflow1

View all

14 more disclosed reports, best first.

More from Paradex

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.