probe: svg injection (XXE/SSRF via model-emitted markup) - #2040
Open
francose wants to merge 1 commit into
Open
Conversation
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
force-pushed
the
feature/probe_svg_injection
branch
from
August 9, 2026 23:40
63c761b to
7f60e98
Compare
There was a problem hiding this comment.
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_injectionwith OF_CONCERN (live markup) and INFORMATIONAL (escaped markup) probe variants. - Adds
garak.detectors.svg_injectionLive/Escaped detectors backed by newgarak.resources.svgpayload/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 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. --- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 atfile://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 markupprobes.svg_injection.SvgInjectionEscaped(INFORMATIONAL) - escaped markup, lower signaldetectors.svg_injection.Live/.Escaped- deterministic regex for the XXE/SSRF constructs<script>/XSS stays in web_injection, this is scoped to the parser/rasterizer sinkdetector tests + docs included, green against current main