The LPNFT contract contains a critical vulnerability that allows the router (a centralized entity specified during deployment) to mint an infinite number of NFTs and arbitrarily burn NFTs belonging to users without their consent. This flaw results from the unrestricted nature of the mint and burn functions, which rely solely on the onlyUpliftOnlyRouter modifier for access control. If the router is malicious or compromised, it could inflate the supply or destroy NFTs at will, undermining the integrity and security of the system.
The issue arises due to:
Unlimited Minting (mint)
The mint function allows the router to create NFTs without a supply cap or any validation logic. This enables infinite token issuance, which can devalue existing tokens or disrupt accounting in systems where NFTs represent assets or liquidity.
Arbitrary Burning (burn)
The burn function permits the router to destroy NFTs arbitrarily, regardless of ownership or user consent. There are no checks to ensure the caller owns the token being burned.
Infinite Minting:
Allows the router to create an unlimited number of tokens, diluting the value of existing NFTs and breaking any assumptions of scarcity or token accounting.
Arbitrary Burning:
Allows the router to confiscate tokens belonging to legitimate users, resulting in financial losses or loss of functionality for token holders.
The vulnerability has significant implications:
Inflation of NFTs:
Unrestricted minting enables the creation of an unlimited number of NFTs, which can undermine market trust and devalue the tokens.
Loss of Ownership:
Arbitrary burning allows NFTs owned by legitimate users to be destroyed without their approval, resulting in irreversible losses.
Centralization Risks:
The reliance on a single router introduces a central point of failure. If the router is compromised or malicious, it can exploit these functions to harm users and the protocol.
Economic Disruption:
For systems where NFTs represent liquidity or pool shares, infinite minting and burning disrupt the token accounting, potentially causing insolvency or other systemic issues.
Add the following test to pkg/pool-hooks/test/foundry/UpliftExample.t.sol:
Result:
The router successfully mints 5 NFTs for the user 0xBEEF.
It then burns tokenId 1 without any ownership validation.
After burning, the user retains 4 NFTs, confirming that the burn operation succeeds without user consent.
Foundry: Used to develop and run tests to validate the vulnerability.
Manual Code Review: Confirms the issue persists within the LPNFT contract where mint and burn only check for router authorization.
Implement a Minting Cap:
Add a maximum supply limit for NFTs to prevent infinite minting:
Enforce Ownership Checks in burn:
Validate that only the owner of the token can burn it:
Introduce Access Control:
Use OpenZeppelin’s AccessControl to assign roles like MINTER_ROLE and BURNER_ROLE for minting and burning. This provides more granular control:
Enable Router Replacement:
Allow the router to be replaced via multisig or governance in case it is compromised:
By applying these mitigations, the protocol can safeguard against infinite minting and unauthorized burns, ensuring the security and trust of users.
Please read the CodeHawks documentation to know which submissions are valid. If you disagree, provide a coded PoC and explain the real likelyhood and the detailed impact on the mainnet without any supposition (if, it could, etc) to prove your point.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.