The Brigde contract's depositToken demonstrated the ability to process various metadata without rejection, including empty strings, long strings, special characters, potentially malicious content (e.g., XSS payloads), and mixed valid/invalid UTF-8 characters. While this versatility can be beneficial, it also introduces significant security and integrity risks due to the lack of metadata validation and sanitization.
A coded POC in foundry
Here are the relevant sections of the test result that confirm the processing of each type of metadata:
1: Empty String Metadata
Confirmation: The setTokenURI
function is called with an empty string as metadata for tokenId: 1
, and the function executes successfully.
2: Long String Metadata
Confirmation: The setTokenURI
function is called with a very long string (truncated here for brevity) for tokenId: 2
, and the function executes successfully.
3: XSS Payload Metadata
Confirmation: The setTokenURI
function is called with an XSS payload as metadata for tokenId: 3
, and the function executes successfully.
4: Invalid UTF-8 Metadata
5: Data URL Injection Metadata
These excerpts confirm that the contract processes each type of metadata without issue, despite the deposit operations failing at a later stage. The contract accepted and stored all forms of metadata provided
The contract does not enforce any restrictions or validations on the metadata content. This means that any form of metadata, including potentially harmful or malformed data, is accepted and processed without rejection.
There are no mechanisms in place to sanitize the metadata before it is stored or used by the contract. This allows potentially dangerous content, such as scripts or HTML tags, to be included in the metadata.
The contract does not validate metadata to ensure it meets specific criteria, such as length, character set, or structure. This can lead to issues when the metadata is processed or displayed by other applications.
Cross-Site Scripting (XSS): The inclusion of executable code in metadata can lead to XSS attacks if the metadata is rendered in a web application without proper sanitization.
Injection Attacks: Malicious metadata can be used to exploit vulnerabilities in systems that process or display NFT metadata.
Manual review
1: Introduce validation checks to ensure metadata conforms to specific standards, such as maximum length, acceptable character sets, and valid structure (e.g., JSON format).
2: Apply sanitization to all metadata inputs to remove potentially harmful content, such as scripts or HTML tags, before they are stored or processed.
3: Introduce mechanisms to reject metadata that fails validation or contains potentially harmful content. This can be enforced at the contract level or through associated metadata submission services.
Please, do not suppose impacts, think about the real impact of the bug and check the CodeHawks documentation to confirm: https://docs.codehawks.com/hawks-auditors/how-to-determine-a-finding-validity A PoC always helps to understand the real impact possible.
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.