Juicebox Buyback Delegate - 0xnacho'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: 19/72

Findings: 1

Award: $315.23

🌟 Selected for report: 0

🚀 Solo Findings: 0

Findings Information

🌟 Selected for report: adriro

Also found by: 0xRobocop, 0xnacho, HHK, SpicyMeatball, max10afternoon, rbserver

Labels

bug
2 (Med Risk)
partial-50
duplicate-232

Awards

315.2306 USDC - $315.23

External Links

Lines of code

https://github.com/jbx-protocol/juice-contracts-v3/blob/main/contracts/abstract/JBPayoutRedemptionPaymentTerminal3_1.sol#L1500-L1501

Vulnerability details

Impact

If the amount of token returned by swapping is greater than by minting and the _minReturnedTokens value is greater than 0, then the jbEthPaymentTerminal.pay call always fails.

Proof of Concept

This behaviour can be observed by adding the following test to the existing suite:

function test_swapIfQuoteBetterMinReturnedTokens(uint256 _weight) public {
    // Reconfigure with a weight smaller than the quote, slippage included
    _weight = bound(_weight, 0, amountOutForOneEth - (amountOutForOneEth * 500 / 10000) - 1);
    _reconfigure(1, address(delegate), _weight, 5000);

    // Build the metadata using the quote at that block
    bytes memory _metadata = abi.encode(
      bytes32(0),
      bytes32(0),
      amountOutForOneEth, //quote
      500 //slippage 500/10000 = 5%
    );
    
    vm.expectRevert();
    // Pay the project
    jbEthPaymentTerminal.pay{value: 1 ether}(
      1,
      1 ether,
      address(0),
      address(123),
      /* _minReturnedTokens */
      // ---> any value greater than 0
      1,
      /* _preferClaimedTokens */
      true,
      /* _memo */
      'Take my money!',
      /* _delegateMetadata */
      _metadata
    );
  }

Tools Used

  • Foundry

Assessed type

Error

#0 - c4-pre-sort

2023-05-25T13:06:51Z

dmvt marked the issue as duplicate of #36

#1 - c4-judge

2023-06-02T14:23:16Z

dmvt marked the issue as partial-50

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