-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Liquidity may be lost when sent to a non-existent token #66
Comments
This reminds me of a discussion regarding the NFT standards.
Duplicate of #13 |
kirk-baird marked the issue as duplicate of #13 |
kirk-baird marked the issue as not a duplicate |
kirk-baird changed the severity to QA (Quality Assurance) |
For reasons stated in #13 I'm going to downgrade this to QA. |
kirk-baird marked the issue as grade-b |
Lines of code
https://github.com/code-423n4/2022-12-Stealth-Project/blob/fc8589d7d8c1d8488fd97ccc46e1ff11c8426ac2/maverick-v1/contracts/models/Pool.sol#L134
Vulnerability details
Impact
Users may lose funds when providing liquidity to a non-existent token. A wrong token ID may be provided mistakenly or due to a software bug.
Proof of Concept
The protocol implements liquidity position NFT: a collection of NFT tokens that are used to identify liquidity providers in pools (Position.sol#L12). When providing liquidity to pools, liquidity providers must specify an NFT token ID (Pool.sol#L114). Provided liquidity will be associated with the token ID, and only the owner of the token or an approved address will be able to withdraw liquidity from pools (Pool.sol#L217).
However, the
addLiquidity
function of Pool doesn't validate the user-provided token ID: it can be any value from the full range of the values ofuint256
, no matter whether a token exists or not:In case a user provides liquidity to a non existent token, it cannot be withdrawn due to the ownership check (Pool.sol#L217):
Thus, when liquidity is provided to a non-existent NFT, there are two scenarios:
type(uint256).max
), the liquidity wil be locked in the contract forever. This is loss of funds.Here's a proof of concept that demonstrates providing liquidity to a non-existent token ID and the inability to withdraw liquidity afterwards:
Tools Used
Manual review
Recommended Mitigation Steps
Consider disallowing providing liquidity to non-existent NFT IDs.
The text was updated successfully, but these errors were encountered: