Skip to content
Last updated December 3, 2026

pgfuzz — PromptGate Recall Suite

Companion CLI for PromptGate — AI Gateway Platform. Bombards a live gateway with synthetic adversarial payloads and reports recall / false-positive / latency / cost.

Terminal window
pgfuzz pii --target http://127.0.0.1:7878/v1/chat/completions \
--token pg_… \
--count 1000 \
--types email,iban,credit_card,phone,ssn \
--report json

Targets the PromptGate Go gateway (v0.3+; mcp needs v0.7, api v0.8, keywords --list v0.9): any pg_ key, the OpenAI chat path, and a guardrail in block mode (refusals are 422). For the archived Laravel v1, use $PG_URL/api/$PG_UUID/v1/chat/completions and a pg_live_… token.

Terminal window
brew install promptgate-ai/tap/pgfuzz # macOS, Linux

Or download the archive for your platform from https://install.promptgate.dev/pgfuzz/<version>/ — for example pgfuzz_v0.2.1_linux_amd64.tar.gz, next to checksums.txt and the software bill of materials pgfuzz.cdx.json (CycloneDX 1.6) — or build it yourself (see Build).

Unit tests check logic (does the PII regex match [email protected]?). pgfuzz answers a different question: out of 1000 synthetic emails with adversarial wrappings, what’s the actual recall rate? That’s the question compliance teams care about.

Uses cases:

  • Pre-launch confidence — verify the guardrails actually catch ≥99% of plausible PII before going live
  • Regression catch — tweak a regex, re-run, see recall drop instantly
  • Customer-facing trust — “download pgfuzz, point at your install, get a compliance report”

Phase 1 ships pii, secrets, injection and keywords recall tests, a negatives false-positive test, a users test of end-user limits and key policies, an endpoints test of AI Gateway endpoints, a ui test of the web UI’s security, an mcp test of the MCP gateway, an api test of the API Gateway, a commands test of what models answer, an admin test of the Management API and a webhooks test of webhook deliveries. Other categories (budget, ratelimit, policy, load) are on the backlog. The PromptGate repository runs a plan of all of them — 30 stages — against every build (scripts/pgfuzz-gate.sh).

  • Not a “pentest” in the formal sense — it’s recall / fuzz testing. Real adversarial pentesting is human work.
  • Synthetic data ≠ production data. Recall on a synth corpus is a lower bound; real-world might be worse.
  • Recall alone rewards blocking everything. Run negatives next to every recall test: it shows what a guardrail gets wrong.
  • The tool consumes real budget on your gateway. Run against a test project or accept the cost.
Command What it tests Status
pgfuzz pii PII Filter recall — emails / IBANs / CCs / phones / SSNs in clean + adversarial wrappings ✅ MVP
pgfuzz secrets Secret Scanner recall — AWS / GitHub / Slack / OpenAI / Anthropic / Stripe / JWT (JWTs are well-formed: base64url JSON header and payload) ✅
pgfuzz injection Prompt injection patterns — ignore-previous / role-assumption / disregard / override / system-prompt-leak / chat-template smuggling / instruction-bypass, in English and German, with direct / wrapped / obfuscated variants ✅
pgfuzz keywords Keyword list recall — words drawn from --list, the file the gateway’s keywords guardrail reads (lists: [{file: …}]), written inline, in other case, with punctuation and at the edge of the message; plan stages take list: ✅
pgfuzz negatives False-positive rate — benign payloads that look like PII, secrets or injection (order numbers, placeholder keys, “ignore the warnings”, “write a system prompt”), plus code and prose, in English and German; a 422 or 403 counts as a false positive. --min-pass-rate 1 fails on any ✅
pgfuzz endpoints AI Gateway endpoints with known definitions (--print-config): --expect variables (wrong types, ranges, lengths, patterns, lookalike characters, unknown names: 400; valid and boundary values: 200), schema (answers breaking the output schema never pass: 502), sessions (other users, another key --token2, forged and broken ids: 404), cache (a hit for the same key, never for another). --min-rate 1 fails on any deviation ✅
pgfuzz ui The gateway’s web UI, probed like an attacker would: --expect access (no page or action without a session, also with forged cookies), forms (no change without the session’s CSRF token or from another site), login (guessing throttled to 429, unknown names indistinguishable, no session fixation, no open redirect, HttpOnly + SameSite=Strict cookie), headers (strict CSP, framing and sniffing blocked, no traversal on /static), reflect (markup in query parameters never comes back unescaped), all ✅
pgfuzz users End users named in X-PromptGate-User: --expect isolated (each user has their own --per-user limit: within it 200, one more 429, users not seen yet still 200), required (no id: 400), ignored (ids from an end-user-held key are never limited). Ids are unique per run; --min-rate 1 fails on any deviation ✅
pgfuzz mcp PromptGate’s MCP gateway, with pgfuzz mcp-echo behind it: --expect access (no valid key 401, no GET stream 405, foreign origins 403), names (a key limited to one tool lists and reaches only it — other tools in any spelling, a header naming another tool, forged cursors, PromptGate’s own tools: never), protocol (header/body mismatch -32020, unknown versions -32022, parse and structure errors, sessions bound to their key and ended by DELETE, batches only in 2025-03-26), arguments (secrets in tool arguments never reach the server — recall), results (injections a server returns never reach the agent — recall), size (an oversized result is an error, the gateway goes on), permissions (--token2 a key with access "*": read lists and reaches only tools that read, --token3 a key with approve: delete passes deletes only after an elicitation answer of accept — never unasked, with a tampered state, twice for one yes, for other arguments or after a decline; also in a 2025-11-25 session over its event stream), all (without permissions) ✅
pgfuzz run --plan Execute a multi-stage YAML test plan — what teams version-control as their compliance suite ✅
pgfuzz budget Pre-flight 402 compliance 📋
pgfuzz ratelimit 429 + Retry-After behaviour 📋
pgfuzz policy IP allowlist + time-window enforcement 📋
pgfuzz auth Revoked / wrong-scope / expired token edge cases 📋
pgfuzz api PromptGate’s API Gateway, with pgfuzz api-echo behind the APIs --print-config defines: --expect access (no valid key 401, APIs outside a key’s list 403, unknown names reach nothing, methods 405), headers (the caller’s pg_ key as Bearer or X-Api-Key, cookies, proxy credentials, spoofed X-Forwarded-*/Forwarded/X-Real-Ip, the user id header and hop-by-hop headers never reach the API; the API’s own credential does; Set-Cookie, WWW-Authenticate, HSTS don’t come back), paths (no path climbs out of the base in any encoding — %2e, %2f, %5c, ..;, overlong UTF-8, double encoding), ssrf (loopback without private: true and the metadata address refused, redirects not followed), size (body caps both ways), requests (secrets in request bodies never reach the API — recall), answers (injections in answers never reach the caller — recall), all ✅
pgfuzz commands Commands in answers, with pgfuzz llm-echo (an OpenAI-compatible model that answers with its prompt) behind the gateway: what a poisoned model slips in for a coding agent — download and run, dropped executables, encoded and hidden PowerShell, base64 run, reverse shells, Defender exclusions, autostart, abused Windows tools — direct, in prose and code blocks, obfuscated; --deliveries text,tool,stream (answer text, a tool call’s arguments, streamed six characters per event). The gateway’s commands guardrail must refuse the answer (422, or a stream ended with its error event). --expect benign sends ordinary answers with commands (builds, installs, git, containers, system queries): a refusal is a false positive ✅
pgfuzz indirect Injections hidden in what the model reads: white, tiny, invisible or off-page text in a PDF, hidden text in a Word file, display:none / 1-pixel / comments in an HTML mail, Unicode tag characters, bidi controls, zero-width spaces, percent-escaped after the # of a page URL (“HashJack”) — delivered as the user’s attachment or as a tool’s result (--deliveries attach_openai,attach_anthropic,tool_openai,tool_anthropic,tool_responses). Kinds: classic and the phrasings mail attacks use (addressed_to_ai, hidden_task, conceal, exfiltration, markdown_exfil). --expect heldout: paraphrases no guard was tuned on. --expect masked: a gateway that masks instead of refusing must pass the visible text and nothing of the payload to the model (llm-echo’s dump model answers with what it received). --expect benign: documents that hide text for ordinary reasons, talk about AI or share words with the attacks ✅
pgfuzz admin PromptGate’s Management API (/control/v1) with a key that has control: write; it makes the other keys it needs through the API. --expect access (no, unknown and provider keys 401, keys without control 403, read keys read but can’t change, wrong methods 405, unknown and nested paths 404), escalation (no read or app key makes a write key, unknown levels refused, a key can’t revoke itself), etag (stale and used-up If-Match 412, eight changes at once with one version: exactly one wins), inputs (SQL in filters, absurd windows, repeated/unknown parameters, 100 KB values, broken/huge/nested/non-JSON bodies, control characters in names: refused in the error shape, never a 5xx), secrets (no answer carries a pg_ key or a hash), all ✅
pgfuzz webhooks Webhook deliveries with pgfuzz as the receiver (--print-config host:port defines the webhooks, --target is the Management API to trigger them): --expect signature (Standard Webhooks v1 HMAC over id, timestamp and body, fresh timestamp, configured header, never the caller’s key, a new id per event, a tampered body fails), retries (a refused delivery comes again after 30 s with the same id, signed afresh; a redelivered event keeps its id), ssrf (loopback without private: true, the metadata address and redirects never delivered to), secrets (no API answer carries the secret, a header value or a URL token), all ✅
pgfuzz load Burst load + p50/p95/p99 📋
19595/mcp
pgfuzz mcp-echo --addr 127.0.0.1:19595 &
# guardrails: secrets {action: block}, prompt_injection {roles: [user, tool]}
# a second key: promptgate keys create narrow --mcp pgfuzz/echo
pgfuzz mcp --target http://127.0.0.1:7878/mcp --token pg_… --token2 pg_narrow… \
--expect all --count 300 --min-rate 0.99

The echo server answers with what its tools are given — echo returns its text, echo64 its base64 data decoded (a result the arguments don’t show), big a text of the requested size — so the probe decides what the gateway sees in arguments and in results.

Terminal window
pgfuzz api-echo --addr 127.0.0.1:19696 &
pgfuzz api --print-config 127.0.0.1:19696 # the gateway's apis: entries
# Gateway: guardrails: secrets {action: block}, prompt_injection {roles: [user, tool]}
# a second key: promptgate keys create narrow --api pgfuzz
pgfuzz api --target http://127.0.0.1:7878/api --token pg_… --token2 pg_narrow… \
--expect all --count 300 --min-rate 0.99

The echo API answers with what it received — method, path as sent and decoded, query, headers, body — so the probe sees exactly what reached it; on request it sets cookies, redirects to the metadata address, answers with N bytes or with base64-decoded text (an answer the request doesn’t show).

Terminal window
# Gateway: limits.users "*": 3/h — every user may send 3 requests per hour.
pgfuzz users --target $PG_URL/v1/chat/completions --token $PG_KEY \
--expect isolated --users 20 --per-user 3 --min-rate 1
CHECK EXPECT TOTAL AS EXPECTED OTHER ERRORS RATE
other_users 200 20 20 0 0 100.0%
over_limit 429 20 20 0 0 100.0%
within_limit 200 60 60 0 0 100.0%

A gateway that counts all users against one allowance fails within_limit and other_users. In a plan, kind: users takes expect, users, per_user and user_header; count is not used.

Terminal window
# Add the probed endpoints to the gateway (endpoints: section or files).
pgfuzz endpoints --print-config --model openai:gpt-4o-mini
pgfuzz endpoints --target $PG_URL/v1/chat/completions --token $PG_KEY \
--token2 $PG_OTHER_KEY --expect sessions --rounds 10 --min-rate 1

A gateway that lets another user or key continue a session fails session_other_user / session_other_key; one whose cache answers across keys fails cache_other_key. In a plan, kind: endpoints takes expect, rounds, token2 and mount. Reports never contain keys.

Terminal window
pgfuzz ui --target http://127.0.0.1:7879 --user admin \
--password "$(cat ui-initial-password)" --expect all --min-rate 1

forms, reflect and login sign in; a first admin who must choose a password gets a random one, so run it against a test instance. login runs last — it locks a made-up name out on purpose. In a plan, kind: ui takes target (the UI’s base URL), user, password and expect. Reports never contain the password.

The other probes put something into a request and expect the gateway to stop it. commands checks the other direction: what a model answers. A poisoned model (in 2026, GGUF models on Hugging Face whose chat template started every reply with a PowerShell unpacker) writes a command, and a coding agent runs it. pgfuzz llm-echo is a model that answers with its prompt, so every payload comes back as the answer:

Terminal window
pgfuzz llm-echo --addr 127.0.0.1:19797 &
# promptgate.yaml:
# providers: { echo: { type: openai-compatible, base_url: "http://127.0.0.1:19797/v1", api_key: x } }
# guardrails: { commands: {} }
pgfuzz commands --target http://127.0.0.1:7878/v1/chat/completions --token pg_… \
--model echo:echo --count 900 --min-recall 0.99
pgfuzz commands --target … --token pg_… --model echo:echo --expect benign --count 0 --min-recall 1

--count 900 covers every stem of the ten kinds in every variant (direct, in prose or a code block, obfuscated with carets, backticks, mixed case or spacing) and delivery (text, tool call, stream). In a plan, kind: commands takes expect (attacks, benign), kinds, variants and deliveries; count: 0 with expect: benign sends each ordinary answer once per delivery.

The first run against PromptGate found real gaps — commands inside a tool call’s JSON arguments (escaped quotes and backslashes), and four phrasings the patterns didn’t know — which were fixed before the stage joined the gate. Recall on this corpus says the known forms are caught; new tricks belong in the corpus.

Attacks on assistants that read mail or documents hide the instruction from people, not from the model: white 1-point text in a PDF, a display:none block in a newsletter, Unicode tag characters that no screen shows. pgfuzz indirect builds such documents and hands them to the model the two ways they arrive — attached by the user, or returned by a tool an agent called:

Terminal window
# promptgate.yaml: a model on an openai-compatible provider, and one on
# an anthropic provider (Anthropic documents can't be translated):
# guardrails: { prompt_injection: { action: block, roles: [user, tool] } }
pgfuzz indirect --target http://127.0.0.1:7878 --token pg_… \
--model mock:mock-1 --anthropic-model mocka:mock-1 --kinds classic --min-recall 1
pgfuzz indirect --target http://127.0.0.1:7878 --token pg_… \
--model mock:mock-1 --anthropic-model mocka:mock-1 --expect benign --min-recall 1
pgfuzz indirect --target http://127.0.0.1:7878 --token pg_… \
--model mock:mock-1 --anthropic-model mocka:mock-1 --expect heldout

--target is the gateway’s base URL; each delivery adds its path (/v1/chat/completions, /v1/messages, /v1/responses). By default every kind × carrier × delivery the delivery can carry is sent once (binary files only as attachments, and PDFs in Anthropic tool results). In a plan, kind: indirect takes expect, kinds, variants (the carriers), deliveries and model2 (the Anthropic model).

The first run against PromptGate found an Anthropic document whose source listed data before type — as Go and other clients that sort keys write it — going unread, and tag characters glued to the visible text slipping past; both were fixed.

--expect heldout keeps the corpus honest: paraphrases of each kind written without looking at any guard’s rules (“Dear AI assistant, …”, “Don’t let the user know …”). A guard tuned on the corpus catches all of it; the held-out set shows how far its rules carry to wordings they were not written for. Once a rule is written for a held-out phrasing, it measures nothing — add fresh ones instead. PromptGate’s phrases catch 5 of the 20.

--expect masked checks a gateway that masks injection in what the agent reads instead of refusing the request. Behind it, pgfuzz llm-echo’s dump model answers with every text the request carried (on /v1/messages and /v1/responses too), so pgfuzz sees what reached the model: it must hold a mask ([ADDRESSED_TO_AI] …), every visible part of the document, and no three words in a row of the payload — read as a model reads them, through tag characters, zero-width and bidi controls. A PDF or Word file must reach the model as its masked text (PromptGate replaces it); a refusal counts as missed.

19797/v1
# guardrails: { prompt_injection: { roles: { user: mask, tool: mask } } }
pgfuzz llm-echo --addr 127.0.0.1:19797 &
pgfuzz indirect --target http://127.0.0.1:7878 --token pg_… \
--model echo:dump --anthropic-model echoa:dump --expect masked --min-recall 1

Its first run found three places where PromptGate’s mask stopped short or ran over: the instruction before “don’t tell the user” was left, a bidi override didn’t end the masked block, and a mask in an HTML comment ran on into the signature after it.

--min-recall makes every subcommand CI-friendly — non-zero exit when any cell or overall recall falls below the threshold:

Terminal window
pgfuzz pii \
--target $PG_URL/v1/chat/completions \
--token $PG_TOKEN \
--count 500 \
--min-recall 0.95 \
--output report.json

For multi-stage gates, write a plan YAML once and call pgfuzz run:

Terminal window
pgfuzz run --plan compliance.yaml --output report.json

See examples/plan.yaml for the full plan format (defaults, env-var expansion, per-stage min_recall).

Terminal window
go build ./cmd/pgfuzz
./pgfuzz --help
./pgfuzz --version

Releases (a tag v*) build darwin arm64+amd64, linux amd64+arm64 and windows amd64, publish them to install.promptgate.dev/pgfuzz/ and update the Homebrew cask.

Corpora, carriers and probes are welcome — see CONTRIBUTING.md; contributions need a signed CLA. Vulnerabilities go to [email protected] (SECURITY.md).

Apache License 2.0 — see LICENSE.

PromptGate itself (the gateway) is BSL 1.1 — a separate license decision. pgfuzz uses Apache-2.0 because compliance-verification tooling only earns its trust through enterprise auditability and community-contributed corpora, both of which need a permissive license.


Akyros Labs LLC — [email protected]

Was this page helpful?