Badger-Vested-Aura contest - dipp's results

Bringing BTC to DeFi

General Information

Platform: Code4rena

Start Date: 15/06/2022

Pot Size: $30,000 USDC

Total HM: 5

Participants: 55

Period: 3 days

Judge: Jack the Pug

Id: 138

League: ETH

BadgerDAO

Findings Distribution

Researcher Performance

Rank: 16/55

Findings: 1

Award: $235.59

🌟 Selected for report: 0

🚀 Solo Findings: 0

Findings Information

🌟 Selected for report: scaraven

Also found by: GimelSec, berndartmueller, cccz, dipp, kenzo, kirk-baird, unforgiven

Labels

bug
duplicate
2 (Med Risk)
sponsor confirmed
valid

Awards

235.5937 USDC - $235.59

External Links

Lines of code

MyStrategy.sol#L405-L413 BaseStrategy.sol#L346-L353 Vault.sol#L396-L415

Vulnerability details

Impact

In MyStrategy.sol, when claiming bribes or sweeping reward tokens, the _handleRewardTransfer function is called which calls _sendToBadgerTree to send the amount of BADGER in the contract to the BADGER_TREE. However, the _processExtraToken (in BaseStrategy.sol) called after the transfer to BADGER_TREE will attempt to transfer the same amount of BADGER to the vault.

This leads to the sweepRewardToken, sweepRewards and claimBribesFromHiddenHand functions not working properly if BADGER is claimed.

Proof of Concept

The tests do not consider when the contract contains BADGER tokens, so the BADGER token should be added in the conftest.py test file.

Test code added to conftest.py:

@pytest.fixture def badger(deployer): TOKEN_ADDRESS = BADGER token = interface.IERC20Detailed(TOKEN_ADDRESS) BADGER_WHALE = accounts.at(BADGER_WHALE_ADDRESS, force=True) ## Address with tons of token token.transfer(deployer, token.balanceOf(BADGER_WHALE), {"from": BADGER_WHALE}) return token

BADGER tokens should then be sent to the strategy contract and an attempt to sweep the BADGER should fail.

Test code added to test_custom.py:

def test_sweep_BADGER(badger, strategy, strategist, deployer): badger.transfer(strategy, badger.balanceOf(deployer), {"from": deployer}) # test the strategy has BADGER tokens assert badger.balanceOf(strategy) > 0 # test that sweep reverts with brownie.reverts(): strategy.sweepRewards([badger], {"from": strategist}) # sanity check the sweep was unsuccessful assert badger.balanceOf(strategy) > 0

The purpose of the _processExtraToken function in BaseStrategy.sol seems to be to forward the extra token (BADGER) to the BADGER_TREE and to process fees. This should mean that the transfer to BADGER_TREE in _sendBadgerToTree is not necessary and can be removed.

#0 - GalloDaSballo

2022-06-18T23:12:28Z

This is a basic developer oversight, I agree with the finding

#1 - GalloDaSballo

2022-07-13T22:31:58Z

Maybe Dup of M-02 @jack-the-pug

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