XSS via SVG Construction contract #131
Labels
2 (Med Risk)
Assets not at direct risk, but function/availability of the protocol could be impacted or leak value
bug
Something isn't working
sponsor confirmed
Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
Handle
thank_you
Vulnerability details
Impact
SVG is a unique type of image file format that is often susceptible to Cross-site scripting. If a malicious user is able to inject malicious Javascript into a SVG file, then any user who views the SVG on a website will be susceptible to XSS. This can lead stolen cookies, Denial of Service attacks, and more.
The
NFTTokenURIScaffold
contract generates a SVG via theNFTSVG.constructSVG
function. One of the arguments used by theNFTSVG.constructSVG
function issvgTitle
which represents the ERC20 symbols of both the asset and collateral ERC20 tokens. When generating an ERC20 contract, a malicious user can set malicious XSS as the ERC20 symbol.These set of circumstances leads to XSS when the SVG is loaded on any website.
Proof of Concept
NFTTokenURIScaffold#constructTokenURI
is called, a SVG is generated. This process works such that when generating the SVG the tainted ERC20 symbol created in Step 1 is passed to theNFTSVG.constructSVG
function here. This function returns a SVG containing the tainted ERC20 symbol.Tools Used
N/A
Recommended Mitigation Steps
Creating a SVG file inside of a Solidity contract is novel and thus requires the entity creating a SVG file to sanitize any potential user-input that goes into generating the SVG file.
As of this time there are no known Solidity libraries that sanitize text to prevent an XSS attack. The easiest solution is to remove all user-input data from the SVG file or not generate the SVG at all.
The text was updated successfully, but these errors were encountered: