We have a web service where logged in users can create web page content and write custom CSS for their pages. All the HTML goes through a whitelist parser and doesn't allow any executable content. All the CSS is put through a whitelist parser that verifies all CSS.
It seems that browsers do not execute JavaScript embedded in SVG files when used this way
selector
{
filter: url("data:image/svg+xml;base64,...#filter");
}
However, I cannot find a spec that says that browsers should not run JavaScript in that data URL.
Is it safe to allow data:
URLs for function url()
in property filter
? I'm primarily thinking XSS attacks but I obviously would like to hear about other vulnerabilities, too.
The intended use case is to e.g. allow custom content filtering to theme colors so there's no need to allow JS in SVG. I'm basically wondering if I can safely add rule that says that prefix data:image/svg+xml
is safe value for CSS function url
when used in property filter
.
I'm also aware that the Content-Security-Policy
would need to include data:
in the default-src
because the specs failed to define SVG handling any better. As a result, I also need script-src 'self'; object-src 'self'
.