The SoulboundProfileNFT.sol::tokenURI()
function constructs metadata using user-provided inputs (name, age and image URL) without sanitization. This creates a risk of a Cross-Site Scripting (XSS) attack if a malicious user mints an NFT with JavaScript payloads embedded in the metadata fields. When displayed in a browser-based NFT viewer, the malicious script could execute, leading to potential theft of session data, cookies, or even user keys.
The SoulboundProfileNFT.sol::tokenURI()
function directly incorporates user-controlled inputs (name
and profileImage
) into the returned JSON metadata. If a malicious user inputs a script payload, it could execute in environments that do not properly sanitize or escape metadata before rendering.
Affected code:
A malicious user can inject JavaScript in the name
or profileImage
fields, leading to an XSS attack when the NFT metadata is displayed in a vulnerable frontend.
The attack can compromise user wallets, session data, or other sensitive information.
Affected platforms may be exploited to distribute malicious payloads.
Manual review
I would recommend the following:
Escape or sanitize user inputs before including them in metadata.
Implement validation to restrict name
and profileImage
to alphanumeric characters and valid URLs.
Use proper encoding (e.g., HTML entity encoding) before rendering the metadata in a frontend.
Consider using a trusted metadata storage solution instead of directly embedding user inputs.
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.