Why test Unicode and token smuggling tricks in garak
If your LLM application relies on keyword lists, regex rules or a text classifier to block harmful requests, you need to know whether character-level disguises get past them. garak can test that directly. Its badchars, smuggling and DRA probe families send the same kind of request in forms a filter may not recognize, and the results show whether your model or guardrail still refuses. garak is an Apache 2.0 licensed command-line tool, so the test can run inside your own environment against the endpoint you actually ship.
The three families attack from different angles. The badchars probes apply imperceptible Unicode perturbations, including invisible characters, homoglyphs, reorderings and deletions, inspired by the Bad Characters research. The smuggling probes, HypotheticalResponse, HomoglyphObfuscation and FunctionMasking, hide contentious terms among benign text so that a keyword match fails while the model still understands the intent. The DRA probes take a harmful string, disguise it, and ask the model to reconstruct it through string manipulation. Each family tests a different weakness, so a pass on one says little about the others.
Before running them, confirm which filter sits in front of the model, whether it normalizes Unicode before matching, and which outputs your application shows to users. A failure only matters if the disguised request reaches the model and the response reaches a user or downstream system. Treat a fail as evidence that a filter layer needs normalization, homoglyph mapping or output checks, and plan a retest after each change, using the same probes and detectors so the comparison holds.
What the badchars, smuggling and DRA probes send
garak's Unicode and disguise probes share one question: does a filter judge a request by its meaning or by its surface form? Each family changes the surface of a request while keeping the intent, then checks whether the model still responds in a way the detectors flag.
Badchars imperceptible perturbations
The badchars probe inserts invisible characters, swaps in homoglyphs, reorders characters and deletes them, so the prompt looks normal to a person but reads differently to a tokenizer. It is inspired by the Bad Characters paper. Check whether your input normalization strips or flags these characters before a model or classifier sees them. A failure means the model answered a request it would refuse in plain text.
garak READMEHypotheticalResponse framing
The HypotheticalResponse probe in the smuggling module wraps a contentious term inside otherwise benign text, often as a hypothetical or descriptive answer. The harmful term is hidden among harmless wording, so a keyword filter that looks for the term alone may miss it. Check whether the model's answer repeats or expands the hidden term in a way the detectors score as undesirable.
Smuggling probe sourceHomoglyphObfuscation substitutions
The HomoglyphObfuscation probe replaces letters in sensitive terms with visually similar characters from other scripts, so the word looks the same to a reader but not to a string match. It tests whether the model still recognizes and acts on the term after substitution. Check your blocklists and guardrails for case folding and script normalization, because a failure here usually means an exact-match filter is the only control.
Smuggling probe sourceFunctionMasking disguised requests
The FunctionMasking probe hides a contentious term inside a function-like structure or code-style wrapper, mixed with benign text. It checks whether the model treats the disguised content as an ordinary task and returns it. This matters for assistants that accept code, JSON or tool-call style input. Check whether your application validates structured input against the same policy as free text.
DRA disguise and reconstruction
The DRA probes send harmful strings that have been disguised, then ask the model to reconstruct them through string manipulation such as reversal, splitting or reassembly. The model completes the reconstruction and may then act on the result. A failure means the safety behavior applied to the plain request did not carry over to the assembled one. Check whether outputs are scored after reconstruction, not only on the original prompt.
DRA probe sourceHow disguise and reconstruction get harmful requests past filters
A keyword filter, a regular expression or a safety classifier works on the text it sees. Text altered at the character level can look different to the filter while still carrying the same meaning to the model. A homoglyph replaces a Latin letter with a visually identical character from another script, zero-width characters break a word into fragments that no longer match a blocklist, and reordered bidirectional text can display one phrase while the underlying string says another. Splitting a request across a reasoning step has a similar effect: each fragment looks harmless on its own, and the instruction is only assembled after the filter has already passed it. Whether a given model or guardrail misses these forms is an empirical question, and the answer depends on its tokenizer, its training and the filter placed in front of it.
The same logic applies to disguise-and-reconstruction attacks. A harmful string is hidden as something that looks benign, such as a scrambled, reversed or masked form, and the prompt asks the model to undo the transformation. garak's smuggling probes apply this pattern, including HypotheticalResponse, HomoglyphObfuscation and FunctionMasking, which hide contentious terms among benign text. The DRA probes in dra.py follow the same idea by giving the model a disguised string and asking it to reconstruct the original. Because the model is the component doing the decoding, a filter that only inspects the incoming text may never see the intent. Treat these as tests of the whole chain, not only the model: the filter, the system prompt and the model's refusal behavior all have to hold together.
Before you rely on a filter, decide what it is meant to stop and where it sits. Confirm whether your filter normalizes Unicode, strips zero-width and bidirectional control characters, and runs before or after any decoding the model performs. Then run the smuggling and DRA probes against the full endpoint, not a bare model, so the result reflects your guardrail. Record which probe families fail and at what rate, since a failure rate on one probe says little about another. Results are only meaningful for the deployed configuration, so any change to the filter, the model or the system prompt means the test should be repeated.
How a smuggling probe travels from garak to your filters
The run starts in garak, where a probe such as badchars or smuggling builds the disguised prompt and, optionally, a buff transforms it before sending. The prompt then crosses your input filter, which is the first point where your own controls can act, before reaching the model. The model's response is scored by the probe's detectors, and every attempt and its evaluation lands in the JSONL report. Check whether the filter normalizes Unicode before matching, and whether the detector sees the raw output.
Path of one smuggling attempt across the garak and application trust boundary.
Which smuggling probe fits which exposure
This table compares garak's badchars, smuggling and DRA probes by what each disguises, where it fits in the request path, and when a team should run it. Read each row against your own architecture: an input filter, a bare model, or an output check. The main takeaway is that the disguise technique should follow the control you are testing, not the other way round.
| Probe family | What it disguises | Where it fits | When to run it |
|---|---|---|---|
| badchars | Invisible characters, homoglyphs, reorderings and deletions applied to the request text | Input filters and normalization steps before the model sees the text | When a text filter, keyword blocklist or moderation layer sits in front of the model and may not normalize Unicode |
| Smuggling: HypotheticalResponse | Contentious terms hidden inside benign framing text | Model-only testing, and application inputs that pass prompts unchanged | When the application passes user text straight through and you need to see whether the model answers the hidden request |
| Smuggling: HomoglyphObfuscation | Harmful terms written with look-alike characters | Input filters that match exact strings, and models that must read the intent | When keyword or string-match filters are part of your defenses and you want to test their coverage |
| Smuggling: FunctionMasking | Requests disguised as function or code-style structures | Tool-using or code-capable deployments where the model may treat input as structured | When the model or application handles structured input, tool calls or code generation |
| DRA probes | Harmful strings split, disguised and asked to be reconstructed through string manipulation | Model-only testing, with output checks needed to judge whether reconstruction happened | When the model is exposed to users who can ask for transformations, or when you want to test reconstruction behavior directly |
| Input filter coverage | Depends on the probe run, with badchars and homoglyph probes most relevant | Pre-model filters, guardrails and normalizers | Before release, and after any change to filtering rules or Unicode handling |
| Output checks | Harmful content the model produces after decoding or reconstruction | Post-generation moderation and detectors | Confirm which detectors score each probe in your garak version and configuration before reading results |
Running badchars, smuggling and DRA probes in garak
This sequence takes a team from a clean garak install to a first recorded run of the badchars, smuggling and DRA probes against a target they control. Each step closes with a check so the team knows the run is valid before it scales up the testing.
Install garak from PyPI
An engineer on the test host installs garak with pip from PyPI into a dedicated virtual environment, using Python 3.11 or newer. The package is a command-line tool, developed on Linux and macOS, so run the install on one of those hosts. Confirm the install by running
garak --helpand checking that the command prints its usage text without import errors. Record the installed version so that later reports can be tied to the exact release.Configure a generator for the target
Choose the generator that matches the target. Native generators cover models such as Hugging Face Hub, OpenAI API, AWS Bedrock and LiteLLM, while the REST generator reaches any endpoint that returns plaintext or JSON. For a REST application, write a short YAML file describing the endpoint, the request body and the response field, and keep it in version control. Confirm the configuration with a single test prompt sent through the generator, and check that the reply comes back in the expected shape before any probe is run.
List the smuggling and DRA probes
Run garak's probe listing command to see the available probe names, then filter for the three families this topic covers:
badchars, the probes insmuggling(HypotheticalResponse, HomoglyphObfuscation and FunctionMasking), and thedraprobes. Note the exact probe names, because the run command takes them as arguments. Confirm that each family appears in the listing. If a family is missing, the installed version may predate it, so check the release notes before continuing.Run the chosen probe family
Start with one family, typically
badchars, and run it against the configured generator using the probe name from the listing. Keep the default of 5 generations per prompt for the first run so results are comparable with later runs. Expect the run to take longer on hosted endpoints than on a local model, and ask the endpoint owner in advance about rate limits. Confirm the run started by watching the console for the probe name and a progress line. Do not start the other families until the first one has finished cleanly.Open the JSONL report
When the run ends, garak writes a JSONL report with one record per attempt and its evaluation. Open the report file and find the entries for the probe you ran. Check that each record holds the prompt that was sent, the response the target returned and the detector result. Confirm the run is valid by counting that at least one attempt is recorded for the probe, and that the record shows the detector that scored it. An empty or partial report means the run should be repeated before any finding is written down.
Check garak.log for errors
Open the garak.log file, which garak continues across runs, and read the entries written during the latest run. Look for generator timeouts, parsing errors from the REST configuration, and detector warnings. These messages explain why an attempt scored oddly or produced no output. Confirm the run is clean when the log shows the probe starting and finishing with no error entries tied to the target. Keep the log with the report so that a later reviewer can see how the run was produced.
Repeat for the remaining families
Once the badchars run is clean, repeat steps three to six for the smuggling probes and then the DRA probes, saving each report under a separate name. Ask the team that owns the application which of these techniques its filters are meant to stop, because that decides which results matter most. Confirm each family by checking its own report for recorded attempts. Without a written scope agreed with the application owner, the test results do not show what the application actually blocks.
Reading results when a probe fails or passes
A FAIL on a bare model means the model itself produced undesirable output when a Unicode or disguised prompt reached it without any application layer in front. garak marks a probe as FAIL with a failure rate when any of the default 5 generations for a prompt produces undesirable output, so a single fragment from one attempt is enough to flag the probe. That makes the result a statement about the model's own behavior under the attack, not about your product's defenses.
- Read the failure rate, then the attempts: Open the JSONL report and check how many prompts failed and which generations produced the output. A failure in one of five attempts points to intermittent behavior, which needs a wider sample before it is treated as settled.
- Check which detector flagged it: The detector decides what counts as undesirable. Confirm that the flagged text really answers the harmful request rather than matching a keyword.
- Compare with the decoded request: Some smuggling probes hide a request that the model decodes and then answers. Confirm the model reconstructed the contentious term before concluding it was tricked.
- Record the model version and settings: Temperature, system prompt and generator settings change results, so store them with the report.
- Plan the model-level response: Model choice, fine-tuning or a separate guard layer are the options, and each should be decided against the application's exposure.
Before you act on a bare-model FAIL, confirm the detector, the attempts and the model settings with the report in hand.
A FAIL that appears only on the full application, with input filters, output scanners or a guardrail in place, tells you something different. The bare model may refuse the request, while the filtered application lets it through, or the reverse. The gap sits in how the layers interact, so the test should be read against the whole request path, not the model alone.
- Run the same probes both ways: Compare the bare model run with the application run using the same probe set, generations and detectors. Differences isolate the layer that changed the outcome.
- Test the normalization step: Many filters match on raw text. If the application strips or normalizes characters before the model sees them, or does not, the smuggled form may reach the model in a different state than the one you tested.
- Look at what the filter returns: A filter that blocks a request by failing closed may hide the model's answer, while a filter that logs without blocking may pass the output through.
- Verify the rendering path: Check whether invisible characters survive into logs, UIs and downstream tools, because the application may show or store text the filter never inspected.
- Document the boundary: Record which control stopped which variant so that a later change to any one layer can be retested.
Before assigning a fix, confirm which layer produced the difference by rerunning the probe with that layer removed or replaced.
A PASS means no attempt produced output that the configured detectors scored as undesirable. It does not mean the model or application is safe against smuggling. The result is only as strong as the detector and the attack variants you ran, and a detector that cannot recognize a disguised or partly decoded answer will report a pass on a real failure.
- Question the detector fit: Check whether the detector looks for the harmful content in the form the model actually returns. A detector built for plain text can miss a reconstructed term or an answer written in a different script.
- Check the probe coverage: A pass on one badchars variant says little about others. Confirm which perturbation types and smuggling patterns were included in the run.
- Sample detector output by hand: Read a set of passing responses and confirm that none contains the target content in a form the detector missed.
- Note the attempt count: Five generations per prompt is the default. A pass with few attempts gives weak assurance, so record the settings used.
- Keep a known-bad control: Include a prompt the model is known to answer, so you can confirm the detector and probe still produce a FAIL when they should.
Before you report a PASS as assurance, confirm with the detector owner that it recognizes the disguised output your probes produce.
Sometimes a run completes with no undesirable output across any probe. Before treating that as a clean result, confirm the run actually exercised what you intended. A run can finish quickly and show nothing because the probes did not load, the generator failed, or the responses were empty or errors.
- Inspect garak.log: The debugging log is continued across runs, so check the current run's entries for generator errors, timeouts and skipped probes.
- Confirm attempts were made: Look in the JSONL report for the expected number of attempts per prompt. Missing or empty responses mean the test did not reach the model.
- Check the probe names: Confirm the badchars, smuggling and DRA probes you selected appear in the run, since a mistyped probe selection can produce an empty but apparently clean run.
- Review response content: Read a sample of responses to confirm the model answered the requests, rather than returning refusals, template text or formatting that a detector would never flag.
- Rerun with a control: Add a probe with a known result to confirm the pipeline reports failures when they exist.
Before recording the run as clean, confirm with your team that the attempts reached the model and produced real responses.
Security and operational considerations for smuggling tests
Smuggling probes generate payloads that are harmful by design, and the reports, logs and endpoints around them carry that content too. The cards below cover where test material lives, which endpoint receives it first, what the target retains and how the local debug file is handled.
Store payloads and reports in controlled storage
Badchars, smuggling and DRA runs write attempts, prompts and model outputs into the JSONL report, and those files often contain disguised harmful requests in readable or reconstructable form. Decide before the first run where reports live, who can read them and how long they are kept. Restrict the output directory to the test team, encrypt it at rest, and keep it out of shared drives, chat channels and general CI artifacts. Confirm the retention period with your security policy owner rather than leaving it to the default of the file system.
Run against non-production endpoints first
Start with a staging or sandbox copy of the application so that filter bypasses, unexpected completions and rate-limit spikes do not reach customers. Smuggling probes often reveal that a guardrail is misconfigured, so a first run against production can trigger alerts, fill abuse queues or change moderation state. Use a test configuration with the same system prompt, filters and tool access as production, and move to production only after a scoped, approved run. Document which environment each report came from.
Check what the target's logs retain
Every adversarial prompt sent through the application may be written to prompt logs, tracing backends, analytics stores or vendor-hosted moderation logs. Before the scan, ask the team that owns the target which logs capture request and response bodies, how long they persist and whether policy permits storing deliberately harmful content. Where policy does not allow it, agree on log suppression or a dedicated test tenant. Confirm the answers in writing, because a scan can leave a copy of the attack set in systems no one planned to audit.
Handle garak.log as sensitive output
The garak.log debugging file is continued across runs and can record prompts, responses, endpoint details and sometimes credentials in request or configuration traces. Treat it with the same controls as the JSONL report, and review its contents before sharing a log with a vendor or support channel. Set a rotation or cleanup step in the runbook so that old logs from earlier smuggling runs do not accumulate. Confirm with the garak maintainers' user guide at docs.garak.ai which settings control log verbosity in your installed version.
garak user guideQuestions teams ask before testing smuggling attacks
Is garak free to use for smuggling tests?
Yes. garak is open source under the Apache 2.0 license, and its maintainers describe it as a free tool. The license covers using the tool, but it does not cover the cost of the people who set up endpoints, interpret results and fix findings. Those costs sit with your team or with a partner you hire, and they are the part a quote will reflect. Confirm the license terms for your own use with your legal team, and read the project's garak user guide for current usage notes.
What does a first smuggling test run require to set up?
The first run needs a Python environment, the garak package installed from PyPI with pip, and Python 3.11 or newer. Effort then depends on how your model is reached. A hosted model with a supported generator is quick to point at. A custom application usually needs a REST generator configured with a short YAML file describing the endpoint, plus a check that the responses come back as plaintext or JSON. Most of the time goes into agreeing the target, the system prompt and the permitted inputs, not into typing the command.
Can an internal team run the badchars, smuggling and DRA probes alone?
Yes, if the team has someone comfortable with Python, command-line tools and API authentication. The commands are simple, and the JSONL report and garak.log give a clear record of each attempt. The harder part is judgment: deciding which probes match your exposure, whether a detector's verdict is correct, and how a finding should be fixed in the filter or application layer. Teams that lack this experience often run the scan once, read a FAIL as a verdict, and stop there. Plan a reviewer who can read the outputs before you rely on them.
What does the work need from our team?
Three things should be settled before testing starts, in writing:
- Endpoint access: a test deployment or staging copy of the model or application, with credentials that can send prompts and receive responses.
- A test window: an agreed time when scans can run, especially if they create load or trigger alerts in monitoring and content filters.
- A remediation owner: a named person who decides what happens to each finding, such as tuning an input filter, normalizing Unicode before classification, or accepting a risk.
Without the third item, findings tend to sit in a report with no action taken.
How should we act on a FAIL result?
Treat a FAIL as evidence that a specific disguised input got past your controls, not as a final score. garak marks a probe as FAIL with a failure rate when any attempt produces undesirable output, and it makes 5 generations per prompt by default. Open the JSONL report, find the attempts that failed, and check the prompt, the response and the detector's decision. Then confirm whether the output is actually harmful in your context. If it is, decide whether the fix belongs in input normalization, output filtering, the system prompt or model choice, and retest the same probe after the change.
Does garak test whether our input filter normalizes Unicode?
It tests behavior, and the answer depends on what your application does with the text. The badchars probe sends imperceptible Unicode perturbations, including invisible characters, homoglyphs, reorderings and deletions, and the smuggling probes hide contentious terms among benign text. A FAIL shows that the combined system responded to a disguised request. It does not tell you which layer caused it. Confirm the pipeline order with your engineers, for example whether text is normalized before a moderation or allow-list check runs, and rerun the probes after changing that order.
Will a smuggling scan replace a security review of our application?
No. The probes cover a defined set of disguise techniques against the model and the path you expose. They do not cover authorization, data access, tool permissions or the rest of your threat model. DeployOpen runs application and AI security testing as a separate scoped engagement, and it prepares evidence for compliance assessments, but it does not issue audit reports or certifications. Independent auditors and certification bodies make those decisions.
How DeployOpen scopes and delivers garak smuggling tests
This sequence turns a question about whether smuggling tricks get harmful requests past an application's filters into a written scope, a set of garak runs against the agreed endpoint, and a findings report with fixes and a retest. Each step closes with an output the client can check.
Agree scope, target and deliverables in writing
DeployOpen and the client agree which application, model endpoint and guardrail layers are in scope, which garak probes apply (badchars, smuggling and DRA families are the usual starting points), and what the client receives. The client confirms who may send traffic to the endpoint, which test accounts exist, and whether a non-production environment is available. The step closes with a signed scope document that lists the endpoint, the probe families, the detectors and the report format.
Map the target and its filters
The team documents how a request travels from the user to the model, including any input filter, output scanner, system prompt and tool layer. It records the endpoint type and whether garak can reach it through an existing generator or needs a REST generator configuration. The output is a short architecture note that shows where Unicode normalization, text cleaning or keyword matching may occur, which tells the team where a smuggled string should be expected to survive or fail.
Configure the garak run and baseline
The engineer installs garak from PyPI on a host with Python 3.11 or newer, writes the endpoint configuration and selects the badchars, smuggling and DRA probes. A benign baseline run confirms that the endpoint responds, that the detectors fire on known outputs and that the JSONL report and garak.log are written. The step closes with a configuration file in version control and a baseline report the client can inspect before any adversarial prompts are sent.
Run the smuggling and disguise probes
The team runs the agreed probes against the agreed endpoint. Badchars probes send invisible characters, homoglyphs, reorderings and deletions. Smuggling probes hide contentious terms among benign text, and DRA probes ask the model to reconstruct a disguised string. Garak's default generation count applies unless the scope changes it. The output is a complete JSONL attempt log and a probe-by-probe summary that marks each probe as passing or failing with its failure rate.
Review failures and separate filter gaps from model behavior
Engineers read the failing attempts and classify each one. A failure may occur because the input filter never normalizes the characters, because the model decodes and complies, or because a detector scored an output incorrectly. The team checks detector outputs against manual review of a sample. The output is a triaged list of findings that states, for each one, which layer let the request through and what evidence supports that conclusion.
Deliver findings with fixes
DeployOpen writes a findings report with reproduction steps, the affected probe and endpoint, the layer responsible and a recommended fix. Fixes may include Unicode normalization before filtering, stripping of bidirectional controls, output scanning, or model-side changes that the model provider owns. The client reviews the report with its security and platform teams. The step closes when the client accepts the report and the fix owners are named.
Retest after changes and hand over
After the client applies fixes, the team reruns the same probes with the same configuration and compares the new report with the baseline and the original run. The comparison shows which failures are closed and whether any new ones appear. The output is a retest report and a versioned configuration the client can rerun. Where the client wants continuous coverage, a retainer can schedule recurring runs, upgrade garak and review new results.

