Sandclock contest - Ruhum'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: 19/33

Findings: 2

Award: $412.91

🌟 Selected for report: 1

🚀 Solo Findings: 0

Findings Information

🌟 Selected for report: camden

Also found by: Ruhum, WatchPug, cccz, cmichel, danb, defsec, harleythedog, hyh, kenzo, leastwood, palina, pauliax, pmerkleplant, ye0lde

Labels

bug
duplicate
3 (High Risk)

Awards

90.0579 USDC - $90.06

External Links

Handle

Ruhum

Vulnerability details

Impact

When swapping tokens you should include a slippage check. Meaning, if a swap didn't result in a minimum amount of tokens the transaction reverts. The NonUSTStrategy contract uses Curve to swap the underlying token to UST. There, the contract doesn't use any slippage checks and leaves the minimum amount at 0. That makes the contract vulnerable to sandwich attacks.

Proof of Concept

https://github.com/code-423n4/2022-01-sandclock/blob/main/sandclock/contracts/strategy/NonUSTStrategy.sol#L78

https://github.com/code-423n4/2022-01-sandclock/blob/main/sandclock/contracts/strategy/NonUSTStrategy.sol#L94

https://curve.readthedocs.io/factory-pools.html?highlight=exchange%20underlying#StableSwap.exchange_underlying

Tools Used

none

add a reasonable minimum amount or check the amount received and verify that it's an expected amount

#0 - naps62

2022-01-11T18:41:40Z

duplicate of #8

#1 - dmvt

2022-01-27T11:47:44Z

duplicate of #7

Findings Information

🌟 Selected for report: Ruhum

Also found by: Tomio, WatchPug, harleythedog

Labels

bug
2 (Med Risk)
sponsor disputed

Awards

322.8543 USDC - $322.85

External Links

Handle

Ruhum

Vulnerability details

Impact

Some ERC20 tokens charge a fee for every transfer. If the underlying token of a vault is such a token any deposit to the protocol will fail.

Some tokens have the possibility of adding fees later on, e.g. USDT. So those have to be covered too.

Generally, the user would also receive fewer tokens on withdrawing in such a scenario but that's not the protocol's fault.

I rated the issue as medium since part of the protocol become unavailable in such a situation.

Proof of Concept

https://github.com/code-423n4/2022-01-sandclock/blob/main/sandclock/contracts/Vault.sol#L583-L585

_transferAndCheckUnderlying() is used to deposit and sponsor the vault. It checks that after a safeTransferFrom() the same exact amount is sent to the balance of the vault. But, if fees are enabled the values won't match, causing the function to revert. Thus, it won't be able to deposit or sponsor the vault in any way.

https://github.com/code-423n4/2022-01-sandclock/blob/main/sandclock/contracts/Vault.sol#L162

https://github.com/code-423n4/2022-01-sandclock/blob/main/sandclock/contracts/Vault.sol#L266

Tools Used

none

One possibility would be to simply not use ERC20 tokens with fees.

#0 - r2moon

2022-01-11T15:39:46Z

We don't use tokens with fees

#1 - naps62

2022-01-11T18:28:58Z

The only place where we mention USDT is on an old pitch deck (not up to date anymore). The codebase itself doesn't mention it, and all tests are done with USDC and DAI as examples

#2 - dmvt

2022-01-27T22:22:59Z

I'm going to let this issue stand given that #164 is also valid. Supported or not, fee on transfer tokens would cause a loss of funds in the scenario described. As the USDT example shows (in both issues), many stables can be upgraded and add a fee later.

#3 - naps62

2022-02-21T13:27:17Z

There's no action point here, as the recommended steps already match what we're doing:

One possibility would be to simply not use ERC20 tokens with fees.

Therefore closing this

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