Badger eBTC Audit + Certora Formal Verification Competition - OMEN's results

Use stETH to borrow Bitcoin with 0% fees | The only smart contract based #BTC.

General Information

Platform: Code4rena

Start Date: 24/10/2023

Pot Size: $149,725 USDC

Total HM: 7

Participants: 52

Period: 21 days

Judge: ronnyx2017

Total Solo HM: 2

Id: 300

League: ETH

eBTC Protocol

Findings Distribution

Researcher Performance

Rank: 29/52

Findings: 1

Award: $117.51

QA:
grade-a

🌟 Selected for report: 0

πŸš€ Solo Findings: 0

Awards

117.508 USDC - $117.51

Labels

bug
disagree with severity
downgraded by judge
grade-a
QA (Quality Assurance)
insufficient quality report
Q-16

External Links

Lines of code

https://github.com/code-423n4/2023-10-badger/blob/f2f2e2cf9965a1020661d179af46cb49e993cb7e/packages/contracts/contracts/PriceFeed.sol#L445-L463

Vulnerability details

Impact

wrong calculation in chainlinkPriceChangeMax leads to be unfair

Proof of Concept

function _chainlinkPriceChangeAboveMax( ChainlinkResponse memory _currentResponse, ChainlinkResponse memory _prevResponse ) internal pure returns (bool) { uint256 minPrice = EbtcMath._min(_currentResponse.answer, _prevResponse.answer); uint256 maxPrice = EbtcMath._max(_currentResponse.answer, _prevResponse.answer); /* * Use the larger price as the denominator: * - If price decreased, the percentage deviation is in relation to the the previous price. * - If price increased, the percentage deviation is in relation to the current price. */ uint256 percentDeviation = maxPrice > 0 ? ((maxPrice - minPrice) * EbtcMath.DECIMAL_PRECISION) / maxPrice : 0; // Return true if price has more than doubled, or more than halved. return percentDeviation > MAX_PRICE_DEVIATION_FROM_PREVIOUS_ROUND; }

calculation will be unfair when price is increased , max price is used in denominator SO percentage will be less than percentage of that when it's decreased . let's say current price is 5000 and prev price is 4000 , percentage will be 1000/5000 = 20 % , when price is dropped 1000 instead of increase , calculation will be 1000/4000= 25%

Tools Used

manual view

user previous price instead of max price

Assessed type

Math

#0 - c4-pre-sort

2023-11-15T10:21:03Z

bytes032 marked the issue as insufficient quality report

#1 - bytes032

2023-11-15T10:21:07Z

Invalid

#2 - c4-sponsor

2023-11-20T12:59:57Z

GalloDaSballo marked the issue as disagree with severity

#3 - GalloDaSballo

2023-11-20T13:00:00Z

Maybe QA

#4 - jhsagd76

2023-11-25T13:07:52Z

valid, but why high? max change cap from 50% -> 40% means nothing

#5 - c4-judge

2023-11-25T13:08:06Z

jhsagd76 changed the severity to QA (Quality Assurance)

#6 - c4-judge

2023-11-25T13:08:41Z

jhsagd76 marked the issue as grade-b

#7 - c4-judge

2023-11-28T09:40:34Z

jhsagd76 marked the issue as grade-a

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