Submitted by berndartmueller
https://github.com/jbx-protocol/juice-nft-rewards/blob/f9893b1497098241dd3a664956d8016ff0d0efd0/contracts/JBTiered721DelegateStore.sol#L1224-L1259
https://github.com/jbx-protocol/juice-nft-rewards/blob/f9893b1497098241dd3a664956d8016ff0d0efd0/contracts/JBTiered721DelegateStore.sol#L566
https://github.com/jbx-protocol/juice-nft-rewards/blob/f9893b1497098241dd3a664956d8016ff0d0efd0/contracts/abstract/JB721Delegate.sol#L142
If the reserved rate of a tier is set to a value > JBConstants.MAX_RESERVED_RATE, the JBTiered721DelegateStore._numberOfReservedTokensOutstandingFor function will return way more outstanding reserved tokens (up to ~6 times more than allowed - 2^16 - 1 due to the manual cast of reservedRate to uint16 divided by JBConstants.MAX_RESERVED_RATE = 10_000). This inflated value is used in the JBTiered721DelegateStore.totalRedemptionWeight function to calculate the cumulative redemption weight of all tokens across all tiers.
This higher-than-expected redemption weight will lower the reclaimAmount calculated in the JB721Delegate.redeemParams function. Depending on the values of _data.overflow and _redemptionWeight, the calculated reclaimAmount can be 0 (due to rounding down, see here) or a smaller than anticipated value, leading to burned NFT tokens from the user and no redemptions.
The owner of an NFT contract can add tiers with higher than usual reserved rates (and mint an appropriate number of NFTs to bypass all conditions in the JBTiered721DelegateStore._numberOfReservedTokensOutstandingFor), which will lead to a lower-than-expected redemption amount for users.
JBTiered721DelegateStore._numberOfReservedTokensOutstandingFor
JBTiered721DelegateStore.totalRedemptionWeight
The JBTiered721DelegateStore._numberOfReservedTokensOutstandingFor function is called from within the JBTiered721DelegateStore.totalRedemptionWeight function. This allows for inflating the total redemption weight.
JBTiered721Delegate._totalRedemptionWeight
JBTiered721DelegateStore.totalRedemptionWeight is called in the JBTiered721Delegate._totalRedemptionWeight function.
abstract/JB721Delegate.redeemParams
This JBTiered721Delegate._totalRedemptionWeight function is then called in the JB721Delegate.redeemParams function, which ultimately calculates the reclaimAmount given an overflow and _decodedTokenIds.
uint256 _base = PRBMath.mulDiv(_data.overflow, _redemptionWeight, _total); in line 142 will lead to a lower _base due to the inflated denumerator _total.
Consider validating the tier reserved rate reservedRate in the JBTiered721DelegateStore.recordAddTiers function to ensure the reserved rate is not greater than JBConstants.MAX_RESERVED_RATE.
mejango (Juicebox DAO) confirmed
For this contest, 49 reports were submitted by wardens detailing low risk and non-critical issues. The report highlighted below by berndartmueller received the top score from the judge.
The following wardens also submitted reports: brgltd,
SaharAP,
minhtrng,
0xSmartContract,
joestakey,
d3e4,
peanuts,
svskaushik,
bharg4v,
delfin454000,
Trust,
Aymen0909,
V_B,
a12jmx,
0x4non,
cryptostellar5,
Diana,
ReyAdmirado,
__141345__,
ret2basic,
cryptphi,
tnevler,
Jeiwan,
carlitox477,
lukris02,
erictee,
mcwildy,
hansfriese,
RaymondFam,
ignacio,
LeoS,
0xNazgul,
ch0bu,
karanctf,
slowmoses,
RaoulSchaffranek,
yixxas,
RedOneN,
fatherOfBlocks,
Lambda,
BClabs,
cloudjunky,
Rolezn,
seyni,
0x1f8b,
ladboy233,
csanuragjain, and
chaduke.
