BadgerDAO Zaps contest - gzeon's results

Building Products to Bring BTC to DeFi.

General Information

Platform: Code4rena

Start Date: 14/11/2021

Pot Size: $30,000 USDC

Total HM: 7

Participants: 13

Period: 3 days

Judge: leastwood

Total Solo HM: 4

Id: 57

League: ETH

BadgerDAO

Findings Distribution

Researcher Performance

Rank: 2/13

Findings: 5

Award: $6,483.34

🌟 Selected for report: 5

🚀 Solo Findings: 1

Findings Information

🌟 Selected for report: WatchPug

Also found by: 0x0x0x, Meta0xNull, fatima_naz, gzeon, ksk2345

Labels

bug
duplicate
3 (High Risk)

Awards

925.536 USDC - $925.54

External Links

Handle

gzeon

Vulnerability details

Impact

setGuardian incorrectly set governance in SettToRenIbbtcZap.sol

Proof of Concept

https://github.com/Badger-Finance/badger-ibbtc-utility-zaps/blob/a5c71b72222d84b6414ca0339ed1761dc79fe56e/contracts/SettToRenIbbtcZap.sol#L132

        _onlyGovernance();
        governance = _guardian;
    }```

## Tools Used

## Recommended Mitigation Steps

#0 - GalloDaSballo

2021-11-17T15:09:50Z

Agree, there' s a bunch of duplicates for this, I think #31 #10 and a few more I don't remember

#1 - CloudEllie

2021-11-17T17:35:59Z

Also #25 (potentially), based on the comments I've seen

#2 - 0xleastwood

2021-12-09T12:15:25Z

duplicate of #51

Findings Information

🌟 Selected for report: WatchPug

Also found by: gzeon

Labels

bug
duplicate
2 (Med Risk)

Awards

1269.5967 USDC - $1,269.60

External Links

Handle

gzeon

Vulnerability details

Impact

redeem may return less than minOut if wrong token is supplied with poolID=3 because there is no check against minOut in L230-L232.

Proof of Concept

https://github.com/Badger-Finance/ibbtc/blob/d8b95e8d145eb196ba20033267a9ba43a17be02c/contracts/Zap.sol#L216-L238

  1. User mistakenly call redeem(USDC, 100, 3, 0, 100)
  2. The contract take 100 bBTC from the user, redeem it (L231)
  3. The contract call USDC.balanceOf(address(this)), which return 0 (L236)
  4. The contract send 0 USDC to the user, despite minOut set to 100 The redeemed byvWBTC can be extracted by anyone calling redeem(byvWBTC, 0, 3, 0, 0)

Tools Used

After L230 require(token==byvWBTC, "INVALID_TOKEN"); or After L236 require(out>=minOut, "INSUFFICIENT_OUTPUT");

#0 - GalloDaSballo

2021-11-17T15:11:32Z

Agree with the finding, we will put a slippage check at end of function

Seems to be a dup of #47

#1 - 0xleastwood

2021-12-09T13:03:19Z

duplicate of #47

Findings Information

🌟 Selected for report: gzeon

Also found by: WatchPug

Labels

bug
2 (Med Risk)

Awards

1269.5967 USDC - $1,269.60

External Links

Handle

gzeon

Vulnerability details

Impact

There is no slippage control on deposit of IbbtcVaultZap.sol, which expose user to sandwich attack.

Proof of Concept

https://github.com/Badger-Finance/badger-ibbtc-utility-zaps/blob/6f700995129182fec81b772f97abab9977b46026/contracts/IbbtcVaultZap.sol#L174 Any deposit can be sandwiched, especially when the pool is not balanced.

Tools Used

Add a _minOut in line with the mint function of other contacts, and pass it as a parameter on L174

Findings Information

🌟 Selected for report: gzeon

Labels

bug
2 (Med Risk)

Awards

2821.3259 USDC - $2,821.33

External Links

Handle

gzeon

Vulnerability details

Impact

calcMint in Zap.sol always return poolId=0 and idx=0, while the docstring specified it should return the most optimal route instead. This will lead to suboptimal zap.

Proof of Concept

https://github.com/Badger-Finance/ibbtc/blob/d8b95e8d145eb196ba20033267a9ba43a17be02c/contracts/Zap.sol#L156

Tools Used

#0 - GalloDaSballo

2021-11-17T15:15:48Z

Given the context that the warden has, the finding is valid, we're missing two functions for calcMint

As for us, we have shifted to only using pool 0 as such the code works fine for us

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