SablierV2NFTDescriptor.sol#generateAttributes() - The function is vulnerable to JSON injection from a malicious asset symbol
The nft descriptor is used to generate the tokenURI
of a stream. It uses many different fields, including the stream asset's symbol.
The protocol team correctly handle large symbols, so that a malicious asset can't inject malicious scripts from it symbol
.
But, the symbol can still use JSON injection to inject an attribute, as the symbol
isn't sanitized anywhere, which means the symbol
field can contain the "
character, which would alter the integrity of the JSON data that is being generated by generateAttributes
.
If asset.symbol()
returns something like '","name":"hello world'
, then this new attribute will be appended to the JSON data and will look something like this:
The <= 30 bytes requirement is enough to even inject images/gifs which may be very bad for the protocol, as a malicious actor can inject violence/pornographic images, which can lead to real world consequences for the protocol.
This attack can very easily be achieved with a malicious ERC20 token used when creating a stream, that is specifically built to inject malicious characters when tokenURI
is called on SablierV2Lockup
.
Anyone that queries that specific streamId
or queries all the token URI's of the contract, will be hit with a maliciously injected attribute.
Some similar issues found in the past.
https://code4rena.com/reports/2023-12-revolutionprotocol#h-03-verbstokentokenuri-is-vulnerable-to-json-injection-attacks
https://code4rena.com/reports/2023-03-canto-identity#m-04-bio-protocol---tokenuri-json-injection
JSON injection
Manual Review
Sanitize the asset symbol, so it can't inject malicious attributes. This resource can help https://github.com/OWASP/json-sanitizer.
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.