Skip to content
Business logic Audit finding Intermediate

Max_withdraw and max_withdraw do not fully consider global restrictions.

The vault's max_deposit and max_withdraw functions do not account for all global restrictions, such as the owner's share balance or paused withdrawals, so they can return non-zero values when deposits or withdrawals are actually disallowed. This can mislead users or integrators relying on these functions.

shaflow1 Follow

Originally disclosed on Immunefi

  • Disclosed after under an hour

#46839 [SC-Low] `max_withdraw` and `max_withdraw` do not fully consider global restrictions.

Submitted on Jun 5th 2025 at 07:49:32 UTC by @shaflow1 for IOP | Paradex

Description

Brief/Intro

The Vault protocol includes max_withdraw and max_deposit functions, which can return the maximum amount currently available for deposit or withdrawal, similar to the implementation in ERC4626. However, these functions do not fully account for global restrictions, which may result in incorrect return values under certain conditions.

Vulnerability Details

Rust
        fn max_deposit(self: @ContractState, receiver: ContractAddress) -> u256 {
            let status = self.status.read();
            if (status == VaultStatus::Closed) {
                return 0;
            }

            if (!self._is_vault_healthy()) {
                return 0;
            }

            let tvl_limit = self.tvl_limit.read();
            if (tvl_limit == 0) {
                return Bounded::<u256>::MAX;
            }

            let current_assets = self._total_assets();
            if (current_assets >= tvl_limit.into()) {
                return 0;
            }

            tvl_limit.into() - current_assets
        }

For the max_deposit function, it does not consider the owner's shares status. If the caller is not the owner and the owner's shares equal zero, the caller is not permitted to deposit. Therefore, max_deposit should return 0 in this case.

Rust
        fn max_withdraw(self: @ContractState, receiver: ContractAddress) -> u256 {
            if (!self._is_vault_healthy()) {
                return 0;
            }
            let shares = self.erc20.balance_of(receiver);
            let assets = self._convert_to_assets(shares);

            let status = self.status.read();
            if (status != VaultStatus::Closed) {
                let average_deposit_time = self.asset_weighted_time.read(receiver);
                let current_time = get_block_timestamp();
                let holding_time = current_time.into() - average_deposit_time;
                let min_lockup = self.lockup_period_seconds().try_into().unwrap();
                if (holding_time < min_lockup) {
                    return 0;
                }
            }
            assets
        }

For the max_withdraw function, it does not check whether the registry has paused withdrawals. If withdrawals are paused, the function should return 0 since no withdrawals are allowed in this case. Moreover, it fails to account for the existence of pending orders of operator/sub operator, which could cause the transfer to revert.

Impact Details

When called by users or integrated with other projects, it may return misleading values and does not comply with EIP-4626.

References

https://github.com/tradeparadex/audit-competition-may-2025/blob/0eb81b26a67666c399b4e16b39a96c19848ab7fd/vaults/src/vault/vault.cairo#L834 https://github.com/tradeparadex/audit-competition-may-2025/blob/0eb81b26a67666c399b4e16b39a96c19848ab7fd/vaults/src/vault/vault.cairo#L811 https://github.com/tradeparadex/audit-competition-may-2025/blob/0eb81b26a67666c399b4e16b39a96c19848ab7fd/vaults/src/vault/vault.cairo#L584 https://github.com/tradeparadex/audit-competition-may-2025/blob/0eb81b26a67666c399b4e16b39a96c19848ab7fd/vaults/src/vault/vault.cairo#L487

Proof of Concept

Proof of Concept

For example:

  1. The registry has enabled all_vault_withdrawals_paused.
  2. When a user calls max_withdraw, the function fails to consider this restriction and does not return 0 as required. Users may be misled during interactions.

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 max_deposit and max_withdraw functions omit checks for certain global restrictions, such as the owner's share balance or a paused-withdrawals flag, leading to inaccurate return values.

Impact

Users or integrators may receive misleading maximum deposit or withdrawal values, which could lead to failed transactions or incorrect assumptions, though no direct loss of funds is described.

What the attacker needed

Registry can pause withdrawals; caller is not the owner

The fix

The functions should be updated to return zero when global restrictions such as paused withdrawals or zero owner shares apply.

How it was found

  1. The registry enables the all_vault_withdrawals_paused flag.
  2. A user calls max_withdraw.
  3. The function does not consider the pause and returns a non-zero value instead of zero.

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.

A vault is a smart contract that holds funds. It has functions that tell you the maximum you can deposit or withdraw. This report says those functions sometimes give a number greater than zero even when you are not allowed to deposit or withdraw, which could confuse users or other programs that rely on them.

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.