Liquid Staking

Stakelink
DeFiHardhatOracle
50,000 USDC
View results
Submission Details
Severity: medium
Invalid

contracts/core/tokens/LinkPoolNFT.sol

The provided Solidity code for the LinkPoolNFT contract looks well-structured, but there are a few potential vulnerabilities and areas for improvement that you should consider:

1. Token ID Management

  • Issue: The totalSupply variable is incremented directly in the mint function, which can lead to potential issues with overflow (though this is mitigated by using Solidity 0.8.x, which has built-in overflow protection).

  • Recommendation: Consider using a separate mechanism for managing token IDs. The current method can lead to confusion if multiple mints are attempted concurrently.

2. Access Control on Minting

  • Issue: While the mint function restricts calls to the lpMigration address, if this address is compromised or incorrectly set, anyone could mint tokens.

  • Recommendation: Ensure that the lpMigration address is securely controlled and consider implementing a mechanism to change it if needed.

3. Setting Token URI

  • Issue: The _setTokenURI function sets the token URI to "/" for every minted token, which may not be what you want if you aim to provide distinct metadata for each token.

  • Recommendation: Modify the token URI to include meaningful data. For example, you might want to use Strings.toString(tokenId) to create unique URIs for each token.

4. Reentrancy Vulnerability

  • Issue: Although this contract does not currently seem to have external calls that could lead to reentrancy attacks, it's generally good practice to be cautious.

  • Recommendation: If any future functions involve sending Ether or interacting with external contracts, use the checks-effects-interactions pattern and consider using a reentrancy guard.

5. Lack of Events

  • Issue: There are no events emitted for significant actions, such as minting a new token or updating the base URI.

  • Recommendation: Add events for better transparency and tracking on the blockchain:

    event Minted(address indexed to, uint256 indexed tokenId);
    event BaseURIUpdated(string newBaseURI);

    Emit these events in the mint and setBaseURI functions, respectively.

6. No Mechanism for Token Burning

  • Issue: There is no option for burning tokens, which could be important for certain use cases.

  • Recommendation: Consider implementing a burn function if you foresee a need to allow token holders to destroy their tokens.

7. Potential Base URI Exposure

  • Issue: The base URI is publicly visible, which could expose sensitive information if the base URI is intended to be private.

  • Recommendation: Ensure that the base URI does not lead to sensitive data and consider adding a privacy mechanism if necessary.

Example of a Revised Mint Function

Here’s how you might implement a revised mint function and add an event for better tracking:

event Minted(address indexed to, uint256 indexed tokenId);
function mint(address _to) external {
require(msg.sender == lpMigration, "LPMigration only");
uint256 tokenId = totalSupply + 1; // Use a separate variable for clarity
totalSupply = tokenId; // Increment after generating the token ID
_safeMint(_to, tokenId);
_setTokenURI(tokenId, string(abi.encodePacked(baseURI, Strings.toString(tokenId))));
emit Minted(_to, tokenId); // Emit event
}

By addressing these points, you can improve the security and functionality of your NFT contract.

Updates

Lead Judging Commences

inallhonesty Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Lack of quality

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.