Skip to content

Instantly share code, notes, and snippets.

@packmad
Last active September 5, 2025 10:05
Show Gist options
  • Select an option

  • Save packmad/ab1eb8cb660e799e08029a18e5df15da to your computer and use it in GitHub Desktop.

Select an option

Save packmad/ab1eb8cb660e799e08029a18e5df15da to your computer and use it in GitHub Desktop.
This PoC shows how a valid SVG file (i.e., XML) can embed JavaScript code
Display the source blob
Display the rendered blob
Raw
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg xmlns="http://www.w3.org/2000/svg"
width="420" height="140"
onload="init(evt)">
<title>SVG JavaScript PoC (benign)</title>
<defs>
<style><![CDATA[
text { font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif; }
]]></style>
</defs>
<rect x="0" y="0" width="100%" height="100%" fill="#f3f4f6" />
<text x="20" y="50" font-size="20" fill="#111827">This SVG contains an inline &lt;script&gt;.</text>
<text x="20" y="85" font-size="16" fill="#374151">If you open this image in a browser, you’ll see an alert.</text>
<script type="application/ecmascript"><![CDATA[
function init(evt) {
// This is where attackers would put their payload.
alert('Hello from inside an SVG! (PoC)');
}
]]></script>
</svg>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment