Skip to main content

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.0

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) 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 — issuedAt within max_payment_age_seconds, and not future-dated beyond payment_clock_skew_seconds (replay / pre-signing defence, both REJECT_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.

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_methods is 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/sendSubscribe carrying 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.py returns a different reason for 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 pass now. 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() returns sha256:… over the JCS (RFC 8785, rule jcs-rfc8785-v1) of the profile snapshot. Pin it; any policy change produces a new, auditable hash. The canonicaliser is algovoi-substrate when installed and a byte-identical stdlib fallback otherwise — tests/test_substrate_parity.py enforces that both produce the same address, so a pinned reference never depends on the deployment.
  • .well-known/agent-card.json is a standard A2A AgentCard advertising the skill, the pinned profile_ref, every reject code, and its OWASP mapping. It is generated by build_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 — discovery
  • GET /healthz — liveness
  • POST / — 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 33 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   # 34/34 (33 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. 65 tests:

python -m pytest tests -q -m "not substrate"   # 64 passed, 1 deselected
python -m pytest tests -q -m substrate         # 1 passed — needs the substrate extra
File Tests Covers
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 65 passed, 0 skipped
Portable suite, -m "not substrate" 64 passed, 1 deselected, 0 skipped
Independent conformance verifier 34/34
Guard mutation matrix 21 planted mutations, 21 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 65 passed, 0 skipped
Declared Python floor (python:3.10-slim) 65 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    # 21 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.

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.

Metadata

Release files for algovoi-waf 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for algovoi-waf 0.3.0
File Size Uploaded Provenance Actions
algovoi_waf-0.3.0.tar.gz 80.8 kB Without provenance Details for algovoi_waf-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for algovoi-waf 0.3.0
File Interpreter ABI Platform Actions
algovoi_waf-0.3.0-py3-none-any.whl Python 3 none any Details for algovoi_waf-0.3.0-py3-none-any.whl

Total release size: 130.1 kB

Release files / algovoi_waf-0.3.0.tar.gz

Download URL algovoi_waf-0.3.0.tar.gz
Size 80.8 kB
Tags Source
SHA-256 checksum
How to use checksums
c4410d979763665a6d01070cbbc6903fe1a7cbd63b2328117d3a107b2df3a60a
BLAKE2b-256 checksum
How to use checksums
694f2ca2cdcd880eb4058d38d4787f1a7455ee7ff7a69cfeaae2f57ab4fd226c
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.0-py3-none-any.whl

Download URL algovoi_waf-0.3.0-py3-none-any.whl
Size 49.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b26917eaa3eb9d8480c92e051de591dcbc8f89ae1e70e5468b5577d2c1d876fa
BLAKE2b-256 checksum
How to use checksums
2863280c8c4e6d94629c5c6c1fd735646605ce80747284e87152c6cf738b86d5
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.0

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page