The tokenURI
function in the SoulboundProfileNFT
contract constructs JSON metadata using unsanitized user-provided inputs (name
and profileImage
). Attackers can inject malicious characters (e.g., "
, \
, <>
) to break the JSON structure, corrupt metadata, or execute cross-site scripting (XSS) attacks in applications that parse the metadata.
Contract: SoulboundProfileNFT.sol
Function: tokenURI
Unsanitized Inputs:
The name
and profileImage
fields (set by users during profile creation) are directly inserted into the JSON string without escaping special characters.
Example: A name
containing "
or \
will break the JSON syntax.
Missing Validation:
No checks are performed to ensure name
and profileImage
conform to safe standards (e.g., alphanumeric characters only).
Metadata Corruption: Malicious users can create profiles with invalid JSON, causing applications (e.g., marketplaces, wallets) to fail when rendering the NFT.
XSS Risk: If the metadata is displayed in a web context without sanitization, attackers could inject scripts via profileImage
URLs.
Reputation Damage: The protocol may be seen as insecure, especially if third-party integrations break due to invalid metadata.
Malicious Profile Creation:
Resulting Corrupted JSON:
This invalid JSON breaks parsers and injects a fake hacked
field.
Restrict name
and profileImage
to safe characters during minting:
n.
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.