Vader Protocol contest - Reigada's results

Liquidity Protocol anchored by Native Stablecoin with Slip-Based Fees AMM, IL protection and Synthetics.

General Information

Platform: Code4rena

Start Date: 09/11/2021

Pot Size: $75,000 USDC

Total HM: 57

Participants: 27

Period: 7 days

Judge: alcueca

Total Solo HM: 49

Id: 52

League: ETH

Vader Protocol

Findings Distribution

Researcher Performance

Rank: 11/27

Findings: 4

Award: $2,491.12

🌟 Selected for report: 8

🚀 Solo Findings: 2

Findings Information

🌟 Selected for report: Reigada

Labels

bug
3 (High Risk)
sponsor disputed
BasePool

Awards

1619.075 USDC - $1,619.07

External Links

Handle

Reigada

Vulnerability details

Impact

In the contract BasePool the mint function can be frontrun. This will assign the NFT to the attacker which later on he can burn it retrieving the corresponding _nativeAsset and _foreignAsset initially deposited by the frontrun victim. https://github.com/code-423n4/2021-11-vader/blob/main/contracts/dex/pool/BasePool.sol#L149-L194

Proof of Concept

User1 transfers 1000 _nativeAsset tokens and 1000 _foreignAsset tokens into the BasePool contract. User1 calls the BasePool.mint() function to retrieve his NFT. Attacker is constantly polling for an increase of the balance of _nativeAsset and _foreignAsset of the contract OR attacker is constantly scanning the mempool for mint() function calls. Attacker detects an increase of balance of _nativeAsset and _foreignAsset OR attacker detects a mint() function call in the mempool. Attacker frontruns the mint call and retrieves the NFT. Gets a NFT that is worth 1000 _nativeAssets and 1000 _foreignAssets. User1 gets a NFT that is worth 0 _nativeAssets and 0 _foreignAssets. Attacker burns the NFT retrieving the corresponding _nativeAsset and _foreignAsset initially deposited by the victim.

Tools Used

Manual testing

Include in the mint() function the transfer of _nativeAssets and _foreignAssets to the smart contract.

#0 - SamSteinGG

2021-11-25T11:58:14Z

The pool is meant to be utilized via the router or smart contracts and is not meant to be utilized directly. The exact same "flaw" exists in Uniswap V2 whereby if you transfer assets directly someone else can claim them on your behalf.

#1 - alcueca

2021-12-11T06:52:26Z

Ah, so this how you prevent direct access to the pools. The issue is valid due to lack of documentation on the usage of the router.

#2 - SamSteinGG

2021-12-16T12:06:45Z

Firstly, documentation related issues cannot constitute a high risk vulnerability. Secondly, this type of documentation does not exist in Uniswap V2 either. We advise this finding to be set to no risk.

Findings Information

🌟 Selected for report: Reigada

Labels

bug
2 (Med Risk)
sponsor acknowledged
StakingRewards

Awards

485.7225 USDC - $485.72

External Links

Handle

Reigada

Vulnerability details

Impact

In the contract StakingRewards, the stake function assume that the amount of stakingToken is transferred to the smart contract after calling the safeTransferFrom function (and thus it updates the _balances mapping). However, this may not be true if the stakingToken is a transfer-on-fee token or a deflationary/rebasing token, causing the received amount to be less than the accounted amount in the _balances mapping.

Same can be applied for the withdraw function.

Proof of Concept

https://github.com/code-423n4/2021-11-vader/blob/main/contracts/staking-rewards/StakingRewards.sol#L100-L102

Tools Used

Manual code review

Get the actual received amount by calculating the difference of token balance before and after the transfer. For example: uint256 balanceBefore = stakingToken.balanceOf(address(this)); stakingToken.safeTransferFrom(msg.sender, address(this), amount); uint256 receivedAmount = stakingToken.balanceOf(address(this)) - balanceBefore; _totalSupply = _totalSupply.add(receivedAmount); _balances[msg.sender] = _balances[msg.sender].add(receivedAmount);

#0 - 0xstormtrooper

2021-11-15T09:03:30Z

VADER / USDV fee on transfer will be removed

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