Skip to content
Business logic Audit finding Intermediate

Changing default reserved token beneficiary may result in wrong beneficiary for tier

A tier's reserved token beneficiary is not stored explicitly when it matches the current default, so later changing the default silently redirects that tier's reserved tokens to the new default beneficiary. An attacker or owner could cause reserved tokens intended for one address to be sent to another.

Lambda Follow

Originally disclosed on Code4rena

Submitted by Lambda

When the reservedTokenBeneficiary of a tier is equal to defaultReservedTokenBeneficiaryOf[msg.sender], it is not explicitly set for this tier. This generally works well because in the function reservedTokenBeneficiaryOf(address _nft, uint256 _tierId), defaultReservedTokenBeneficiaryOf[_nft] is used as a backup when _reservedTokenBeneficiaryOf[_nft][_tierId] is not set. However, it will lead to the wrong beneficiary when defaultReservedTokenBeneficiaryOf[msg.sender] is later changed, as this new beneficiary will be used for the tier, which is not the intended one.

Proof Of Concept

defaultReservedTokenBeneficiaryOf[address(delegate)] is originally set to address(Bob) when the following happens:

  1. A new tier 42 is added with _tierToAdd.reservedTokenBeneficiary = address(Bob). Because this is equal to defaultReservedTokenBeneficiaryOf[address(delegate)], _reservedTokenBeneficiaryOf[msg.sender][_tierId] is not set.
  2. The owner calls setDefaultReservedTokenBeneficiary to change the default beneficiary (i.e., the value defaultReservedTokenBeneficiaryOf[address(delegate)]) to address(Alice).
  3. Now, every call to reservedTokenBeneficiaryOf(address(delegate), 42) will return address(Alice), meaning she will get these reserved tokens. This is of course wrong, the tier was explicitly created with Bob as the beneficiary.

Recommended Mitigation Steps

Also set _reservedTokenBeneficiaryOf[msg.sender][_tierId] when it is equal to the current default beneficiary.

mejango (Juicebox DAO) confirmed

drgorillamd (Juicebox DAO) commented:

Edge case but valid imo! Nice finding!

mejango (Juicebox DAO) commented:

yep. valid imo too!


The original report as published on Code4rena, by Lambda. 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 contract skips storing a tier's reserved token beneficiary when it equals the current default, relying on a fallback that later changes.

Impact

Reserved tokens for a tier could be sent to the wrong beneficiary after the default is changed.

What the attacker needed

Owner can change default beneficiary; tier created with default beneficiary

The fix

The contract should also store the tier's reserved token beneficiary explicitly when it equals the current default.

How it was found

  1. A new tier is added with its reserved token beneficiary set to the current default address.
  2. Because it matches the default, the tier's beneficiary is not stored explicitly.
  3. The owner changes the default reserved token beneficiary to a different address.
  4. Queries for the tier's beneficiary now return the new default address instead of the original one.

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 lets a project owner set a default address to receive reserved tokens. If a tier is created with that same address, the contract does not save it separately. Later, if the default is changed, the tier now points to the new default, so tokens go to the wrong person.

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 Lambda

View all

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