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.
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:
- A new tier 42 is added with
_tierToAdd.reservedTokenBeneficiary = address(Bob). Because this is equal todefaultReservedTokenBeneficiaryOf[address(delegate)],_reservedTokenBeneficiaryOf[msg.sender][_tierId]is not set. - The owner calls
setDefaultReservedTokenBeneficiaryto change the default beneficiary (i.e., the valuedefaultReservedTokenBeneficiaryOf[address(delegate)]) toaddress(Alice). - Now, every call to
reservedTokenBeneficiaryOf(address(delegate), 42)will returnaddress(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!
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
- A new tier is added with its reserved token beneficiary set to the current default address.
- Because it matches the default, the tier's beneficiary is not stored explicitly.
- The owner changes the default reserved token beneficiary to a different address.
- 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.