Juicebox V2 contest - Ruhum's results

The decentralized fundraising and treasury protocol.

General Information

Platform: Code4rena

Start Date: 01/07/2022

Pot Size: $75,000 USDC

Total HM: 17

Participants: 105

Period: 7 days

Judge: Jack the Pug

Total Solo HM: 5

Id: 143

League: ETH

Juicebox

Findings Distribution

Researcher Performance

Rank: 19/105

Findings: 3

Award: $799.78

🌟 Selected for report: 0

🚀 Solo Findings: 0

Awards

14.8726 USDC - $14.87

Labels

bug
duplicate
3 (High Risk)
old-submission-method
valid

External Links

Lines of code

https://github.com/jbx-protocol/juice-contracts-v2-code4rena/blob/main/contracts/JBChainlinkV3PriceFeed.sol#L44

Vulnerability details

Impact

Consumers of a Chainlink price feed should always verify that the price they receive is fresh, i.e. submitted recently. Otherwise, your protocol might work with outdated price data.

In the recent incident with Luna/UST, we've seen a protocol that doesn't verify the Chainlink data resulting in them losing ~$11M: https://medium.com/@blizzfinance/blizz-finance-post-mortem-2425a33fe28b

Proof of Concept

The contract only retrieves the price and ignores all the other values:

(, int256 price, , , ) = feed.latestRoundData();

Tools Used

none

Verify that the data is fresh by checking the updatedAt parameter: https://docs.chain.link/docs/price-feeds-api-reference/#latestrounddata

Also, Chainlink recommends consumers be able to pause usage of a specific feed in case the feed is paused: https://docs.chain.link/docs/selecting-data-feeds/#risk-mitigation

#0 - mejango

2022-07-12T18:49:41Z

dup #138

Awards

3.4075 USDC - $3.41

Labels

bug
duplicate
2 (Med Risk)
old-submission-method
valid

External Links

Lines of code

https://github.com/jbx-protocol/juice-contracts-v2-code4rena/blob/main/contracts/JBERC20PaymentTerminal.sol#L88

Vulnerability details

Impact

Some tokens don't follow the ERC20 standard. For example, some don't revert on failure but instead just return false. With your current implementation, you won't catch these cases. Your contract will continue the transaction believing that the transfer was successful. Here's a good repo on that: https://github.com/d-xo/weird-erc20

Because of that, it's recommended to use OpenZeppelin's SafeERC20 library.

Proof of Concept

https://github.com/jbx-protocol/juice-contracts-v2-code4rena/blob/main/contracts/JBERC20PaymentTerminal.sol#L88

Tools Used

none

Use SafeERC20.

#0 - mejango

2022-07-12T18:13:23Z

sup of #281

Findings Information

🌟 Selected for report: berndartmueller

Also found by: 0x52, Ruhum, hyh

Labels

bug
duplicate
2 (Med Risk)
sponsor disputed
old-submission-method
valid

Awards

781.4991 USDC - $781.50

External Links

Lines of code

https://github.com/jbx-protocol/juice-contracts-v2-code4rena/blob/main/contracts/abstract/JBPayoutRedemptionPaymentTerminal.sol#L1451

Vulnerability details

Impact

The fee calculation seems to be wrong. The formula you use is: $x - x * MaxFee / (fee + MaxFee)$. But instead you should use $x * fee / MaxFee$.

Proof of Concept

Using the default values: $x = 100,000,000,000$ $fee = 25,000,000$ $MaxFee = 100,000,000,000$ You take: 100,000,000,000−100,000,000,000∗1,000,000,000/1,025,000,000=2439024390.24100,000,000,000 - 100,000,000,000 * 1,000,000,000 / 1,025,000,000 = 2439024390.24 instead of: 100,000,000,000∗25,000,000/1,000,000,000=2500000000100,000,000,000 * 25,000,000 / 1,000,000,000 = 2500000000

Tools Used

none

Use the other formula to compute the fees:

return PRBMath.mulDiv(_amount, _discountedFee, JBConstants.MAX_FEE);

#0 - mejango

2022-07-12T15:43:29Z

_amount in this case is pre-fee. So an amount of 110 with a 10% fee should result in a fee of 10. 110 - (110 * 1/ 1.1) = 10.

#1 - jack-the-pug

2022-07-24T02:01:22Z

Duplicate of #275

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