Closed SelfMadeSystem closed 1 year ago
Heya, thanks for submitting this issue.
I am not sure if I agree that <animate>
is a frequently used element in SVG and, given that it is deprecated in SVG 2.0, it will also likely not become more frequent in the future. The <animate>
element is a weird leftover from VML when it got merged with PGML to create SVG, no I am hesitant to give it more spotlight by default :)
Together with the <set>
element, it somewhat forms the group of fringe elements that, while being rarely used and clumsy in terms of implementation, also cause security risks by, as you mentioned, animating href
and alike.
I would recommend to simply use a hook to add more fine-grained handling of those kinds of elements, given the dark past of XSS via SVG caused by <animate>
, <set>
, <use>
, <foreignObject>
and the likes will make it very unlikely for us to actually change core library behavior.
References: https://discuss.httparchive.org/t/use-of-html-elements/1438 https://svgwg.org/specs/animations/#AnimateElement
Closing this for now as no core changes are anticipated and all requested logic can be implemented using a hook.
Background & Context
The
<animate>
tag is used frequently in SVG animations. It can also animate certain attributes that CSS can't animate, such asoffset
on<stop>
elements.Proposition
I propose to instead limit what values the
attributeName
can have. For example,href
orxlink:href
make no sense to be animated. They should never be animated. However, other attributes such asd
,width
,fill
,offset
, orflood-color
absolutely have the right to be animated.I think this would be a much more sensible way of preventing XSS while keeping the features that make SVG great.
Examples
Should turn into
or something similar idk
but...
should be left as-is
(note that the example above cannot be converted to a CSS animation as
offset
is not a CSS-animatable attribute)Notes:
I am not a cyber-security analyst (however I hope to be), so please make sure my ideas make sense from a security standpoint.
Please give feedback.
I'll try to help with an implementation of something like this when I have time.