Testing chat interfaces for markdown data exfiltration and XSS with garak
If your team has placed a model behind a chat UI that renders markdown, you need to know whether a model response can leak data to a third party or run script in a user's browser. garak's web_injection module is built for that question: it sends prompts designed to make the model emit output that the front end may render, then evaluates whether the rendered result would carry data out or execute code. The probes are aimed at the application's rendering path, not at the model alone, so a clean result from a bare model API says little about the chat product that displays its output. garak is licensed under Apache 2.0 and installs from PyPI with pip on Python 3.11 or newer, so a security team can run the test in its own environment before involving a partner.
The module's probes cover distinct techniques. MarkdownImageExfil and StringAssemblyDataExfil test whether injected instructions can get the model to place sensitive text into an image URL or a link, which the browser then requests from an external host. ColabAIDataLeakage tests a related leakage pattern in notebook-style AI output. MarkdownXSS and TaskXSS test whether output can carry script or markup that the interface executes. Each probe is a plugin with its own detectors, so the report shows which technique succeeded rather than a single pass or fail for the whole UI.
Run this test when the chat product renders model output as markdown or HTML, when responses can include links or images, or when the model reads content from users, documents or web pages that an attacker could influence. It is also relevant before a product goes into a customer security review that asks about output handling. Before you start, confirm with your front-end team which markdown features are enabled, whether image loading is allowed to external domains, and whether any sanitizer runs before rendering. Those settings decide what a positive result means. The fix usually sits in the front end: restrict image and link domains, sanitize output with a maintained library, set a content security policy, and retest with the same probes after each change.
Which web injection probe covers which failure
garak's web_injection module groups probes by how a chat front end can be abused: data leaving through rendered markdown, data assembled in ways that slip past simple filters, and script running in the browser. Each card below names one probe, the rendering behavior it exercises and the risk it points to. Confirm each behavior against the probe source before you rely on a result.
MarkdownImageExfil
This probe tests whether model output can make the chat client fetch an image whose URL carries conversation data in its query string. If the interface renders markdown image syntax automatically, the browser sends that request to a third-party host without any user click. Check whether your client renders external images, whether it proxies or blocks them, and whether a Content Security Policy restricts image sources.
Probe sourceStringAssemblyDataExfil
This probe covers exfiltration when the model builds the leaking URL in pieces instead of writing one obvious image tag. A filter that looks only for complete markdown image or link patterns can miss the assembled result. Test whether your renderer or sanitizer evaluates or joins fragments, and whether output is checked after rendering rather than only before.
ColabAIDataLeakage
This probe targets leakage in notebook-style and code-cell interfaces, where model output may be executed or rendered with access to the session's data. Its relevance depends on whether your product runs generated code or displays it with privileged context. Confirm with the probe source which output shapes it generates, then check what the rendering surface can read and send.
MarkdownXSS
This probe tests whether markdown output can carry HTML or script that executes in the user's browser when the chat is rendered. A successful result means the front end trusted model text as markup, which exposes session tokens and page content to any script the model emits. Check the markdown library's raw HTML setting, the sanitizer configuration and whether dangerous attributes are stripped.
TaskXSS
This probe tests script injection through task-style prompts, where the model is asked to produce content such as a page, widget or formatted block that the interface then displays. The risk is that the instruction, not the chat text, becomes executable markup. Test each output path that accepts generated HTML, including previews, exports and shared links, because each one can have different sanitization.
How model output becomes a data leak in a chat UI
A chat interface can leak data without the model ever sending it anywhere directly. The chain starts when an injected instruction, carried in a user message, a retrieved document or a tool result, persuades the model to write a markdown image such as !status where the query string carries conversation content. If the chat front end renders that markdown, the browser fetches the image on its own, and the request delivers the data to the attacker's host in the URL. Nothing in the model's answer looks unusual to the user. The same pattern works with links the user is invited to click, and with output that is assembled from fragments so that no single chunk looks like a URL.
Injected script is the second path. If the front end converts model output to HTML and inserts it into the page without sanitization, any tag or attribute the model emits runs in the context of the application. In that case the attacker's code can read the session token, the conversation history visible on screen, or any value the page holds, and can call the application's own APIs as the signed-in user. Stored conversations, shared chat links and admin views all widen the reach of one injected response. Whether either path is a real exposure depends on three things: what the UI renders (images, links, raw HTML), what it can fetch (outbound network access, content security policy, image proxies), and what session data the page holds (cookies, tokens, other users' threads).
Before writing any test, confirm these three facts for the product under test with its engineering team, and record the answers, because the same model output can be harmless in one front end and serious in another. Ask whether the renderer allows raw HTML, which sanitizer and version it uses, whether a content security policy restricts image and script sources, whether session cookies are marked as not readable by scripts, and whether images are proxied through the vendor's own domain. garak's web injection probes exercise the first two paths, so the results only mean something when the team knows which of these controls is actually in place.
Scan options and when each fits a chat product
This table compares the main scan choices for a chat interface: which probes to run, how to connect the chat backend, how many generations to request, and whether to keep the default harness. Read each row against the release cycle of your chat front end, since a rendering change calls for a different scan than a routine model swap.
| Option | What it covers | When it fits |
|---|---|---|
| Web injection probes only | The web_injection family, including MarkdownImageExfil, StringAssemblyDataExfil, TaskXSS and MarkdownXSS, aimed at rendering paths | Quick check before a release that changes how markdown, images or links are rendered |
| Full probe set | All probe families, covering jailbreaks, prompt injection, leakage and toxicity alongside rendering tests | Fuller rerun after a model change, a new system prompt or a major front-end change, where output behavior may shift in several places |
| REST generator with YAML | Sends prompts to your chat backend's HTTP endpoint, described in a short YAML file, so the test uses the real request path | Testing the product as users reach it, including any middleware, prompt templates or filters between the user and the model |
| Direct model generator | Calls a model provider or local runtime without your application layer | Isolating whether the model itself emits risky markdown, useful for comparing base and fine-tuned models before wiring the UI |
| Generations per prompt, default of 5 | Each prompt is sent several times, and the probe is marked FAIL if any attempt produces undesirable output | Keep the default for release gates, where one rendered exfiltration link is enough to block a change. Lower values suit quick local iterations only if you accept missed intermittent failures |
| Default probewise harness | Runs each probe with its recommended detectors and reports results per probe | Standard choice for most chat scans, and the setting that keeps results comparable across reruns |
| Custom harness or detector changes | Changes which detectors judge the output, which alters what counts as a failure | Only after you have confirmed what a detector flags in your product, and only with a note in the scan record explaining the change |
Running a web injection scan against your chat UI
This sequence takes a chat backend from a clean garak install to a reviewed set of web injection results, with a check at each stage so that failures are traced to the right layer. The output is a JSONL report and a garak.log file that the front-end and security teams can read together.
Confirm the Python version and install garak
The engineer running the scan checks that Python 3.11 or newer is available on the Linux or macOS host, then installs garak from PyPI with pip in a dedicated virtual environment. Pin the version you intend to report against, because results can shift between releases. Done means
garak --helpruns without errors and prints the command-line options, which confirms the install is usable before any network calls are made.Describe the chat backend in a REST generator file
Write a short YAML file that names the chat backend endpoint, the request body shape, the header or token used for authentication, and the path in the JSON response where the model's text appears. Use a test or staging deployment with a non-production account. Keep the file in version control so the same configuration can be rerun later. Plaintext responses need no response path. Confirm the field names with the team that owns the chat backend, since a wrong path produces empty or misread output.
Check the generator reaches the model
Before any probe runs, send a single known-safe prompt through the generator, such as a request for a short greeting, and read the response that garak logs. The engineer confirms that the reply is the model's text and not an error page, a login redirect or a truncated JSON fragment. If the reply is wrong, fix the YAML or the credentials first, because a broken generator makes later results meaningless.
Run the web injection probes
Launch garak against the generator with the web injection probe module selected, using the probe specification from the garak documentation for the web_injection family. The module includes MarkdownImageExfil, StringAssemblyDataExfil, MarkdownXSS, TaskXSS and ColabAIDataLeakage. Keep the default generations per prompt unless you have a documented reason to change them, and record the exact command in the test plan. Expect the run to take as long as the backend takes to answer the prompts.
Read the JSONL report for each attempt
Open the JSONL report written for the run. Each line records one attempt, the model output and the detector verdict. Filter for probes marked FAIL and read the raw output of those attempts, looking for markdown image or link syntax that points to an external host, or for script-like content in the reply. A FAIL means at least one attempt produced undesirable output, so the reviewer should check whether the rendered page would actually behave that way.
Review garak.log for errors and gaps
Open garak.log, which is continued across runs, and search for timeouts, authentication failures, rate-limit responses and parse errors. A probe that errored out is not a pass, so list any probes with errors as untested. Compare the run timestamps in the log with the report to confirm they describe the same scan. Hand the reviewed report and log to the front-end owner, who decides which rendering rules to test in the browser next.
What the front end must do when the probes hit
When a markdown exfiltration or XSS probe fails, the fix sits in the front end that turns model output into HTML, not in the model. Start by confirming how your markdown renderer treats raw HTML. Check whether it is disabled, sanitized through an allowlist, or passed through untouched, and whether the sanitizer runs on every path that writes model text into the page, including streamed tokens, edited messages and shared conversation views. Ask the team to show you the exact configuration key or library option that controls this, because a renderer default that looks safe in one component often differs in another.
Next, review image loading and outbound links. A markdown image pointing at an attacker-controlled host can carry conversation data in its URL, and the browser fetches it without any user click. Confirm whether the chat client loads external images at all, whether it restricts them to an approved host list, or whether it routes them through a proxy that strips query strings and logs requests. For links, confirm whether the client displays the true destination before navigation and whether rel attributes and target handling are set consistently. Treat each of these as a question for your frontend stack, since the behavior depends on the renderer, the sanitizer and any custom components your team has added.
Finally, check the layers that limit damage if a control slips. A strict Content Security Policy restricts where scripts, images and connections may load from, and it should be tested by re-running the failing probes after the change rather than assumed to work. Confirm that session tokens never appear in URLs, since a token in a query string can be exfiltrated by the same image or link technique the probe uses. Ask the team to verify these settings in a staging build with the probe output open beside it, and to record which probes still fail so the retest in your next scan has a clear baseline.
Security and operational considerations for chat UI testing
A chat UI scan sends adversarial prompts through a live product, and the output it produces can contain sensitive material. The cards below cover where to run the test, how to protect the evidence, how to handle endpoint credentials, and when to scan again.
Run against a non-production deployment
Point the scan at a staging or pre-production copy of the chat product that uses the same renderer, sanitizer and model configuration as production. Injection probes intentionally generate links and images that point to external hosts, so a production deployment can log requests, trigger outbound calls or show test content to real users. Confirm with your platform team that outbound traffic from the test environment is logged and allowed only where you expect it.
Use dedicated test accounts
Create test users with the same role and permission set as the users you are protecting, but with no access to real customer records or shared knowledge bases. Chat history, uploaded files and conversation memory tied to these accounts should be seeded with synthetic data only. If the test account can reach real data, a successful exfiltration probe becomes a real data exposure, and the test is no longer safe to run.
Control access to report files
garak writes a JSONL report of every attempt and its evaluation, and a garak.log file that accumulates across runs. Prompts and model replies can echo synthetic secrets, system prompt fragments or test tokens, so treat these files as sensitive. Store them in a restricted location, set retention limits your security team agrees to, and record who can read them before the first run.
Handle the live endpoint credentials
The REST generator configuration file usually holds an API key or session token for the chat endpoint. Keep it out of source control, load it from a secrets store or environment variable at run time, and use a key scoped to the test environment with a short lifetime. Rotate it after the engagement and confirm that garak.log does not echo the header values.
Rescan after renderer or sanitizer changes
A fix for MarkdownImageExfil or MarkdownXSS is only as durable as the sanitizer behind it. Rerun the web injection probes after any upgrade of the markdown library, change to the allowed tags or URL schemes, update to the content security policy, or change in how the front end handles streamed tokens. Compare results against the prior baseline, and keep the scan in the release checklist so regressions surface before users see them.
web_injection probesQuestions teams ask before testing their chat UI
Is garak free to use for testing our chat interface?
Yes. garak is an open-source tool licensed under Apache 2.0, developed in the NVIDIA GitHub organization, and its maintainers describe it as a free tool. The license covers the software, not your time. Your costs come from the engineers who configure and run scans, the model or endpoint calls the scans make, and any help you buy to interpret results or fix the front end. Read the license text and the garak README before adopting it, and confirm with your legal team how the license applies to your internal use.
What does a markdown exfiltration and XSS test cost in effort?
The tool is free, so effort is the main cost. Most of it is one-time setup: pointing garak at your chat endpoint, confirming how responses arrive, and choosing the web injection probes that match your rendering path. Recurring effort comes from rerunning scans after front-end or model changes and reviewing findings. Effort rises with the number of rendering paths (chat, previews, exports, embedded widgets), the amount of authentication and session handling in front of the endpoint, and how many people must review and fix the output. Ask any partner for a quote built from a written scope that lists these paths.
How long does a first scan take to set up?
The duration depends on your environment, so the honest answer is that it varies with access and preparation. A scan can start quickly when the endpoint is reachable, returns plain text or JSON, and a single account can send prompts. Setup takes longer when responses stream, the chat UI sits behind single sign-on or session tokens, or the rendering logic lives in several services. garak's REST generator is configured with a short YAML file describing the endpoint, so the configuration itself is small. Confirm the endpoint shape and access model with your engineers before you plan the calendar.
What must our team provide before the test starts?
Three things block most engagements. First, endpoint access: the URL, the request and response format, and a way to call the chat path from the test host. Second, test accounts with the same roles and permissions your real users have, so the scan covers what users can actually see. Third, named owners for the rendering code, such as the team that maintains the markdown renderer, sanitizer, content security policy and any image proxy. Those owners must be available to explain behavior and approve fixes. Also agree on a safe test environment and who may receive the JSONL report, since it records every attempt.
Can an internal security team run this test without outside help?
Yes, if the team has someone comfortable with Python, the command line and HTTP APIs, and a front-end engineer who can read the renderer and sanitizer code. garak installs from PyPI with pip and requires Python 3.11 or newer, and its user guide at docs.garak.ai covers configuration. The harder part is judgment: deciding which probe results are real exposure, which are false positives, and whether a fix closes the path. Teams often run the scan themselves and bring in outside testers for an independent review, a retest after fixes, or a rendering path that the internal team cannot inspect.
What does garak's JSONL report show for markdown and XSS probes?
Each run writes a JSONL report of every attempt and its evaluation, and garak.log keeps debugging detail across runs. For web injection probes, the report shows which prompts produced output that a detector judged undesirable, such as an image or link whose URL carries data or a script payload. A FAIL result marks a probe where any attempt produced undesirable output, so one occurrence can be enough to warrant a fix. Read the raw attempts rather than trusting the summary alone, and confirm each finding in the real browser, because the detector judges model text, not what your renderer actually does.
What should we do when a probe hits our chat UI?
Reproduce the hit in the actual chat client with a test account, then trace where the model output becomes HTML. Common fixes include disabling automatic rendering of remote images, restricting link and image domains, sanitizing HTML output, applying a strict content security policy, and proxying any image fetch so it cannot send data to an attacker-controlled host. Each change should be followed by a rerun of the same probes and a check that normal formatting still works. Keep the before and after reports so you can show the fix and its verification to reviewers.
How a probe travels from garak to the browser
The walk starts in garak, where a web injection probe sends a crafted prompt through the REST generator to the chat backend. The model's reply returns through the chat UI renderer, which turns markdown into images, links or HTML. The trust boundary sits where the browser fetches an image URL or runs script. Check two things: whether the detector flags the reply in garak, and whether the browser ever makes the request or executes the payload.
Probe path from garak through the chat stack to the browser's trust boundary.
How DeployOpen scopes a chat UI markdown and XSS test
DeployOpen scopes this test as a fixed-scope engagement, and the scope starts with the chat endpoint itself. Before work begins, both parties agree in writing on the exact endpoint under test, the rendering stack that turns model output into the page (the markdown parser, sanitizer, any allowed-tag list and the component that draws images and links), the test accounts and roles that will be used, and the deliverables. Test accounts matter because markdown rendering often differs between a workspace admin, a standard user and a shared link view, so each role that can see model output should be named in the scope.
Once the scope is signed off, the work runs in two parts. The first is the garak scan, where DeployOpen configures the web_injection probes, including MarkdownImageExfil, MarkdownXSS and TaskXSS, against the chat endpoint and keeps the JSONL report and garak.log from every run. The second is application testing by hand, which checks what garak cannot see: whether the front end renders the output, whether images fetch from outside domains during a session, and whether injected script executes in the browser. The written deliverables should separate the two, so a finding from the scan can be confirmed or rejected by a tester looking at the actual page.
The deliverables usually include a findings report with severity, the reproduction steps, the rendering and sanitizer changes that DeployOpen recommends, and a retest after the client's developers apply fixes. Fixes to the client's front end are carried out by the client's own team unless the written scope says otherwise. If the organization wants help beyond the first report, such as repeated scans after each release, a retainer can cover ongoing support and retesting. Ask for the retest count, the response window and the rescan cadence to be written into the scope so the quote can be compared with other options.

