A rendering step pasted credential values into an SVG template without escaping. A value carrying markup breaks out of its slot and adds a live script to whatever renders the image.
What goes wrong
The template has placeholders, and the code fills them by dropping selected credential values into the SVG string as-is. No escaping, no encoding. Whatever the value contains becomes part of the document.
SVG is XML, and XML can carry scripts, event handlers, and references to external resources. A credential value that contains a closing tag followed by a script element does not sit quietly inside its placeholder. It closes the surrounding element and injects live content. When that SVG is rendered in a browser context, the script runs with whatever access that context has. That is stored XSS, delivered as an image.
Placeholders are not a safety boundary. Any value going into markup has to be encoded for the exact context it lands in. For SVG and XML, escape the special characters, and strip or reject anything that tries to introduce active elements.
The pattern
function render(template, cred) {
let out = template;
for (const field of FIELDS) {
out = fill(out, field, cred[field]); // inserted raw
}
return out; // markup in a value becomes live SVG
}function render(template, cred) {
let out = template;
for (const field of FIELDS) {
out = fill(out, field, xmlEscape(cred[field]));
}
return sanitizeSvg(out); // strip active markup
}Every gate held. The exploit path was reproduced against a negative control, the impact was calibrated, and the finding was signed report-ready.
Why it matters to you
If these documents get shown in a browser, to an admin reviewing a submission or another user viewing a shared credential, you have handed an attacker script execution in that viewer's session. Credential data is attacker-supplied more often than teams admit, because the entire point is that outsiders fill it in. Treat every field as hostile until it has been encoded.
Check your own code
- Find every spot where input values are concatenated into SVG, XML, or HTML.
- Encode for the target context, and reject or sanitize active markup.
- Serve generated documents with a restrictive content type and a CSP where you can.