The mintProfile()
function in the SoulboundProfitNFT
contract lacks proper input sanitization or escaping for its name
and profileImage
parameters. This vulnerability allows malicious actors to inject arbitrary data into the JSON metadata structure, potentially leading to security risks such as data corruption or manipulation.
Within the mintProfile()
function, the contract accepts name
and profileImage
as user-provided input but does not impose any restrictions or validation mechanisms. As a result, there is a possibility for attackers to insert malformed or malicious JSON structures, which can lead to JSON Metadata Injection. If an attacker provides a specially crafted input, it could alter the metadata stored within the contract in an unexpected way.
This vulnerability introduces several risks. Attackers could manipulate metadata in a way that disrupts the intended structure, causing issues with on-chain data integrity. Additionally, external applications that rely on properly formatted JSON metadata may fail to parse or interpret the data correctly, leading to unexpected errors.
The absence of input sanitization in mintProfile()
can result in several security and functionality issues. Corrupted or manipulated metadata may render certain NFTs unusable, affecting their intended utility. Furthermore, if third-party platforms such as NFT marketplaces or blockchain explorers retrieve and process the injected metadata without proper escaping, it could lead to disruptions in their operations. This vulnerability could also expose off-chain applications to security risks if they do not properly handle unexpected metadata formats.
Manual Audit
To address this issue, the contract should implement input validation and sanitization for the name
and profileImage
parameters before storing them. Input validation should enforce restrictions on character sets and length limits to prevent malformed or malicious data from being inserted. Additionally, special characters that could interfere with JSON structures should be properly escaped to prevent metadata manipulation. Using structured input formats such as Base64 encoding for images or predefined schemas for metadata fields can further enhance security. Unfortunately, the current implementation encodes the entire JSON data as a whole.
By implementing these safeguards, the contract can ensure that metadata remains properly formatted and secure, preventing potential injection attacks while maintaining data integrity.
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.