Sandclock contest - ACai's results

The Next Generation of Wealth Creation.

General Information

Platform: Code4rena

Start Date: 06/01/2022

Pot Size: $60,000 USDC

Total HM: 20

Participants: 33

Period: 7 days

Judge: LSDan

Total Solo HM: 9

Id: 67

League: ETH

Sandclock

Findings Distribution

Researcher Performance

Rank: 26/33

Findings: 2

Award: $105.91

🌟 Selected for report: 0

🚀 Solo Findings: 0

Findings Information

🌟 Selected for report: danb

Also found by: ACai, WatchPug, cmichel, harleythedog, leastwood, palina, pedroais

Labels

bug
duplicate
2 (Med Risk)

Awards

105.9124 USDC - $105.91

External Links

Handle

ACai

Vulnerability details

Impact

When the Vault contract deposits (all/most) of the token into the strategy contract, so that the remaining tokens in the Vault contract are less than the user's deposit, the user's withdrawal operation will result in a rollback that is not considered by the program.

Proof of Concept

The relevant code for this question is shown below. For ease of reading, the form of pseudocode is used.

totalUnderlyingMinusSponsored() 
= totalUnderlying() - totalSponsored 
= underlying.balanceOf(Vault) + strategy.investedAssets() - totalSponsored 

strategy.investedAssets()
= underlyingBalance + ((exchangeRateFeeder.exchangeRateOf(address(aUstToken), true) * aUstBalance) / 1e18)
= underlyingBalance + balanceOfaUstToUnderlying
= underlying.balanceOf(Strategy) + pendingDeposits + balanceOfaUstToUnderlying

totalUnderlyingMinusSponsored() 
= underlying.balanceOf(Vault) + underlying.balanceOf(Strategy) + pendingDeposits + balanceOfaUstToUnderlying - totalSponsored 

As a simple example, we assume that pendingDeposits, balanceOfaUstToUnderlying, totalSponsored are all 0.

totalUnderlyingMinusSponsored() 
= underlying.balanceOf(Vault) + underlying.balanceOf(Strategy)

We assume that TotalShares is 1000, and TotalPrinciple is 1000 underlying tokens which 200 in Vault contract and 800 in Strategy contract.

While one user withdraws a Deposit NFT which value of 500 underlying tokens via _withdraw function, the Vault contract would call underlying.safeTransfer(_to, amount);. However, Vault contract has not enough token and an unexpected rollback would happend.

This situation is also likely to occur in claimYield function.

Tools Used

#0 - r2moon

2022-01-11T16:08:02Z

AuditHub

A portfolio for auditors, a security profile for protocols, a hub for web3 security.

Built bymalatrax © 2024

Auditors

Browse

Contests

Browse

Get in touch

ContactTwitter