Open c4-bot-8 opened 11 months ago
Non-standard token type support is more of a QA issue to me.
0xleastwood marked the issue as primary issue
I agree with the judge @0xleastwood. But good to learn this perk for BNB token.
Re check allowance, aren't the previous approvals always set the approved value to be higher?
wukong-particle (sponsor) acknowledged
I agree with the judge @0xleastwood. But good to learn this perk for BNB token.
Re check allowance, aren't the previous approvals always set the approved value to be higher?
Not super concerned about this being an issue. It's not possible for LPs to mint LP tokens in the first place and therefore positions cannot be opened. This is a compatibility issue and no funds are at risk. Downgrading to QA.
0xleastwood changed the severity to QA (Quality Assurance)
Lines of code
https://github.com/code-423n4/2023-12-particle/blob/a3af40839b24aa13f5764d4f84933dbfa8bc8134/contracts/libraries/Base.sol#L59 https://github.com/code-423n4/2023-12-particle/blob/a3af40839b24aa13f5764d4f84933dbfa8bc8134/contracts/libraries/LiquidityPosition.sol#L152-L153 https://github.com/code-423n4/2023-12-particle/blob/a3af40839b24aa13f5764d4f84933dbfa8bc8134/contracts/libraries/LiquidityPosition.sol#L202-L203
Vulnerability details
Summary
Some ERC20 implementations revert when
approve()
is called with a zero amount, causing a denial of service when token allowances are reset.Impact
Token allowances in the LAMM implementation follow a pattern in which approvals are setup for the required amount before executing the operation, and then reset back to zero after executing the operation.
The same behavior is present in
Base.swap()
,LiquidityPosition.mint()
andLiquidityPosition.increaseLiquidity()
. Taking the latter as an example, we can see the implementation callssafeApprove()
with the required amount, then executes the call toincreaseLiquidity()
in the Uniswap NPM contract, and finally it resets the allowances back to zero by executing another call tosafeApprove()
, to ensure any unused allowance is cleared.https://github.com/code-423n4/2023-12-particle/blob/a3af40839b24aa13f5764d4f84933dbfa8bc8134/contracts/libraries/LiquidityPosition.sol#L178-L204
Some ERC20 implementations revert on approvals of zero value. One major example is the BNB token, that throws when called with
0
as the amount argument.This will cause a denial of service in any of the mentioned functions, preventing the protocol from being used under the presence of such tokens.
Recommendation
There is no clean solution for this issue, a potential workaround could be to set the allowance to 1 wei:
approve()
using zero.Assessed type
ERC20