algovoi-waf
A semantic WAF for agentic / e-commerce payments. A fail-closed A2A JSON-RPC gate that sits between the world and an AI agent, immediately before canonicalisation in the Keystone spine. Pure Python, no required dependencies.
It answers one question for every inbound message: should this reach the agent? — and refuses with a stable, OWASP-mapped reject code when the answer is no.
Version 0.3.1
Install
pip install algovoi-waf
Python 3.10+, no required dependencies. The optional RFC 8785 canonicalisation backend is an extra:
pip install "algovoi-waf[substrate]"
Without it the package uses a standard-library fallback that produces
byte-identical canonical JSON for the policy snapshot.
tests/test_substrate_parity.py pins the two addresses together wherever the
real backend is installed.
What it stops
| Control | Reject code | OWASP |
|---|---|---|
| Prompt injection (patterns, homoglyph, base64, indirect carriers + dict keys, NFKC+noise-stripped, relaxed) | REJECT_PROMPT_INJECTION |
LLM01:2025 Prompt Injection |
| Oversized prompt / task | REJECT_PROMPT_OVER_SIZE, REJECT_OVER_TASK_SIZE |
API4:2023 Unrestricted Resource Consumption |
| SSRF (private ranges, cloud metadata, scheme, host) | REJECT_SSRF_URL |
API7:2023 / A10:2021 SSRF |
| Unknown method / malformed JSON-RPC | REJECT_UNKNOWN_METHOD, REJECT_SCHEMA |
API8:2023 Security Misconfiguration |
| Unverified payment authorization | REJECT_UNVERIFIED_PAYMENT |
API3:2023 BOPLA / LLM06:2025 Excessive Agency |
| Stale / replayed payment authorization | REJECT_PAYMENT_EXPIRED |
API3:2023 BOPLA / LLM06:2025 Excessive Agency |
| Payment bound to different terms than demanded | REJECT_PAYMENT_MISMATCH |
API3:2023 BOPLA / LLM06:2025 Excessive Agency |
| Cross-tenant task access, on every object-bearing method (get, cancel, pushNotification, and task continuation) | REJECT_TENANCY (masked as method-not-found) |
API1:2023 BOLA / A01:2021 Broken Access Control |
| Rate / concurrency abuse | REJECT_OVER_RATE, REJECT_OVER_CONCURRENT |
API4:2023 Unrestricted Resource Consumption |
| SQL injection | REJECT_SQLI |
A03:2021 Injection |
| Server-side template injection | REJECT_SSTI |
A03:2021 Injection |
| XXE (external entity) | REJECT_XXE |
A05:2021 Security Misconfiguration |
| Command injection (incl. JNDI) | REJECT_CMD_INJECTION |
A03:2021 Injection |
| Path traversal to a sensitive file | REJECT_PATH_TRAVERSAL |
A01:2021 Broken Access Control |
| Unsigned-token authentication bypass | REJECT_AUTH_BYPASS |
API2:2023 Broken Authentication |
| Automated enumeration / burst probing | REJECT_SCAN_DETECTED |
API9:2023 Improper Inventory Management |
| Sustained hostile actor | REJECT_ACTOR_BLOCKED |
API4:2023 Unrestricted Resource Consumption |
The full map is algovoi_waf.OWASP_CATEGORY and is re-published in the agent
card so coverage is auditable from outside the process.
The payment core
For agentic commerce, the WAF's job is to stop a payment authorization from
being used for something other than what it authorizes. check_payment
enforces, statelessly:
- presence + structure — a required reference must be present and fully
describable (
scheme,network,maxAmountRequired,payTo,asset); - freshness —
issuedAtwithinmax_payment_age_seconds, and not future-dated beyondpayment_clock_skew_seconds(replay / pre-signing defence, bothREJECT_PAYMENT_EXPIRED); - binding — the reference must match the terms the task demands: same
merchant (
payTo),network,asset, and an amount that covers the demand. A $0.001 authorization cannot settle a $1.00 cart; a valid authorization cannot be redirected to another merchant.
It does not settle, verify signatures, or touch a chain — that is the facilitator's job. The WAF binds intent to authority; settlement verifies it.
from algovoi_waf import gate_message, FirewallProfile, FirewallError
profile = FirewallProfile(require_payment_reference=True)
try:
gate_message(message, profile, now=time.time()) # True, or raises
except FirewallError as e:
print(e.code, e.owasp, e.detail)
Agentic attack tooling (ARTEX-class)
ARTEX, the LLM-driven autonomous penetration testing framework public since July 2026, does not invent new techniques; it runs commodity ones at machine speed and changes tactic the moment a control blocks it. The published analyses (FBI FLASH 2026-11-13, Microsoft Threat Intelligence, F5 Labs, CERT-EU) agree on what a WAF has to do about it: refuse the payload vocabulary, and score the behaviour, because no single request identifies the attacker.
attack.py— stateless screen over every string in a message for SQL injection, template injection (including Spring EL), XXE, command injection (including JNDI), path traversal that reaches a sensitive file, and unsigned-token authentication bypass. Percent-encoding (decoded twice), NUL padding and SQL comment noise are normalised before matching, because that is how the payloads evade a naive signature.behaviour.py— per-caller sliding window scoring three independent signals (request burst, distinct rejected methods, refusal ratio), escalating a repeat offender from a scan block to a doubling actor block. It is keyed on the authenticated principal, not the source address, so proxy rotation does not reset it, and every decision is an event, including rate-limit refusals.
The payload screen is a profile field (block_attack_payloads, default on), so
turning it off produces a different, auditable profile_ref. The tracker is
operational like the DNS-resolution screen: tune it with BehaviourPolicy(...)
and the pinned policy address does not move.
The prompt screen also covers indirect injection (LLM01:2025): it walks every
string in the message, values and dict keys, not only text parts, so an
instruction smuggled through a tool result, an MCP tool description, a dict key or
file text is refused before it reaches the model. Each string is scanned in complementary forms. A
spaced form replaces every noise char with a space and is scanned with the
strict (\s+) patterns, so real or noise-derived word boundaries survive: a persona
word followed by a separator still hits its boundary, while a noise-free camelCase
identifier (systemPrompt, developerMessage:) keeps no space and is not refused.
A noise-stripped form is scanned with the relaxed (\s+ -> \s*) patterns only
when noise was actually removed, exposing a keyword split by an internal mark
(i+U+0307+gnore) without matching ordinary identifiers. An NFKD form decomposes
precomposed diacritics and folds compatibility look-alikes (full-width i -> i), then
strips the freed marks, and is scanned relaxed only when NFKD changed it; NFKD rather
than NFKC because NFKC would recompose a base letter plus a mark and hide it.
A persona match is also located on a base-letter fold of the stripped form (each
char first folded through the curated confusable map so a mapped look-alike that NFKD
would rewrite, such as U+03F2 lunate sigma, still folds to its ASCII target, then
expanded to its full NFKD base letters with combining marks dropped and the map
applied again, with a per-character index map back to the input) and mapped back to
the original positions. Whenever the fold differs from the original, a persona
followed by anything that is not an ASCII letter is a real word boundary and is refused:
a noise separator, punctuation, end of string, or a compatibility symbol that NFKD
expands to letters (U+2122 trademark -> TM, U+2116 numero -> No) which would otherwise
glue onto the persona in the folded form and defeat the letter-only lookahead. The full
expansion keeps compatibility ligatures intact (U+FB01 fi -> fi, so un+fi+ltered reads
as unfiltered). This refuses a fold-dependent persona plus a separator or symbol after
it (full-width DAN, Cyrillic o in you, D+accent+A+N, a ligature persona, DAN+U+2122)
that the plain stripped form would miss, while a persona glued to a real ASCII letter
(DANv11, dancing, Daniel) stays accepted.
The relaxed patterns also run over that full base-letter fold whenever it differs
from the plain NFKD form, so a payload mixing a compatibility letter NFKD folds
(full-width i) with a curated confusable NFKD leaves unmapped (lunate sigma c) is
read as ASCII and refused even for the non-persona phrases.
Stripping non-spacing, enclosing and spacing marks (Mn, Me, Mc), format and control
chars (Cf, Cc), lone surrogates (Cs), private-use and unassigned code points (Co, Cn)
and invisible fillers exposes keywords hidden by marks inside a word, zero-width
separators (ignore+U+200B+previous), any mix of the two, or control/filler chars. A
curated confusable fold (Cyrillic and Greek look-alikes, script g, dotless i,
ghe, pe, eta, Armenian oh/now/se, Greek lunate sigma, lowercase Cyrillic te/ka/em,
palochka and shha for l/h, and the Latin small-capital block) runs over the stripped
and NFKD forms (relaxed) and feeds the base-letter fold used by the persona boundary check,
catching look-alikes NFKD does not fold. It is a curated
subset, not an exhaustive UTS #39 skeleton: a novel unmapped look-alike can still
evade it, a documented bound of the signature approach rather than a fail-open path
in the enforced patterns. Tonos variants fold via NFKD to the mapped base letter. The DAN pattern tolerates noise between its letters
(D\sA\sN) and carries a letter-only negative lookahead, so DAN2, DAN_mode and
D+U+200B+AN are refused while ordinary prose ("you are dancing", "you are
Daniel") is not. Two bounded residuals remain: the case-insensitive match still
treats the personal name "Dan" in "you are Dan" as the persona, and a persona glued
to a following letter ("DANv11") is not distinguished from a word beginning "dan"
without case heuristics that would introduce their own false positives. A further
precision bound is fail-closed: when control noise such as a newline is present
elsewhere in a string, the relaxed scan may refuse a benign camelCase injection-shaped
keyword (systemPrompt: in a YAML block); the noise-free identifier is accepted.
A further structural bound is pre-existing at 0.3.0: the injection screen visits
each string part separately (_walk_text_parts is byte-identical to the parent),
so a phrase split across sibling text parts ("ignore all previous" + "instructions")
is never seen whole in any single scanned string and is accepted, while a downstream
model that joins the parts would read the full phrase. Closing it means scanning the
joined sibling text, which is outside this increment's per-string signature scope.
conformance/artex.py exercises this as layer
E alongside the object-scope, payment, behavioural and payload waves.
Object scope: the pivot after the payloads fail
Refusing payloads does not stop an autonomous attacker; it redirects one. The
next request is well formed, correctly authenticated and names an object that
exists — it is only wrong in that the object belongs to somebody else, which no
stateless rule can see. Object scope closes that with five rules, enforced
across scope.py, gate.py and proxy.py:
- Every allowed method is classified. Each entry in
profile.allowed_methodsis either object-bearing (it can name an existing object) or object-free. An allowlist entry the layer cannot classify raises at construction, so adding a method cannot leave it unchecked by accident. - A named object must be owned. Get, cancel, pushNotification and
continuation (
tasks/send/tasks/sendSubscribecarrying an existing id) are refused unless the ownership store says the caller owns the object. Continuation is a read and a write on a task's history, which is why it is in scope. - The refusal is masked (
proxy.py). A foreign object and an object that never existed produce the same response —scope.pyreturns a differentreasonfor each case, and the proxy turns every one of them into the same method-not-found body — so enforcement cannot be turned back into the existence oracle it exists to close. - An unreadable shape is not "no object". A2A params are a JSON object.
Positional (array) or scalar params are refused by
enforce_a2a_schema(REJECT_SCHEMA), and any object-bearing method whose params are not a mapping — including omitted params — is refused by the scope layer. Without this, an id wrapped in a container the extractor does not walk arrives as a fresh creation and is forwarded unchecked. - The agent's response id is not an authorisation grant (
proxy.py, post-forward). After a forward, the id the agent returns is claimed, not registered: if it already belongs to another caller, ownership does not transfer and that response body is masked rather than delivered. A colliding, reused or hostile response id cannot hand a caller an object it never owned.
Three profile fields govern it, and all are in the content-addressed policy so a consumer can audit the choice rather than infer it:
| Field | Default | Meaning |
|---|---|---|
enforce_object_scope |
true |
Off means no ownership check at all — an auditable downgrade, not a runtime tweak. |
enforce_a2a_schema |
true |
Refuse params that are present but not a JSON object (array or scalar). This is the rule that keeps an object id from hiding in a shape the ownership layer cannot read. |
object_scope_unknown_ids |
"deny" |
What an id the store has never seen means. deny refuses it: a continuation of a task this firewall did not see created is indistinguishable from a client inventing an id, and only one is legitimate. adopt lets the first caller to name an id own it atomically (a later claimant is refused) — for deployments whose clients assign their own task ids. Under adopt, an object the store never saw (after a restart, or created through another instance) goes to whoever names it first, so that mode trades authorisation for reachability. |
Ownership is per-firewall and TTL-bound. A restart empties it, and the firewall
then refuses continuations rather than assuming they are innocent — the
fail-closed direction. Deployments that need cross-instance continuity should
inject a shared store into FirewallProxy(task_store=...).
Layers
gate.py— the stateless core (gate_message). No I/O, no identity, no clock unless you passnow. This is what the conformance vectors test.proxy.py— the stateful reverse proxy (FirewallProxy): adds object scope (task ownership on every object-bearing method), per-caller token-bucket rate limiting, and per-caller in-flight concurrency limiting on top, then forwards to the agent. Wire it behind an auth proxy that sets the caller identity — the WAF consumes identity, it does not authenticate.scope.py,tenancy.py— the ownership model and its store: classification, mandatory-id rules, atomic claim, TTL and eviction.attack.py,behaviour.py,payment.py,concurrency.py,rate_limiter.py,resolver.py— standalone, reusable checks.
Discoverability
algovoi-waf is a Keystone-discoverable app:
- Its policy is content-addressed:
profile_ref()returnssha256:…over the JCS (RFC 8785, rulejcs-rfc8785-v1) of the profile snapshot. Pin it; any policy change produces a new, auditable hash. The canonicaliser isalgovoi-substratewhen installed and a byte-identical stdlib fallback otherwise —tests/test_substrate_parity.pyenforces that both produce the same address, so a pinned reference never depends on the deployment. .well-known/agent-card.jsonis a standard A2A AgentCard advertising the skill, the pinnedprofile_ref, every reject code, and its OWASP mapping. It is generated bybuild_agent_card(profile)— the same builder the running app serves, so the checked-in file cannot drift from the live policy.
Run it
serve.py is a zero-dependency ASGI app. Point it at the protected agent and
run it under any ASGI server:
AGENT_URL=https://agent.internal uvicorn algovoi_waf.serve:app
GET /.well-known/agent-card.json— discoveryGET /healthz— livenessPOST /— gate an A2A JSON-RPC message, then forward to the agent
Caller identity is read from the X-Authenticated-Caller header, set by an
upstream auth proxy. Malformed JSON fails closed with a JSON-RPC parse error and
never reaches the agent.
Conformance
conformance/algovoi_waf_v1/ holds vectors.json (the pinned profile_ref +
snapshot and 81 accept/reject vectors) and verify.py, an independent
reimplementation of the gate — it does not import the package, so a single
implementation bug cannot make the vectors self-validating. It also re-derives
profile_ref from the snapshot.
python conformance/algovoi_waf_v1/verify.py # 82/82 (81 vectors + meta)
The stateful controls (rate, concurrency, tenancy, object scope), the ASGI app
and the published metadata are tested under tests/ — they are not expressible
as stateless message vectors. 223 tests:
python -m pytest tests -q -m "not substrate" # 222 passed, 1 deselected
python -m pytest tests -q -m substrate # 1 passed — needs the substrate extra
| File | Tests | Covers |
|---|---|---|
tests/test_ai_injection.py |
158 | indirect carriers, spaced + noise-strip + NFKD diacritic + confusable + ligature + symbol + lunate-sigma + mixed look-alike evasion, DAN boundary, camelCase controls, dict keys, benign scripts, size precedence (LLM01:2025) |
tests/test_attack_payloads.py |
10 | payload classes + benign controls |
tests/test_behaviour.py |
8 | burst, enumeration, ratio, escalation |
tests/test_concurrency.py |
1 | per-caller in-flight cap |
tests/test_conformance_pin.py |
4 | pinned vectors/card match the live policy |
tests/test_object_scope.py |
25 | object-level authorisation on every bearing method |
tests/test_packaging.py |
10 | licence, backend floor, version, sdist, README counts, mutation anchors |
tests/test_proxy_controls.py |
1 | response-id claim-or-mask, owner-only TTL refresh |
tests/test_serve.py |
1 | discovery + health + gate + forward |
tests/test_ssrf_resolver.py |
2 | resolved-address SSRF refusal |
tests/test_substrate_parity.py |
1 | profile_ref: real backend == fallback |
tests/test_tenancy.py |
2 | cross-tenant task access, masked refusal |
Every count in this table and in the conformance section is re-derived from the
artefacts by tests/test_packaging.py, so a stale figure fails the suite rather
than surviving into a release.
Proof
These figures come from runs against the built artefacts in a clean container,
not from the source tree. Every count in them is re-derived by
tests/test_packaging.py, so a stale number fails the suite.
| Check | Result |
|---|---|
| Full suite, optional backend installed | 223 passed, 0 skipped |
Portable suite, -m "not substrate" |
222 passed, 1 deselected, 0 skipped |
| Independent conformance verifier | 82/82 |
| Guard mutation matrix | 48 planted mutations, 48 killed, 0 survived |
Clean-room build (python:3.12-slim) |
wheel + sdist, twine check PASSED on both |
| Sdist's own suite against the installed wheel | 223 passed, 0 skipped |
Declared Python floor (python:3.10-slim) |
223 passed, 0 skipped |
| Secret scan of the published tree | 0 findings; planted control 1 |
The pinned policy address is
sha256:886e3f979cb5cf3cb894b90738c2764ae95984c4a768ac57502b820fa393dc1e.
verify.py re-derives it from the snapshot, so a consumer can check the policy
without trusting the package that computes it.
Re-running the mutation matrix
conformance/mutations.py ships in the sdist. It disables one guard at a time in
the installed package, requires the covering test to fail, restores the exact
original bytes and requires the test to pass again:
pip install algovoi-waf pytest
python conformance/mutations.py # 48 killed, 0 not killed
It refuses to run when algovoi_waf resolves outside site-packages. A source
directory on the test path wins the import, every mutant then lands in a file the
suite never loads, and the matrix reports nothing killed while looking green.
A guard no test kills is not a guard, so a SURVIVED row is a defect in the suite.
The full base-letter fold relaxed scan subsumes the separate NFKD-fold and
homoglyph relaxed passes: disabling either alone leaves the suite green because
the full fold still reads the payload as ASCII. Those passes are retained as
defence-in-depth but are not independently killable, so they carry no mutation row.
License
Apache-2.0. The full text is in LICENSE; the attribution and the
optional-backend notice are in NOTICE. Both ship in the wheel and
the sdist.
Related
Part of the AlgoVoi security category — browse the security category.
algovoi-advisories: Public security advisories for AlgoVoi software and servicesalgovoi-agent-guard: The budget your agent can't raise: human-signed spend mandates with offline-verifiable receiptsalgovoi-agent-guard-ts: The budget your agent can't raise - human-signed spend mandates with offline-verifiable receiptsalgovoi-agent-trust-bench: Open agentic payment security test suite for x402 agentsalgovoi-atb: AlgoVoi Agent Trust Bench client — run your AI agent through 166 adversarial x402 payment profiles and earn…algovoi-consensus-blocklist: 4-of-N on-chain consensus wallet blocklist for Algorand and VOI (algopy ARC-4)algovoi-fabric: Security composition core for agentic commercealgovoi-keyhygiene-conformance: Signed, cross-language conformance battery for RSA/EC public-key hygiene and primality soundness…
Metadata
Release files for algovoi-waf 0.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| algovoi_waf-0.3.1.tar.gz | 109.3 kB | Without provenance | Details for algovoi_waf-0.3.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| algovoi_waf-0.3.1-py3-none-any.whl | Python 3 | none | any | Details for algovoi_waf-0.3.1-py3-none-any.whl |
Total release size: 164.7 kB
Release files / algovoi_waf-0.3.1.tar.gz
| Download URL | algovoi_waf-0.3.1.tar.gz |
|---|---|
| Size | 109.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
84fb5580c4b111b25e1fa8ed734356cb79b53a400b07967478308c0493c07411
|
|
BLAKE2b-256 checksum How to use checksums |
bf37c2969beaccf7a0612d3964cfb700a46adb11231a0f08168dc34b25503b48
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.10
|
Release files / algovoi_waf-0.3.1-py3-none-any.whl
| Download URL | algovoi_waf-0.3.1-py3-none-any.whl |
|---|---|
| Size | 55.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b1eb7c8f57232fadc4fb71ca6fad23c87a5bdab0c73e4c6ce2c64c877d67745f
|
|
BLAKE2b-256 checksum How to use checksums |
d1bb1633aedf7fb28bc830a0fa46d04933afa662863c24a92ec7751f710cc0ad
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.10
|
Security for algovoi-waf 0.3.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.