Juicebox Buyback Delegate - arpit's results

Thousands of projects use Juicebox to fund, operate, and scale their ideas & communities transparently on Ethereum.

General Information

Platform: Code4rena

Start Date: 18/05/2023

Pot Size: $24,500 USDC

Total HM: 3

Participants: 72

Period: 4 days

Judge: LSDan

Id: 237

League: ETH

Juicebox

Findings Distribution

Researcher Performance

Rank: 61/72

Findings: 1

Award: $16.19

QA:
grade-b

🌟 Selected for report: 0

🚀 Solo Findings: 0

Incorrect authorization check in the 'didPay' function

The bug in the provided code is related to an incorrect authorization check in the didPay function. The original code uses the revert statement to handle unauthorized access, but it should be using the require statement instead.

In the incorrect code: https://github.com/code-423n4/2023-05-juicebox/blob/9a36e5c8d0588f0f262a0cd1c08e34b2184d8f4d/juice-buyback/contracts/JBXBuybackDelegate.sol#L185

if (msg.sender != address(jbxTerminal)) revert JuiceBuyback_Unauthorized();

The condition checks if the msg.sender (the caller of the function) is not equal to the address(jbxTerminal). If the condition evaluates to true, it triggers a revert statement, which reverts the transaction and rolls back any changes made.

However, using revert in this context is not the appropriate way to handle authorization checks. The revert statement is typically used to revert the entire transaction when a condition is not met. In this case, it should be using the require statement, which is specifically designed for authorization checks.

The correct code should be:

require(msg.sender == address(jbxTerminal), "JuiceBuyback_Unauthorized");

The require statement checks if the condition (msg.sender == address(jbxTerminal)) is true. If the condition is false, it will revert the transaction and provide an error message ("JuiceBuyback_Unauthorized").

Using require ensures that the condition for authorization is met, and if not, it immediately halts the execution and reverts the transaction, preventing unauthorized access to the didPay function.

By replacing revert with require, the code enforces proper authorization checks and enhances the security of the smart contract.

#0 - c4-pre-sort

2023-05-24T10:12:55Z

dmvt marked the issue as low quality report

#1 - c4-judge

2023-06-02T10:54:13Z

dmvt marked the issue as grade-b

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