Juicebox V2 contest - 0xDjango'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: 35/105

Findings: 3

Award: $147.60

🌟 Selected for report: 0

🚀 Solo Findings: 0

Awards

14.8726 USDC - $14.87

Labels

bug
duplicate
3 (High Risk)
valid

External Links

Lines of code

https://github.com/jbx-protocol/juice-contracts-v2-code4rena/blob/828bf2f3e719873daa08081cfa0d0a6deaa5ace5/contracts/JBChainlinkV3PriceFeed.sol#L42-L51

Vulnerability details

Impact

Calls to the Chainlink price oracle via latestRoundData() in JBChainlinkV3PriceFeed.sol use the correct function latestRoundData() per Chainlink's documentation, but lack the recommended validations to ensure that the round is complete and does not return stale data.

Per the following Halborn audit, page 19, the recommended implementation is:

( roundId, rawPrice, , updateTime, answeredInRound ) = AggregatorV3Interface(XXXXX).latestRoundData(); require(rawPrice > 0 , "Chainlink price <= 0"); require(updateTime != 0 , "Incomplete round"); require(answeredInRound >= roundId , "Stale price");

Halborn audit, page 19:

https://3405344147-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6bWsvjSvuHlmjaYdDGxA%2Fuploads%2FxvaQXQq7NxRcRQBiGL3J%2FRolla_Finance_Quant_Protocol_Smart_Contract_Security_Audit_Report.pdf?alt=media&token=1d59da93-2e5c-4e53-9de8-a4bb6dba138e

Tools Used

Audit report.

Add checks for stale data, incomplete round, and 0 price return value. If any of these fail, then the function should revert.

#0 - mejango

2022-07-12T18:46:38Z

dup #138

QA Report

[L-01] Should use safeTransfer and safeTransferFrom

To avoid potential fund loss from tokens that do not revert on failure, use safeTransfer.

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

[L-02] Approval pattern will not work with USDC, must approve 0

Tokens like USDT do not allow non-zero to non-zero approvals, so 0 must be approved first.

https://github.com/jbx-protocol/juice-contracts-v2-code4rena/blob/828bf2f3e719873daa08081cfa0d0a6deaa5ace5/contracts/JBERC20PaymentTerminal.sol#L98-L100

[L-03] Anyone can record payments in JBSingleTokenPaymentTerminalStore

Though I don't think there is any incentive, anyone can record payments in JBSingleTokenPaymentTerminalStore.sol. The comments make it sound like this is behind access control but it is not.

https://github.com/jbx-protocol/juice-contracts-v2-code4rena/blob/828bf2f3e719873daa08081cfa0d0a6deaa5ace5/contracts/JBSingleTokenPaymentTerminalStore.sol#L298-L391

[N-01] Typo in "Operator"

https://github.com/jbx-protocol/juice-contracts-v2-code4rena/blob/828bf2f3e719873daa08081cfa0d0a6deaa5ace5/contracts/JBOperatorStore.sol#L102

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