Skip to content
Smart contracts Audit finding Intermediate

`Vault::_calcDeposit()` will overflow for low priced tokens

The vault's deposit calculation multiplies three 18-decimal values, which can overflow for low-priced tokens and cause deposits to revert. An attacker could exploit this to prevent deposits, making users miss yield and favourable entry prices.

0x73696d616f Follow with armoking32

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2025-02-yieldoor-judging/issues/85

Found by

0x73696d616f, armoking32

Summary

Vault::_calcDeposit() calculates the shares as depositAmount * bal * totalSupply in the numerator. If each of these quantities has 18 decimals, this is 1e54 of precision, having only around 1e23 left. Now, if bal and totalSupply are for example 1e9 each, this leaves 1e5 left. Thus, any deposit exceeding 100_000 will revert. If the token is valued for example 0.01 USD, this is very likely to happen. As deposits failling will make users miss out on yield and favorable entry prices in the pool, it is time sensitive.

Root Cause

In Vault:149, there is an overflow risk.

Internal Pre-conditions

  1. Token is low valued such as 0.1 or 0.01 USD.

External Pre-conditions

None.

Attack Path

  1. User deposits in the vault but reverts, missing out on yield and a certain entry price in the pool.

Impact

User loses yield and may get worse slippage / price afterwards. Additionally, until someone withdraws it may be hard to deposit. They may split their deposits in smaller ones but this has other implications. Given enough balance and supply of a low valued token it may not be possible to deposit at all.

PoC

See above.

Mitigation

Implement some precision downscaling in between calculations.

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

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 multiplication of three 18-decimal values in the share calculation can exceed the maximum integer size, causing an overflow.

Impact

Users cannot deposit and lose yield and favourable entry prices; with enough balance and supply of a low-valued token, deposits may be impossible.

What the attacker needed

Token is low valued such as 0.1 or 0.01 USD

The fix

Implement precision downscaling in intermediate calculations to prevent overflow.

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 smart contract calculates how many shares a user gets when depositing tokens. It multiplies three large numbers together, and if the token is cheap, the result becomes too big for the computer to store, so the deposit fails. This means users cannot deposit and lose out on potential earnings.

What is Smart contracts?

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.

More by 0x73696d616f

View all

172 more disclosed reports, best first.

More from Yieldoor

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Smart contract vulnerabilities

The lesson behind this report.

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.