The vault’s implementation fails to normalize token values based on their specific decimal configurations. It is hardcoded to work with an assumed fixed decimal format (likely 18 decimals), so when a token with another decimal precision (such as 6 decimals) is used, arithmetic operations (e.g., total vault value, user share calculations, and collateral balance adjustments) become inaccurate.
Code Selection for Decimal Mismatch Simulation
To demonstrate the impact of varying token decimals (e.g., USDC with 6 decimals vs. DAI with 18 decimals), I extracted key calculations from the PerpetualVault contract. These calculations play a crucial role in deposit, withdrawal, and vault valuation logic. By recreating these specific computations in a controlled environment, I was able to observe discrepancies caused by different decimal formats.
Selected Code
Subtracting Deposited Amount from Index Token Balance
Calculating the Total Value of the Vault in Collateral Tokens
Getting Available Collateral Token Balance for Position Opening
Determining Swap Amount Based on User Shares
Tracking Vault Balance Before Withdrawal
Proof of Code
How to Run - forge test --mp test/PerpetualVault.t.sol --mt test_IncorrectCalculationsWith6And18DecimalTokens --via-ir --rpc-url arbitrum -vv
This vulnerability introduces financial discrepancies in the vault operations. The primary risks include:
Incorrect Share Calculations – Users may receive fewer shares than expected due to improper scaling of balances.
Misrepresented Vault Value – The total vault value may be significantly skewed depending on the token's decimal format.
Incorrect Deposits & Withdrawals – Users could withdraw more or less than their fair share of funds, leading to loss of funds or unfair advantages.
Potential Exploitation – Malicious actors could strategically deposit low-decimal tokens to manipulate share distribution and extract an unfair portion of assets.
Manual Analysis
To resolve the decimal mismatch issue, the following fixes should be implemented:
Normalize Token Decimals Before Performing Arithmetic
Modify the contract to retrieve each token's decimal value using IERC20.decimals() and adjust calculations accordingly:
This ensures that all calculations are performed in a consistent format.
Use a Standardized Unit for Vault Calculations
Instead of performing calculations in raw token units, introduce a unified precision unit (e.g., 18 decimals) to prevent inconsistencies:
Audit All Deposits, Withdrawals, and Vault Value Calculations
Ensure that every function handling collateral token balances, shares, and vault value is updated to accommodate different decimal values.
There is no real proof, concrete root cause, specific impact, or enough details in those submissions. Examples include: "It could happen" without specifying when, "If this impossible case happens," "Unexpected behavior," etc. Make a Proof of Concept (PoC) using external functions and realistic parameters. Do not test only the internal function where you think you found something.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.