Unauthorized increase of maxSellPercent
The setSellable function resets maxSellPercent to 20% when the current value is 0, which is interpreted as uninitialised. This allows the admin to inadvertently override the token issuer's setting of 0, enabling token sales that the issuer intended to prevent.
BenRai Follow with NexusAudits and seerether
Originally disclosed on Code4rena
Submitted by BenRai, also found by NexusAudits and seerether
This issue allows the maxSellPercent to be increased to 20% against the will of the token issuer. This will result in users being able to sell tokens even when the issuer intended to prevent selling.
Proof of Concept
The SecondSwap_VestingManager contract manages vesting settings and allocations for tokens. A critical function in this context is setMaxSellPercent, which allows the tokenIssuer to set the maximum percentage of vesting tokens that can be sold by users.
The issue arises from the interaction between the setSellable and setMaxSellPercent functions. When the tokenIssuer sets maxSellPercent to 0 to prevent selling, the following sequence of events can occur:
- The token issuer calls
setMaxSellPercent(vesting, 0)to prevent any selling of their tokens. - Because an issue with the vesting has occurred, the admin calls
setSellable(vesting, true)to unlist the vesting - The issue gets fixed and the admin subsequently calls
setSellable(vesting, true)again to list the vesting again. This inadvertently setsmaxSellPercentto 20% because the current value is 0, which is interpreted as a lack of initialization. - As a result, users can now sell their tokens, despite the issuer’s intention to prevent it.
This flaw allows the admin to accidentally override the issuer’s settings, leading to unauthorized selling of tokens.
It also sets the sellFee and buyFee back to default which might not be intended if the admit has changed them before.
Recommended Mitigation Steps
To mitigate this issue, a new variable initiated should be added to the vesting settings. This variable will track whether the vesting has been initialized. The setSellable function should only update the maxSellPercent if initiated is false which should only be when the vesting is initial created.
bobwong (SecondSwap) confirmed
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 setSellable function treats a maxSellPercent of 0 as uninitialised and overwrites it with a default value, without distinguishing between an intentional zero and an unset value.
Impact
Users could sell tokens even when the issuer intended to prevent selling, and the sellFee and buyFee may also be reset to default values.
What the attacker needed
Token issuer sets maxSellPercent to 0; admin calls setSellable to unlist then relist
The fix
A new variable should track whether the vesting has been initialised, and setSellable should only update maxSellPercent when it has not been initialised.
How it was found
- The token issuer calls setMaxSellPercent(vesting, 0) to prevent any selling of their tokens.
- Because an issue with the vesting has occurred, the admin calls setSellable(vesting, true) to unlist the vesting.
- The issue gets fixed and the admin subsequently calls setSellable(vesting, true) again to list the vesting again.
- This inadvertently sets maxSellPercent to 20% because the current value is 0, which is interpreted as a lack of initialization.
- As a result, users can now sell their tokens, despite the issuer’s intention to prevent it.
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 token issuer can set a maximum sell percentage to control how much of their vesting tokens users can sell. If they set it to 0 to block all selling, an admin action to relist the vesting can accidentally reset that limit to 20%, letting users sell tokens against the issuer's wishes.
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.