The tokenURI
function constructs JSON metadata by directly concatenating user input (name
, profileImage
). This introduces a JSON injection vulnerability, allowing an attacker to manipulate the metadata by injecting special characters like double quotes ("
) or backslashes (\
). Exploiting this, an attacker can alter NFT metadata, insert fake attributes, or disrupt NFT marketplaces relying on the token URI.
The function builds JSON using abi.encodePacked
, inserting unescaped user input.
If an attacker supplies a malicious name
or profileImage
, they can break the JSON structure, inject arbitrary data, or modify metadata behavior.
JSON consumers (e.g., NFT marketplaces, wallets) will misinterpret the metadata, leading to incorrect attribute displays or spoofed profiles.
🚨 Risk: No escaping mechanism is applied, making it possible to inject unintended JSON elements.
Metadata Tampering: Attackers can inject fake attributes, misleading users and NFT platforms.
Broken NFT Listings: Malformed JSON may cause token metadata to fail to load on marketplaces.
Security Risks in External Platforms: Marketplaces parsing the JSON might be vulnerable to further exploits.
Loss of Trust: Users may not trust metadata if attackers can spoof names or attributes.
Malicious User Calls mintProfile
with Injected JSON Characters
Generated JSON (Incorrectly Parsed by Marketplaces)
Effect:
The name field breaks the JSON format.
The attacker inserts fake attributes (Age = 100
instead of 25
).
The remaining metadata could be ignored or misinterpreted.
Implement a JSON escaping function to properly encode special characters ("
, \
, etc.):
Instead of manual string concatenation, use abi.encode
for structured JSON objects:
Scamming/phishing is not the protocol problem, that's a user mistake. NFT are unique, even if someone does a copy of your profile (which is also possible in web2), I consider it informational. Injection is a problem for the web2 part of the protocol, not a bug here. For the age, it depends on the countries law and future medicine. Anyways, that's more an ethical/political problem, not a bug.
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.