Skip to content
Business logic Audit finding Intermediate

Funding cycles that use JBXBuybackDelegate as a redeem data source (or any derived class) will slash all redeemable tokens

The redeemParams function in JBXBuybackDelegate returns zero for the reclaim amount instead of passing through the input value, so any funding cycle configured to use it as a redeem data source will burn tokens and send zero tokens to the beneficiary. The function also lacks the virtual keyword, preventing derived contracts from overriding the faulty implementation.

ABA Follow with ktg and RaymondFam

Originally disclosed on Code4rena

Submitted by ABA, also found by ktg and RaymondFam

For a funding cycle that is set to use the data source for redeem and the data source is JBXBuybackDelegate, any and all redeemed tokens is 0 because of the returned 0 values from the empty redeemParams implementation. This means the beneficiary would wrongly receive 0 tokens instead of an intended amount.

While JBXBuybackDelegate was not designed to be used for redeem also, per protocol logic, this function should have been a pass-through (if no redeem such functionality was desired) because a redeem logic is by default used if not overwritten by redeemParams, as per the documentation (further detailed below). Impact is further increased as the function is not marked as virtual, as such, no inheriting class can modify the faulty implementation if any such extension is desired.

Vulnerability details

Project logic dictates that a contract can become a treasury data source by adhering to IJBFundingCycleDataSource, such as JBXBuybackDelegate is and that there are two functions that must be implemented, payParams(...) and redeemParams(...). Either one can be left empty if the intent is to only extend the treasury’s pay functionality or redeem functionality.

But by being left empty, it is specifically required to pass the input variables, not a 0 default value

https://docs.juicebox.money/dev/build/treasury-extensions/data-source/

Return the JBRedeemParamsData.reclaimAmount value if no altered functionality is desired. Return the JBRedeemParamsData.memo value if no altered functionality is desired. Return the zero address if no additional functionality is desired.

What should have been done:

  // This is unused but needs to be included to fulfill IJBFundingCycleDataSource.
  function redeemParams(JBRedeemParamsData calldata _data)
    external
    pure
    override
    returns (
      uint256 reclaimAmount,
      string memory memo,
      IJBRedemptionDelegate delegate
    )
  {
    // Return the default values.
    return (_data.reclaimAmount.value, _data.memo, IJBRedemptionDelegate(address(0)));
  }

What is implemented:

https://github.com/code-423n4/2023-05-juicebox/blob/main/juice-buyback/contracts/JBXBuybackDelegate.sol#L235-L239

    function redeemParams(JBRedeemParamsData calldata _data)
        external
        override
        returns (uint256 reclaimAmount, string memory memo, JBRedemptionDelegateAllocation[] memory delegateAllocations)
    {}

While an overwritten memo with an empty default string is not such a large issue, and incidentally delegateAllocations is actually returned correctly as a zero address, the issue lies with the reclaimAmount amount which is not returned as 0.

Per documentation:

reclaimAmount is the amount of tokens in the treasury that the terminal should send out to the redemption beneficiary as a result of burning the amount of project tokens tokens

and in case of redemptions, by default, the value is:

a reclaim amount determined by the standard protocol bonding curve based on the redemption rate the project has configured into its current funding cycle which is provided to the data source function in JBRedeemParamsData.reclaimAmount

but in this case, it will be overwritten with 0 thus the redemption beneficiary will be deprived of funds.

redeemParams is also lacking the virtual keyword, as such, no inheriting class can modify the faulty implementation if any such extension is desired.

Recommended Mitigation Steps

Change the implementation of the function to respect protocol logic and add the virtual keyword, for example:

  // This is unused but needs to be included to fulfill IJBFundingCycleDataSource.
  function redeemParams(JBRedeemParamsData calldata _data)
    external
    pure
    override
    virtual
    returns (
      uint256 reclaimAmount,
      string memory memo,
      IJBRedemptionDelegate delegate
    )
  {
    // Return the default values.
    return (_data.reclaimAmount.value, _data.memo, IJBRedemptionDelegate(address(0)));
  }

drgorillamd (Juicebox) disagreed with severity and commented:

The funding cycle has two delegate-related parameters, useDelegateForPay and useDelegateForRedemption. This is a pay delegate, to have a situation where the redemption becomes faulty would require the project owner to proactively submit a reconfiguration, to activate the use of the delegate on redemption. This is a user bug, not a protocol one.

Should be documented to avoid confusion.

LSDan (judge) commented:

I respect that this is user error, but I also think it’s a very easy error to prevent. Medium stands.


The original report as published on Code4rena, by ABA. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

The redeemParams function was left empty instead of returning the input reclaimAmount, memo and a zero delegate address, so Solidity's default zero values override the protocol's standard bonding-curve calculation.

Impact

If a project owner configures the funding cycle to use this pay-only delegate for redemptions, every redeemer receives zero tokens instead of the amount the bonding curve would give; the report notes this requires the owner to actively enable the delegate for redemption.

What the attacker needed

Project owner enables delegate for redemption; funding cycle uses JBXBuybackDelegate as redeem data source

The fix

The function should return the input reclaimAmount, memo and a zero delegate address, and be marked virtual so derived contracts can override it.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

A smart contract can act as a helper for a project's treasury, deciding how many tokens a user gets when they cash out (redeem). This helper was written only for payments, so its cash-out function was left empty. An empty function in Solidity returns zero by default, so the treasury sent zero tokens to anyone cashing out. The helper should have passed the original amount through unchanged.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More by ABA

View all

3 more disclosed reports, best first.

More from Juicebox Buyback Delegate

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.