[near, near, near] and receive NEAR tokens several times.
Treat every user-supplied list as a list with duplicates unless you check otherwise. If your method charges once but processes every entry, a caller can repeat a value and receive the same benefit multiple times.
The vulnerable pattern
The vulnerable logic looks like this:Pseudocode: vulnerable flow
token_ids contains each token only once. A caller controls that list, so that assumption is unsafe.
How the exploit happens
- The user redeems their share tokens once.
- They pass
[near, near, near]instead of[near]. - The loop processes every
nearentry as a separate payout. - The user’s NEAR balance is credited several times, even though they paid their share tokens only once.
The safe pattern
Accept one token ID per redemption. Each call deducts the user’s share tokens before paying out:Pseudocode: safe flow
redeem several times. They cannot redeem more than their share balance because every call deducts share_amount.
If an operation genuinely needs a list, deduct share_amount inside the loop before each payout. The user then pays the share amount for each entry, so a repeated token ID cannot create a free extra redemption.