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
Rank: 12/33
Findings: 4
Award: $1,967.05
๐ Selected for report: 1
๐ Solo Findings: 1
90.0579 USDC - $90.06
defsec
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.
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 ); } }
https://curve.readthedocs.io/exchange-pools.html _min_dy: Minimum amount of j to receive
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
90.0579 USDC - $90.06
defsec
The re-entrancy guard is missing on the Eth anchor interaction. The external router interaction can cause to the re-entrancy vulnerability.
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(); }
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
๐ Selected for report: defsec
1771.4916 USDC - $1,771.49
defsec
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.
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
defsec
Open TODOs can point to architecture or programming issues that still need to be resolved. Timestamp in the Vaderpool should be re-evaluated.
https://github.com/code-423n4/2022-01-sandclock/blob/main/sandclock/contracts/vault/Claimers.sol#L33
None
Consider resolving the TODOs before deploying.
#0 - naps62
2022-01-13T19:52:58Z
duplicate of #57
#1 - dmvt
2022-01-28T15:25:02Z
duplicate of #96