Skip to content
Business logic Audit finding Intermediate

Beneficiary credit balance can unwillingly be used to mint low tier NFT

The payment processing function combines a new payment with the beneficiary's existing credit balance to mint NFTs, without checking that the payer is the beneficiary. An attacker can pay a small amount and name a victim as beneficiary, forcing the victim's saved credits to be used to mint a lower-tier NFT instead of the higher-tier one they were saving for.

minhquanym Follow

Originally disclosed on Code4rena

Submitted by minhquanym

In the function _processPayment(), it will use provided JBDidPayData from JBPaymentTerminal to mint to the beneficiary. The _value from JBDidPayData will be sum up with previous _credits balance of beneficiary. There are 2 cases that beneficiary credit balance is updated in previous payment:

  1. The payment received does not meet a minting threshold or is in excess of the minted tiers, the leftover amount will be stored as credit for future minting.
  2. Clients may want to accumulate to mint higher tier NFT, they might specify that the previous payment should not mint anything. (Currently it’s incorrectly implemented in case _dontMint=true, but sponsor confirmed that it’s a bug)

In both cases, an attacker can pay a small amount (just enough to mint lowest tier NFT) and specify the victim to be the beneficiary. Function __processPayment() will use credit balance of beneficiary from previous payment to mint low-value tier.

For example, there are 2 tiers

  1. Tier A: mintingThreshold = 20 ETH, votingUnits = 100
  2. Tier B: mintingThreshold = 10 ETH, votingUnits = 10

Obviously tier A is much more better than tier B in term of voting power, so Alice (the victim) might want to accumulate her credit to mint tier A.

Assume current credit balance creditsOf[Alice] = 19 ETH. Now Bob (the attacker) can pay 1 ETH and specify Alice as beneficiary and mint 2 Tier B NFT. Alice will have to receive 2 Tier B NFT with just 20 voting power instead of 100 voting power for a Tier A NFT.

Since these NFTs can be used in a governance system, it may create much higher impact if this governance is used to make important decision. E.g: minting new tokens, transfering funds of community.

Proof of Concept

Function didPay() only check that the caller is a terminal of the project

function didPay(JBDidPayData calldata _data) external payable virtual override {
    // Make sure the caller is a terminal of the project, and the call is being made on behalf of an interaction with the correct project.
    if (
      msg.value != 0 ||
      !directory.isTerminalOf(projectId, IJBPaymentTerminal(msg.sender)) ||
      _data.projectId != projectId
    ) revert INVALID_PAYMENT_EVENT();

    // Process the payment.
    _processPayment(_data);
}

Attacker can specify any beneficiary and use previous credit balance

// Keep a reference to the amount of credits the beneficiary already has.
uint256 _credits = creditsOf[_data.beneficiary];

// Set the leftover amount as the initial value, including any credits the beneficiary might already have.
uint256 _leftoverAmount = _value + _credits;

Recommended Mitigation Steps

Consider adding a config param to allow others from using beneficiary’s credit balance. Its value can be default to false for every address. And if beneficiary want to, they can toggle this state for their address to allow other using their credit balance.

mejango (Juicebox DAO) acknowledged

fancy. i think accumulating credits to “save up” is out of scope for this contract’s design. Still a pretty cool pattern to note, thank you!

yeah: if you are saving up for a specific nft, save up elsewhere, not through the credit system.

minhquanym (warden) commented:

Thanks for your comments. Just put a note cause my writing might be vague. Saving up is just 1 case that I listed. The other case, funds are left after minting a specific tier in the docs.

If a payment received does not meet a minting threshold or is in excess of the minted tiers, the balance is stored as a credit which will be added to future payments and applied to mints at that time.


The original report as published on Code4rena, by minhquanym. 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

Likely the payment handler trusts the beneficiary field in the payment data and adds the new payment to that beneficiary's existing credit without verifying that the payer is the beneficiary or has permission to spend their credit.

Impact

The victim's saved credit could be consumed to mint a lower-tier NFT with less voting power than intended, which may affect governance decisions if the NFTs are used for voting.

What the attacker needed

Victim has accumulated credit; attacker can make a payment; attacker can name any beneficiary

The fix

The contract should be changed to add a per-address setting, defaulting to false, that lets a beneficiary choose whether others may use their credit balance.

How it was found

  1. The victim accumulates credit by making payments that do not mint or by choosing not to mint.
  2. The attacker makes a small payment that is just enough to mint the lowest tier NFT.
  3. The attacker specifies the victim as the beneficiary in the payment data.
  4. The payment handler adds the attacker's payment to the victim's existing credit and mints the low-tier NFT to the victim.

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 project lets people save up credit from payments to mint special tokens (NFTs) later. The code adds any new payment to the saved credit of whoever is named as the beneficiary, even if someone else made the payment. So an attacker can make a tiny payment, name a victim, and the victim's saved credit gets spent on a cheap token instead of the valuable one they wanted.

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 minhquanym

View all

28 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.