The vault performs an unsafe conversion on the getAccountValue result.
The vault's total-assets calculation converts a signed account value into an unsigned integer without checking for negatives. If a sub-operator's account value goes negative before liquidation, the conversion produces an enormous total, so new deposits mint zero shares and the funds are effectively donated to the vault.
- Disclosed after under an hour
#46997 [SC-Medium] The vault performs an unsafe conversion on the getAccountValue result.
Submitted on Jun 7th 2025 at 15:37:52 UTC by @shaflow1 for IOP | Paradex
- Report ID: #46997
- Report Type: Smart Contract
- Report severity: Medium
- Target: https://github.com/tradeparadex/audit-competition-may-2025/tree/main/paraclear
- Impacts:
- Direct theft of any user funds, whether at-rest or in-motion, other than unclaimed yield
- Temporary freezing of funds for at least 1 hour
Description
Brief/Intro
In the _total_assets function, after obtaining the getAccountValue result, an unsafe type conversion is performed. When the system experiences significant asset price volatility causing one of the vault's operators to fall into bad debt (and before liquidation occur), the vault will convert a negative value to u256, resulting in _total_assets becoming abnormally large.
Vulnerability Details
fn getAccountValue(self: @ContractState, account: ContractAddress) -> felt252 {
Self::get_account_value(self, account)
}
fn get_account_value(self: @ContractState, account: ContractAddress) -> felt252 {
let account_state = self._load_account_v2(account);
account_state.account_value().into()
}
fn _total_assets(self: @ContractState) -> u256 {
...
let mut vault_value: u256 = paraclear_dispatcher.getAccountValue(assets_holder).into();
// Skip sub-operators account values if vault is closed
let status = self.status.read();
if status == VaultStatus::Closed {
return self._convert_value_to_usdc(vault_value);
}
...
if sub_operators.len() > 0 {
let mut i = 0;
loop {
if i >= sub_operators.len() {
break;
}
let sub_operator = sub_operators.at(i);
let sub_operator_value: u256 = paraclear_dispatcher
.getAccountValue(*sub_operator)
.into();
vault_value += sub_operator_value;
i += 1;
};
}
...
}
In futures assets, there exist highly volatile meme assets whose prices may fluctuate drastically. Positions could become undercollateralized (bad debt) before liquidation occurs, resulting in negative account values.
At this point, if the getAccountValue function in _total_assets directly converts the felt252 type to u256, it will cause _total_assets to return an extremely large value.
Impact Details
- When users deposit in this abnormal state, since
_total_assetsreturns an extremely large value, any amount of USDC deposited will result in 0 shares minted. The deposited tokens will be effectively lost and donated to the vault. - If the vault has
WITHDRAWAL_MODE_FASTenabled orprofit_share_percentageset, withdrawals will revert due to calculation failures.
The probability of occurrence is low, but it could potentially affect any user deposits, therefore the severity is assessed as Medium.
References
Proof of Concept
Proof of Concept
- A sub-operator in the vault opens a small long position in a meme asset.
- A user then submit the transaction of depositing 10,000 USDC into the vault.
- The meme price plummets, causing the sub-operator's account value to fall below zero (undercollateralized), but liquidation hasn't yet occurred.
- During the user's deposit transaction execution, _total_assets becomes extremely large due to truncation, resulting in the user's shares being rounded down to 0.
- The user loses their deposited funds.
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 code casts a signed felt252 account value straight into u256 without checking whether it is negative, so a negative value wraps to a very large number.
Impact
Deposits made in this state could mint zero shares and be lost to the vault, and withdrawals could revert when fast mode or a profit-share percentage is set; the report notes the probability is low.
What the attacker needed
A sub-operator with an open position; a sharp price drop before liquidation; a user deposits during that window
The fix
The conversion should be made safe, for example by checking the sign of the account value and handling negative values explicitly rather than casting them to an unsigned integer.
How it was found
- A sub-operator opens a small long position in a volatile meme asset.
- A user submits a deposit of 10,000 USDC into the vault.
- The meme price drops so the sub-operator's account value goes negative, before any liquidation.
- During the deposit, the total-assets figure becomes enormous and the user's shares round down to zero.
- The user loses the deposited funds.
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 pools money and gives depositors shares representing their portion. To price a share it adds up the value of everything the vault holds, but it stores that value in a number type that cannot go below zero. If one account is temporarily worth less than nothing, the number wraps around to a huge positive figure, so a new deposit looks tiny and buys no shares.
What is Smart contracts?
Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.