algovoi-secure-hub
AlgoVoi Secure Hub is a self-hosted, substrate-neutral security and trust hub. It provides issuer trust distribution, service/add-on registration, health posture, policy and attestor coordination, and a durable HMAC-chained audit log. It does not replace the canonical evidence, settlement, compliance, or payment contracts owned by the security applications that bolt into it.
Version 0.3.8
What it does
- Issuer trust registry: one source of truth for issuer DID → Falcon-1024 public key mappings.
- Universal service bridge: registers security applications, substrate adapters, and bolt-on services through one language-agnostic HTTP contract.
- Posture: probes registered
/healthendpoints with bounded, fail-closed SSRF protections. - Policy and attestor coordination: publishes content-addressed policy references and the pinned Keystone attestor public key.
- Signed audit: every trust and topology mutation is committed with an HMAC-chained audit entry and persisted-state verification.
- Edge / WAF / Guard: three independent, opt-in middleware layers that sit in front of every request (see below).
The registry coordinates metadata and posture only; it does not canonicalise, settle, or mutate a security application's evidence.
Screenshots
The panel is server-side rendered — no build step, no external assets, no CDN. It ships one dark theme, shared token-for-token with the Keystone control panel, so an operator moving between the two sees the same product.
The sign-in gate. The password is AHUB_ADMIN_TOKEN; the session is a signed cookie, not a bearer header.
Live posture: registered services and their health, the active policy bridge with its content-addressed policy_ref, the issuer trust set, and audit depth. Auto-refresh every 10s.
Install and run
Every dependency resolves from public indexes, so a plain install works:
pip install algovoi-secure-hub
# or, from a checkout:
pip install -e .
The policy bridge uses the published algovoi-policy-binding (Apache-2.0). It previously imported substrate2.policy_binding, an internal reimplementation that is deliberately not published, so a plain pip install could never resolve — that dependency is gone.
Run it:
export AHUB_DATA_DIR=/var/lib/algovoi-secure-hub
export AHUB_ADMIN_TOKEN="$(python -c 'import secrets; print(secrets.token_urlsafe(32))')"
export AHUB_AUDIT_KEY="$(python -c 'import secrets; print(secrets.token_urlsafe(32))')"
export AHUB_BIND=127.0.0.1:8094
algovoi-secure-hub
# health: curl -s localhost:8094/health
# panel: open http://localhost:8094/ and sign in with AHUB_ADMIN_TOKEN
AHUB_ADMIN_TOKEN and AHUB_AUDIT_KEY must be distinct; the service refuses to start if they match. When either is absent the hub generates one and persists it under AHUB_DATA_DIR with restrictive permissions.
| Request | Expected |
|---|---|
GET /health |
200 (unauthenticated, always) |
GET / |
401 until you sign in |
GET /v1/services with admin bearer |
200 + {"services": [...], "default_bridge": [...]} |
Security middleware layers
Three middleware modules are built into the hub and sit in front of all traffic in this order: Edge → WAF → Guard → login gate. Each is disabled by default; set the corresponding environment variable to activate it.
Edge (AHUB_EDGE_*)
The outermost layer. Blocks origin-direct requests before they reach any authentication logic.
| Feature | Env var | Description |
|---|---|---|
| HMAC pre-auth token | AHUB_EDGE_TOKEN |
Reverse proxy attaches a shared secret via X-AlgoVoi-Edge-Token; requests without the correct token receive 401. |
| Per-IP rate limit | AHUB_EDGE_RPM |
Sliding-window requests-per-minute ceiling per client IP. Excess requests receive 429 with Retry-After: 60. |
| Geo-blocklist | AHUB_EDGE_GEO_BLOCK |
Comma-separated ISO 3166-1 alpha-2 codes (e.g. CN,RU). Checked against the X-Country-Code header set by a trusted reverse proxy; blocked countries receive 403. |
Stats: GET /v1/edge/stats (admin bearer required).
WAF (AHUB_WAF_ENABLED=1)
Stateless pattern-matching firewall. Scans the URL path and query string on every request, and the JSON/text body on POST/PUT/PATCH requests.
| Rule family | Coverage |
|---|---|
sqli-* |
UNION SELECT, stacked queries, Boolean injection, SQL comment + DML |
xss-* |
Script tags, inline event handlers, javascript: URIs, data:text/html |
cmdi-* |
Shell pipe/chain, backtick substitution, $(…) substitution |
pt-* |
Directory traversal (../), percent-encoded traversal |
ssrf-* |
Cloud metadata IPs/hostnames (169.254.169.254, metadata.google), loopback URLs in body |
pi-* |
Prompt-injection phrases, [SYSTEM] tags, XML instruction tags, LLM jailbreak patterns |
Blocked requests receive 400. Oversized bodies (default 1 MiB, override with AHUB_WAF_MAX_BODY) receive 413.
Stats: GET /v1/waf/stats (admin bearer required).
A2A deep gate (AHUB_WAF_A2A=1)
Opt-in second pass for A2A bodies: any JSON dict carrying a jsonrpc, params or method member, or a dict-valued message member (the A2A HTTP+JSON REST binding), including batch arrays. Requires AHUB_WAF_ENABLED=1 and refuses to load otherwise. It runs the published algovoi-waf contract (gate_message, pinned profile algovoi-waf-v1) on top of the raw catalogue: NFKC-folded injection screening, indirect carriers (tool results, descriptions), dict-key walk, method allowlist, schema and payment binding. Detection is content-sniffed, so a misleading Content-Type cannot skip it, and a JSON-shaped body that fails to parse is refused. The hub's own API bodies are not A2A envelopes and are never deep-gated. The flag is A2A-specific: with it on, any presenting body (including other JSON-RPC protocols) is held to the A2A method allowlist. Screening covers the top-level JSON document on POST/PUT/PATCH (the verbs the raw layer covers); nested wrappers, multipart parts and other verbs are not unwrapped, and every such body is subject to AHUB_WAF_MAX_BODY (413 above it), including non-JSON uploads.
pip install algovoi-secure-hub[a2a] # adds algovoi-waf>=0.3.1
export AHUB_WAF_ENABLED=1 AHUB_WAF_A2A=1
A flagged deployment without the package refuses to load (fail closed). Deep-gate blocks return 400 with the stable reject code, e.g. request blocked by WAF (REJECT_PROMPT_INJECTION). GET /v1/waf/stats reports a2a_enabled, a2a_available and the pinned a2a_profile_ref.
Guard (AHUB_GUARD_ENABLED=1)
Runtime anomaly detection with a per-tenant EWMA baseline and a circuit breaker.
Tenant identity is resolved from (in priority order): X-AlgoVoi-Tenant header → X-Tenant-Id header → client IP.
| Feature | Env var | Default |
|---|---|---|
| Anomaly threshold | AHUB_GUARD_ANOMALY_FACTOR |
5.0 σ above baseline |
| Circuit trip threshold | AHUB_GUARD_CIRCUIT_TRIP |
5 anomaly hits |
| Circuit reset | AHUB_GUARD_CIRCUIT_RESET_S |
300 seconds |
| EWMA learning rate | AHUB_GUARD_EWMA_ALPHA |
0.1 |
When the circuit opens, the tenant receives 429 with Retry-After: 60 until the cool-down expires.
An operator can also set a hard per-tenant RPM cap that bypasses the EWMA logic:
POST /v1/guard/policy
Authorization: Bearer <admin-token>
Content-Type: application/json
{"tenant": "acme-corp", "cap_rpm": 500}
Pass "cap_rpm": null to remove the cap.
Status: GET /v1/guard/status (admin bearer required).
Multi-worker note: Guard state is in-process. In a multi-worker deployment set
AHUB_GUARD_ENABLED=0and implement anomaly detection in the upstream reverse proxy or a shared cache layer.
Verified compatible AlgoVoi security applications
These applications were exercised against a live Secure Hub on VM2. Each registered successfully and appeared in /v1/services:
| Application | Registration shape | Trust integration |
|---|---|---|
algovoi-federation-validator |
self_register |
/v1/issuer-pks |
algovoi-zkp-receipt |
self_register |
/v1/issuer-pks |
algovoi-atb-credential-verifier |
self_register |
/v1/issuer-pks, ATB hub documents |
algovoi-retention-chain |
self_register |
service bridge |
algovoi-command-center |
register |
service bridge |
algovoi-compliance-gate |
register |
service bridge |
algovoi-records-vault |
register |
service bridge |
algovoi-retention-app |
register_into_s2_from_env / _post_register |
service bridge |
The VM2 run covered 19 integration checks: all eight applications registered, a generic addon registered with a name-bound scoped token, the admin token was rejected for addon registration, posture reported a live health stub, issuer trust was fetched through a real client, and audit guards held. Any other security application can bolt in if it exposes /health and makes the same POST request; no Python SDK is required.
Bolt-in contract
- Expose
GET /health, returning 200 only while the application's Secure Hub bridge is healthy (or explicit standalone mode is enabled). - Register with:
POST /v1/services
Authorization: Bearer ${AHUB_ADMIN_TOKEN}
Content-Type: application/json
{"name":"my-security-app","type":"security-app","base_url":"http://my-security-app:8000","health_path":"/health"}
- Refresh public issuer trust from
GET /v1/issuer-pks, returning{did: pk_b64}. ATB consumers may use/.well-known/atb-keys.jsonor/issuers/{did}/atb-keys.json. - Use
/v1/postureand/v1/servicesonly with the admin bearer; public trust reads are deliberately narrower and rate-limited.
examples/addon_app.py is a complete Python template. Non-Python applications make the same HTTP calls and expose /health.
Worked example: algovoi-agent-guard (spend-authority bolt-on)
algovoi-agent-guard
(TypeScript) is the
spend-mandate guard — human-signed spend caps with offline-verifiable receipts.
It ships as a library with no HTTP surface, so examples/agent_guard_addon.py
wraps it as a bolt-on: GET /health returns 200 only while a live enforcement
self-check passes (an honest charge ALLOWs, a settled charge_id replay is
DENIED, a forged human countersign is DENIED). The template self-registers as
type="addon" with a scoped, name-bound token, exactly like addon_app.py.
Registering as type="security-app" instead takes the admin bearer: scoped
registration tokens are restricted to type="addon", and the admin bearer is
refused for type="addon".
Exercised against a live hub on VM2 on 2026-11-24 via that operator path
(type="security-app", admin bearer): the guard appeared in /v1/services and /v1/posture
reported it up:true with the enforcement self-check passing (all_up:true).
Three different "guards". This is the spend-authority guard. It is not the keystone-agent behaviour guard (
verify_agent_guard/behaviour_ref), and not the hub's own anomaly / circuit-breaker Guard middleware above.
Keystone integration
The hub sits beside Keystone, not inside it. Keystone owns the execution decision, its content-addressed evidence and its journal; the hub owns cross-service topology, issuer trust and posture. Neither writes the other's evidence.
1. Keystone attestor key (trust, no code)
The hub distributes the pinned Keystone attestor public key so a bridged service can verify Keystone signatures as AlgoVoi without holding the signing seed. Admin-only to set, public to read:
curl -sX POST http://localhost:8094/v1/keystone-attestor \
-H "Authorization: Bearer $AHUB_ADMIN_TOKEN" -H 'Content-Type: application/json' \
-d '{"did":"did:key:z6Mk...","jwk":{...},"kid":"k-2026-01"}'
curl -s http://localhost:8094/v1/keystone-attestor # safe to pin
The attestor also appears in /v1/posture under keystone, so a broken pin is visible rather than assumed.
2. Registering Keystone as an addon
Keystone's control panel is a web service with /health, so it bridges like any other addon. Addon registration requires a scoped, name-bound token — the admin bearer is explicitly refused for type="addon":
# on the hub
export AHUB_REGISTRATION_TOKEN="<scoped-token>"
export AHUB_REGISTRATION_NAME="keystone-control"
# from the Keystone side
curl -sX POST http://localhost:8094/v1/services \
-H "Authorization: Bearer $AHUB_REGISTRATION_TOKEN" -H 'Content-Type: application/json' \
-d '{"name":"keystone-control","type":"addon",
"base_url":"http://keystone-control:8077","health_path":"/health"}'
A scoped registration is immutable: it can create its own name and nothing else, and cannot change an existing entry. For several addons use AHUB_REGISTRATION_TOKENS, a JSON name → token map.
Never give a bridged service or addon the admin bearer. The admin token can rewrite issuer trust and read the audit chain; the scoped token can only claim its own name.
3. Shared policy binding
The hub publishes an active policy_ref and binds it to a subject with POST /v1/policy/bind. That binding uses algovoi_policy_binding.policy_bound_ref — the same construction Keystone's algovoi-policy-binding package exposes — so a ref sealed on one side recomputes identically on the other:
policy_ref = "sha256:" + SHA-256(JCS(policy_document))
policy_bound_ref = "sha256:" + SHA-256(JCS({subject_ref, policy_ref}))
Both refs must be sha256: + 64 hex. The hub rejects anything else at the boundary, and a stored record whose refs no longer validate is treated as untrusted rather than crashing the panel.
Falcon-1024 issuer keys
Registering an issuer requires a real Falcon-1024 public key, base64-encoded. The hub enforces the exact size (public key must be 1793 bytes) and derives the key id itself.
pip install "pqcrypto==0.4.0" # see the pin note below
import base64
from pqcrypto.sign.falcon_1024 import generate_keypair # PQClean-backed
pk, sk = generate_keypair()
assert len(pk) == 1793, len(pk) # Falcon-1024 public key is exactly 1793 bytes
assert len(sk) == 2305 # secret key; keep it offline, the hub never needs it
print(base64.b64encode(pk).decode()) # -> public_key_b64 (2392 chars)
Pin
pqcrypto==0.4.0. Verified on both Linux and Windows: 0.4.0 produces a 1793-byte public key and a 2305-byte secret key. Version 1.0.0 ships no sign or kem modules at all, sofrom pqcrypto.sign.falcon_1024 import generate_keypairraisesModuleNotFoundError— it looks like a packaging regression rather than an API change. Check the import resolves before relying on it, and never paste an arbitrary 1793-byte blob: it passes the size check but nothing will ever verify against it.
curl -sX POST http://localhost:8094/v1/issuers \
-H "Authorization: Bearer $AHUB_ADMIN_TOKEN" -H 'Content-Type: application/json' \
-d '{"did":"did:web:issuer.example","public_key_b64":"<1793-byte key, base64>"}'
The returned kid is SHA-256(public_key_bytes)[:16], computed by the hub — you never supply it. That derivation is verified end to end: a key generated with pqcrypto==0.4.0 registered as kid 1bde4858bf37b12f, exactly matching the local recomputation of SHA-256(pk)[:16].
Verify the import before relying on it. Some
pqcryptobuilds ship without the compiled sign modules, in which casefrom pqcrypto.sign.falcon_1024 import generate_keypairraisesImportError. If that happens, use your existing ATB/issuer tooling. Do not paste an arbitrary 1793-byte blob: it passes the size check but nothing will ever verify against it.
Trust endpoints
| Endpoint | Shape | Consumers |
|---|---|---|
GET /v1/issuer-pks |
{did: pk_b64} |
federation-validator, zkp-receipt, ATB clients |
GET /.well-known/atb-keys.json |
canonical hub document | ATB hub resolver |
GET /issuers/{did}/atb-keys.json |
per-issuer document | multi-hub deployments |
GET /v1/keystone-attestor |
{did, jwk, kid, set_at} |
services that pin Keystone signatures |
Configuration
AHUB_* is the canonical Secure Hub environment namespace. The previous S2CP_* namespace remains accepted as a migration alias where applicable.
| Variable | Purpose |
|---|---|
AHUB_DATA_DIR |
SQLite data and generated secrets directory |
AHUB_DB |
Optional PostgreSQL DSN; SQLite is the default |
AHUB_ADMIN_TOKEN |
Admin bearer; generated securely when absent |
AHUB_AUDIT_KEY |
HMAC audit key; generated securely when absent |
AHUB_REGISTRATION_TOKENS |
JSON name → scoped registration token map |
AHUB_REGISTRATION_TOKEN / AHUB_REGISTRATION_NAME |
Single scoped registration credential |
AHUB_BIND |
Bind address, default 0.0.0.0:8094 |
AHUB_COOKIE_SECURE |
Session cookie Secure flag; on by default, set 0 only for plain-HTTP deployments |
AHUB_PROBE_ALLOW_LOOPBACK |
Allow posture probes to reach loopback (127.0.0.1); off by default as an SSRF defence. Relaxes loopback only — link-local and cloud-metadata ranges stay blocked |
AHUB_EDGE_TOKEN |
Edge: HMAC pre-auth token |
AHUB_EDGE_RPM |
Edge: per-IP requests-per-minute ceiling |
AHUB_EDGE_GEO_BLOCK |
Edge: comma-separated ISO country codes to block |
AHUB_WAF_ENABLED |
WAF: set to 1 to enable |
AHUB_WAF_MAX_BODY |
WAF: maximum inspected body size in bytes (default 1048576) |
AHUB_WAF_A2A |
WAF: set to 1 to deep-gate A2A JSON-RPC bodies with algovoi-waf (requires AHUB_WAF_ENABLED=1 and the [a2a] extra; fails closed without either) |
AHUB_GUARD_ENABLED |
Guard: set to 1 to enable |
AHUB_GUARD_ANOMALY_FACTOR |
Guard: σ multiplier for anomaly threshold (default 5.0) |
AHUB_GUARD_CIRCUIT_TRIP |
Guard: anomaly hits before circuit opens (default 5) |
AHUB_GUARD_CIRCUIT_RESET_S |
Guard: circuit breaker cool-down in seconds (default 300) |
AHUB_GUARD_EWMA_ALPHA |
Guard: EWMA learning rate (default 0.1) |
Existing applications may continue using their current S2_HUB_* or CCC_HUB_* client variables. Those clients call the same Secure Hub endpoints; no application logic or evidence contract needs to change.
Substrate-neutral registry
Register any substrate family or security adapter without changing its canonical evidence contract:
curl -X POST http://localhost:8094/v1/substrates \
-H "Authorization: Bearer ${AHUB_ADMIN_TOKEN}" \
-H "Content-Type: application/json" \
-d '{"name":"payment-rails","family":"payment-rails","version":"1",\
"adapter":"payment-rails","base_url":"http://payment-rails:8090",\
"capabilities":["x402","mpp","ap2","a2a"]}'
Security boundary
Administrative writes require the admin bearer. Addon registration requires a unique, name-bound scoped credential and never accepts the admin bearer. Posture probes disable proxy and redirect use, stream responses with byte and wall-clock caps, pin HTTP resolution, and fail closed for HTTPS until TLS-preserving address pinning is available. Private service networks are allowed, but special-purpose metadata ranges are rejected. Public trust and health reads are bounded by per-client rate limits and persisted-state/response-size caps.
Persistence and migration
SQLite is the default (stdlib, one file, air-gap friendly). Set AHUB_DB to a postgresql://... DSN for PostgreSQL (pip install '.[postgres]'). Established databases require a matching audit_anchor.json; run migration with the service stopped and the same AHUB_DATA_DIR and AHUB_AUDIT_KEY:
PYTHONPATH=src python scripts/migrate_legacy_audit.py
Do not use reconciliation to override a broken HMAC chain or mismatched anchor; restore both from a trusted backup instead.
Validation
python -m pytest tests/test_substrate_registry.py -q --confcutdir=tests
python scripts/acceptance.py
Related
Part of the AlgoVoi security category — browse the security category.
algovoi-agent-guard: human-signed spend mandates with offline-verifiable receiptsalgovoi-agent-guard-ts: the TypeScript port, byte-conformant with the frozen L1 vectorsalgovoi-platform: the payment rails and verifiable compliance estatealgovoi-advisories: Public security advisories for AlgoVoi software and servicesalgovoi-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 commerce
Foundation: algovoi-keystone (Keystone L2 SDK), algovoi-substrate (JCS substrate).
Metadata
Release files for algovoi-secure-hub 0.3.8
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_secure_hub-0.3.8.tar.gz | 258.0 kB | Without provenance | Details for algovoi_secure_hub-0.3.8.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| algovoi_secure_hub-0.3.8-py3-none-any.whl | Python 3 | none | any | Details for algovoi_secure_hub-0.3.8-py3-none-any.whl |
Total release size: 314.5 kB
Release files / algovoi_secure_hub-0.3.8.tar.gz
| Download URL | algovoi_secure_hub-0.3.8.tar.gz |
|---|---|
| Size | 258.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ab67a580a3f1e91b24b03340a234fff423f2f8a88deb3208b8da873cc4df609a
|
|
BLAKE2b-256 checksum How to use checksums |
129a4851f90014537ce13a3cfcf2b71547267a88782db4bc1855b218a194fa2a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.10
|
Release files / algovoi_secure_hub-0.3.8-py3-none-any.whl
| Download URL | algovoi_secure_hub-0.3.8-py3-none-any.whl |
|---|---|
| Size | 56.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
55cf6a0f8eabac4ac47fa8489da2a279e0f0626cd1d7deaca5ea9bbd721b04fc
|
|
BLAKE2b-256 checksum How to use checksums |
285b6521758e8ecfc26813c4efd8fd6118cb3113ab6e79cf9deff93ce26801dd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.10
|
Security for algovoi-secure-hub 0.3.8
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.