- The
<animate>element in SVG is used to animate attributes of another SVG element. - Host element = the element whose attribute is being animated.
- If
<animate>has nohref, the parent element becomes the host. - If
<animate href="#id">is present, the host = the element with that ID.
- If
| Host Element | Example Animatable Attributes |
|---|---|
<circle> |
r, cx, cy, fill, stroke |
<rect> |
x, y, width, height, rx, ry, fill |
<ellipse> |
cx, cy, rx, ry, fill |
<line> |
x1, y1, x2, y2, stroke |
<polygon> / <polyline> |
points, fill, stroke |
<path> |
d, stroke, fill |
<text> |
x, y, font-size, fill, stroke |
<a> |
href (or xlink:href in older SVGs) |
<image> |
x, y, width, height, href |
<svg> |
viewBox, width, height |
<svg>
<a>
<animate attributeName="href" values="javascript:alert(1)" />
<text x="20" y="20">Click me</text>
</a>
</svg>- Parent of
<animate>β<a> - Host element β
<a>(since nohrefwas specified, the parent is used). - Attribute being animated β
hrefof<a>. - Effect β When
<animate>runs, it sets thehrefof<a>tojavascript:alert(1). - User interaction required β User must click the link text (
Click me) to trigger the JavaScript.
- Safe targets for
<animate>in XSS:href,xlink:href,src,style. - User interaction triggers (to bypass restrictions):
<a>click,<text>click, or animation auto-play (begin="0s"). - Modern browsers block
javascript:URIs in some contexts (like top-level navigation), but click-based payloads often still work.
β Use this as a reference for reflected/stored XSS labs involving SVG + animate.