Sandclock contest - defsec'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: 12/33

Findings: 4

Award: $1,967.05

๐ŸŒŸ Selected for report: 1

๐Ÿš€ Solo Findings: 1

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)
sponsor strategy

Awards

90.0579 USDC - $90.06

External Links

Handle

defsec

Vulnerability details

Impact

Trades can happen at a bad price and lead to receiving fewer tokens than at a fair market price. The attacker's profit is the protocol's loss.

Proof of Concept

The NonUSTStrategy contract is missing slippage checks which can lead to being vulnerable to sandwich attacks.

A common attack in DeFi is the sandwich attack. Upon observing a trade of asset X for asset Y, an attacker frontruns the victim trade by also buying asset Y, lets the victim execute the trade, and then backruns (executes after) the victim by trading back the amount gained in the first trade. Intuitively, one uses the knowledge that someoneโ€™s going to buy an asset, and that this trade will increase its price, to make a profit. The attackerโ€™s plan is to buy this asset cheap, let the victim buy at an increased price, and then sell the received amount again at a higher price afterwards.

See curvePool.exchange_underlying function : https://github.com/code-423n4/2022-01-sandclock/blob/main/sandclock/contracts/strategy/NonUSTStrategy.sol

function _swapUnderlyingToUst() internal { uint256 underlyingBalance = _getUnderlyingBalance(); if (underlyingBalance > 0) { // slither-disable-next-line unused-return curvePool.exchange_underlying( underlyingI, ustI, underlyingBalance, 0 ); } }
  • According curve pool documentation the following parameter shows the minimum return amount of token on the return. On the contract, It is defined as 0.
https://curve.readthedocs.io/exchange-pools.html _min_dy: Minimum amount of j to receive

Tools Used

Code Review

Add minimum return amount checks. Accept a function parameter that can be chosen by the transaction sender, then check that the actually received amount is above this parameter.

Alternatively, check if it's feasible to send these transactions directly to a miner such that they are not visible in the public mempool.

#0 - naps62

2022-01-18T13:26:35Z

duplicate of #7

Findings Information

Awards

90.0579 USDC - $90.06

Labels

bug
duplicate
3 (High Risk)
sponsor strategy

External Links

Handle

defsec

Vulnerability details

Impact

The re-entrancy guard is missing on the Eth anchor interaction. The external router interaction can cause to the re-entrancy vulnerability.

Proof of Concept

  1. Navigate to the following contract.
function finishDepositStable(uint256 idx) external { require(depositOperations.length > idx, "not running"); Operation storage operation = depositOperations[idx]; ethAnchorRouter.finishDepositStable(operation.operator); pendingDeposits -= operation.amount; convertedUst += operation.amount; operation.operator = depositOperations[depositOperations.length - 1] .operator; operation.amount = depositOperations[depositOperations.length - 1] .amount; depositOperations.pop(); }

Tools Used

Code Review

Follow the check effect interaction pattern or put re-entrancy guard.

#0 - naps62

2022-01-18T13:21:57Z

this is a duplicate. can't find the original right now, but there's been a bunch of reports regarding reentrancy overall

#1 - dmvt

2022-01-28T15:46:04Z

duplicate of #3

Findings Information

๐ŸŒŸ Selected for report: defsec

Labels

bug
2 (Med Risk)
sponsor disputed

Awards

1771.4916 USDC - $1,771.49

External Links

Handle

defsec

Vulnerability details

Impact

The Strategy contracts do not appear to support rebasing/deflationary/inflationary tokens whose balance changes during transfers or over time. The necessary checks include at least verifying the amount of tokens transferred to contracts before and after the actual transfer to infer any fees/interest.

Proof of Concept

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

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

Tools Used

Code Review

Make sure token vault accounts for any rebasing/inflation/deflation Add support in contracts for such tokens before accepting user-supplied tokens Consider to check before/after balance on the vault.

#0 - naps62

2022-01-13T20:20:16Z

we did not intend to support those currencies in the first place

#1 - dmvt

2022-01-28T15:42:47Z

As with issues #55 and #164, this oversight can cause a loss of funds and therefor constitutes a medium risk. Simply saying you don't support something does not mean that thing doesn't exist or won't cause a vulnerability in the future.

#2 - naps62

2022-02-16T15:58:46Z

Although technically an issue with some tokens, won't be fixed since our supported tokens do not fall under this category

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