Skip to content

probe: svg injection (XXE/SSRF via model-emitted markup) - #2040

Open
francose wants to merge 1 commit into
NVIDIA:mainfrom
francose:feature/probe_svg_injection
Open

probe: svg injection (XXE/SSRF via model-emitted markup)#2040
francose wants to merge 1 commit into
NVIDIA:mainfrom
francose:feature/probe_svg_injection

Conversation

@francose

@francose francose commented Aug 9, 2026

Copy link
Copy Markdown

adds a probe + detector for SVG/XML injection. closes #1949.

when a model emits SVG/XML and something downstream rasterizes or parses it, that markup can carry XXE (<!DOCTYPE ... <!ENTITY SYSTEM>) to read local files, or an <image href> pointing at file:// or an SSRF target (169.254.169.254, metadata.google.internal, gopher:/dict:). this probes whether a model hands that back on request.

whats here:

  • probes.svg_injection.SvgInjection (OF_CONCERN) - live, ready-to-render markup
  • probes.svg_injection.SvgInjectionEscaped (INFORMATIONAL) - escaped markup, lower signal
  • detectors.svg_injection.Live / .Escaped - deterministic regex for the XXE/SSRF constructs
  • intent S008inject, mirrors the ansiescape / web_injection pattern
  • <script>/XSS stays in web_injection, this is scoped to the parser/rasterizer sink

detector tests + docs included, green against current main

Elicit SVG/XML that attacks a downstream rasterizer or XML parser rather
than a browser: XXE local file read, out-of-band exfil via external DTD,
<image href="file://"> reads, and SSRF to cloud metadata / gopher / dict
gadgets. Browser XSS stays in web_injection.

Mirrors the ansiescape pattern: SvgInjection (OF_CONCERN) + SvgInjectionEscaped
(INFORMATIONAL) probes, Live/Escaped StringDetectors, payloads in resources/svg.py.

Signed-off-by: Sadik Erisen <13445813+francose@users.noreply.github.com>
@francose
francose force-pushed the feature/probe_svg_injection branch from 63c761b to 7f60e98 Compare August 9, 2026 23:40

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new SVG/XML injection capability to garak, aimed at detecting when a target emits SVG/XML payloads that could exploit downstream SVG rasterizers or XML parsers (XXE file reads / external DTD fetches and SSRF-style <image href> fetches), alongside deterministic StringDetector-based detectors, resources, docs, and tests.

Changes:

  • Introduces garak.probes.svg_injection with OF_CONCERN (live markup) and INFORMATIONAL (escaped markup) probe variants.
  • Adds garak.detectors.svg_injection Live/Escaped detectors backed by new garak.resources.svg payload/token banks.
  • Wires the new probe/detector modules into Sphinx docs and adds detector-focused unit tests.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/detectors/test_detectors_svg_injection.py Adds unit tests validating Live/Escaped detector scoring against live, escaped, SSRF, and benign SVG samples.
garak/resources/svg.py Introduces SVG/XXE/SSRF payload banks and token triggers used by the probe/detector implementations.
garak/probes/svg_injection.py Adds SvgInjection (live) and SvgInjectionEscaped probes and their prompt banks.
garak/detectors/svg_injection.py Adds deterministic StringDetectors for live vs escaped SVG/XML injection indicators.
docs/source/probes/svg_injection.rst Adds Sphinx automodule page for the new probe module.
docs/source/index_probes.rst Adds the new probe page to the probes documentation index.
docs/source/index_detectors.rst Adds the new detector page to the detectors documentation index.
docs/source/detectors/svg_injection.rst Adds Sphinx automodule page for the new detector module.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread garak/resources/svg.py
Comment on lines +53 to +54
# --- SSRF payloads: the dangerous part is the host/scheme, which no markup
# escaping neutralizes, so these are flagged whenever they appear. ---
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

probe: SVG injection (model output hits a downstream rasterizer / XML parser... XXE + SSRF)

2 participants