inkwall

module
v0.1.0-rc.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 25, 2026 License: Apache-2.0

README

Inkwall

A Kubernetes-native web application firewall. Install one operator, and every ingress and gateway in your cluster is protected by the same policy.

Status: early development. No release exists yet. The inspection engine works as a standalone reverse proxy and behind Traefik's ForwardAuth (see Try it); the other proxy integrations and the Kubernetes operator are not built yet. The architecture is written up in docs/design. Sections other than "Try it" describe the target, not shipped features.


Why Inkwall

Running a WAF in Kubernetes today means picking one per proxy: ModSecurity for ingress-nginx, a plugin for Traefik, a WASM filter for Envoy, an SPOA agent for HAProxy, each with its own config, rules, and failure modes. Change your ingress, and you rebuild your WAF.

Inkwall makes the WAF a Kubernetes primitive, the way cert-manager did for TLS:

  • One policy, every proxy. Write a WAFPolicy against an Ingress or HTTPRoute. The operator discovers which controller serves it and wires the engine in using that proxy's native hook.
  • Standard rules. Built on OWASP Coraza and the OWASP Core Rule Set. Existing ModSecurity rules and exclusions keep working.
  • Fast by design. The engine runs as a sidecar next to the proxy over a Unix socket (or in-process for Caddy), with tiered checks so most requests never touch a regex. Latency budgets are part of the design, and CI will fail on regressions.
  • Safe by default. New routes start in detect mode (no added latency, no false-positive outages). In block mode nothing is forwarded uninspected; detect mode never blocks. Policies are signed.
  • GitOps first, SaaS optional. CRDs in Git are the source of truth. Everything enforces fully offline; an optional control plane adds fleet management and attack analytics.
  • A way off ingress-nginx. Protect ingress-nginx today, move routes to a Gateway API implementation tomorrow, and keep the same policies.

How it works

  1. inkwall-operator watches your routes and WAFPolicy objects, injects the engine into your ingress controller pods, wires the proxy, and pushes signed policy bundles to every engine.
  2. inkwall-engine answers each proxy's native protocol (Envoy ext_proc/ext_authz, HAProxy SPOE, forward-auth, a Lua plugin for ingress-nginx) and returns allow / deny in microseconds.
  3. Status on each policy tells you how far it got: Accepted → Programmed → Enforced on every engine.

Example

apiVersion: waf.inkwall.dev/v1alpha1
kind: WAFPolicy
metadata:
  name: shop
  namespace: shop
spec:
  targetRefs:
  - group: gateway.networking.k8s.io
    kind: HTTPRoute
    name: shop-api
  mode: Detect            # switch to Block once false positives are tuned
  ruleSets:
  - ref: {kind: ClusterWAFRuleSet, name: owasp-crs-v4}
    paranoiaLevel: 1
  rateLimits:
  - name: login
    match: {path: /api/login, methods: [POST]}
    key: ClientIP
    limit: 10
    window: 1m
$ kubectl get wafpolicy -n shop
NAME   MODE     READY   ENGINES   AGE
shop   Detect   True    3/3       2m

(Illustrative. The API is v1alpha1 and will change.)

Try it

The engine runs today as a standalone reverse proxy in front of any HTTP service. It inspects requests with the OWASP Core Rule Set, which is embedded in the binary.

$ make build
$ ./bin/inkwall-engine proxy --upstream http://localhost:3000 --mode block
$ curl -s -o /dev/null -w '%{http_code}\n' 'localhost:8480/?id=1%27%20OR%20%271%27%3D%271'
403

Each blocked or detected request produces one JSON log line with the matching rule IDs. Metrics are on :9480/metrics, health on :9480/healthz and :9480/readyz.

Defaults are deliberately safe. The engine starts in detect mode: it logs what it would block and never blocks. In block mode, a request that cannot be fully inspected (inspection timed out, failed, or the engine is overloaded) is rejected with 503, so padding a request until inspection times out cannot get an attack through; in detect mode such requests are allowed and logged. Use --failure-mode open to prefer availability in block mode. Useful flags:

Flag Default Purpose
--mode detect block to enforce
--paranoia-level 1 CRS paranoia level, 1-4
--max-body-bytes 65536 Body bytes to inspect
--oversize-body auto Bodies over the limit: deny (413), allow (forwarded uninspected, logged), auto = deny in block mode
--max-args 1000 Maximum arguments per source; more is rejected with 400
--rules SecLang rules and configure-time exclusions, loaded after CRS
--rules-before-crs Runtime exclusions (ctl:ruleRemoveById …) and settings, loaded before CRS
--trusted-proxies CIDRs whose X-Forwarded-For is trusted
--skip-paths Paths never inspected, e.g. /healthz,/static/*
--skip-body-paths Paths whose body is not inspected, e.g. /upload/*
--disable-rule-groups CRS families the app can't be vulnerable to, e.g. php,java (~13-15% faster)
--failure-mode auto auto = closed in block mode, open in detect; or open / closed
--timeout 250ms Inspection deadline per request (a safety cap, not typical latency)

Run ./bin/inkwall-engine proxy -h for all flags. Inspection currently costs about 0.5 ms per request plus roughly 0.15 ms per request argument, so skipping static and trusted routes matters; see the performance baseline.

Behind Traefik, inkwall-engine forward-auth answers Traefik's ForwardAuth middleware on 127.0.0.1:9001/v1/forward-auth, with the same flags minus --upstream. Run it as a sidecar in Traefik's pod with --trusted-proxies=127.0.0.1/32, and configure the middleware with trustForwardHeader: false (otherwise clients can make the engine inspect a URI of their choice) and forwardBody: true (otherwise bodies are not inspected). See hack/kind/traefik-demo.yaml and the design notes.

With the operator (Helm chart), all of this is automatic: Traefik pods get the engine injected when they start, and every Ingress a WAFPolicy targets gets the ForwardAuth Middleware, until the policy reports Ready.

The check API. inkwall-engine check serves the engine's own API, POST /v1/check (api/engine/v1), for proxies without a native protocol: the proxy describes one request as a CheckRequest, in protobuf (application/x-protobuf) or JSON (application/json), and gets the verdict back. It listens on 127.0.0.1:9002 by default. It trusts the caller's client_ip, so expose it only to the proxy, for example on a Unix socket:

$ ./bin/inkwall-engine check --listen unix:/run/inkwall/engine.sock --mode block
$ curl -s --unix-socket /run/inkwall/engine.sock -H 'Content-Type: application/json' \
    -d '{"method":"GET","raw_uri":"/?id=1%27%20OR%20%271%27%3D%271","authority":"shop.example.com"}' \
    http://engine/v1/check
{"action":"ACTION_DENY","status":403,"rule_ids":[942100,949110],"reason":"REASON_RULE",...}

Policies from the operator (bundle mode). With --operator host:port, any of the three commands takes its policies from the operator's signed bundles instead of the flags that define a policy (--mode, --rules, --skip-paths, ...; setting one is then an error). Each request is inspected by the policy of its route, matched on host, decoded path and method; a host no policy covers is allowed and reported as no-policy. The engine authenticates with a projected ServiceAccount token (--operator-token), verifies the operator's certificate (--operator-ca) and every bundle's ed25519 signature (--bundle-key) before applying it, and swaps policies without a restart. Without the operator it keeps enforcing the last bundle, also across restarts with --bundle-cache; a new engine with no cache reads the operator's bundle Secret through the Kubernetes API (--bundle-secret). Until it has a bundle it stays unready for up to --bootstrap-timeout (10s), then allows requests uninspected or, with --bootstrap deny, rejects them with 503. The operator injects this configuration (#27); see 0002 §5.2.

Testing rules without traffic. inkwallctl test shows the verdict and the matching rules for a request given like a curl command, as raw HTTP in a file (--request), or as a browser HAR export (--har). It runs the engine's checks in-process with the same flags (--paranoia-level, --rules, ...), or against a running engine with --engine. --expect allow|deny makes it a CI check for rule changes:

$ ./bin/inkwallctl test 'http://shop.example.com/?id=1%27%20OR%20%271%27%3D%271'
deny  403  GET /?id=1%27%20OR%20%271%27%3D%271  reason=rule  rules=942100,949110  interrupting=949110  847µs
$ ./bin/inkwallctl test --rules my-exclusions.conf --expect allow --har checkout-flow.har

To run it in Kubernetes, make kind-up creates a kind cluster with a demo app published twice: behind the engine's reverse proxy (127.0.0.1:30480) and through Traefik with the engine as a forward-auth sidecar (127.0.0.1:30080), both in block mode. make kind-test sends benign and attack requests through both and checks the verdicts. make kind-down deletes the cluster. The setup is in hack/kind.

On the same cluster, make kind-operator installs the operator with the Helm chart and checks its webhook and bundles, and make kind-e2e runs the end-to-end test: a WAFPolicy applied in the cluster is enforced by an engine that takes it from the operator, follows edits without a restart, keeps enforcing while the operator is down, and stops when the policy is deleted. CI runs it on every pull request.

Development checks: make check (lint, tests, vulnerability scan), make crs-test (the OWASP CRS regression suite, about 4,500 tests, through the proxy) and make bench-compare (benchmarks against origin/main; fails on a significant regression over 5%, as CI does on every PR).

Measuring performance. inkwallctl bench replays a fixed mix of benign and attack requests and reports p50/p99/p99.9 per request class and throughput per core; --rate 2000 holds a fixed load to measure latency below saturation, and --engine measures a running engine instead. --pprof on the engine serves /debug/pprof/ on the admin listener; keep that listener private when it is on.

Planned integrations

Proxy / controller Hook Body inspection
Envoy, Envoy Gateway, Istio, Contour ext_proc (or ext_authz) streamed
HAProxy (both Kubernetes ingress controllers) SPOE yes
ingress-nginx Lua plugin (or global auth URL) yes (plugin)
Traefik ForwardAuth (works today), later a plugin yes, with forwardBody (buffered)
Caddy native module, in-process yes
Anything else standalone reverse proxy yes

Roadmap

  1. Engine: Coraza + CRS, tiered pipeline, standalone reverse-proxy mode, benchmark harness.
  2. Envoy integration end to end on kind.
  3. HAProxy, ingress-nginx, Traefik, Caddy integrations.
  4. Operator + Helm chart: discovery, injection, wiring, signed bundles, status.
  5. Optional control plane: multi-cluster policy management and attack analytics.

Documentation

Doc What it covers
Component map Start here: diagrams of every component, where it runs, why Coraza
Performance-first architecture Latency budgets, tiered pipeline, failure behaviour
System architecture Engine, CRDs, protocols, per-proxy integration
Kubernetes operator Discovery, injection, wiring, bundles, status, uninstall
Adapter protocols ext_authz, ext_proc, forward-auth, SPOE explained

Contributing

Contributions and design feedback are welcome. Read CONTRIBUTING.md for commit conventions, branching, and releases. Everyone taking part is expected to follow the Code of Conduct.

Security

Please report vulnerabilities privately as described in SECURITY.md, never in public issues.

License

Inkwall is licensed under the Apache License 2.0.

Directories

Path Synopsis
api
cmd
engine command
Command inkwall-engine runs the Inkwall inspection engine.
Command inkwall-engine runs the Inkwall inspection engine.
inkwallctl command
Command inkwallctl is the Inkwall command-line tool.
Command inkwallctl is the Inkwall command-line tool.
operator command
Command inkwall-operator is Inkwall's Kubernetes operator: it turns WAFPolicy and the other waf.inkwall.dev objects into policy bundles for the engines, and wires the cluster's proxies to them (docs/design/0004).
Command inkwall-operator is Inkwall's Kubernetes operator: it turns WAFPolicy and the other waf.inkwall.dev objects into policy bundles for the engines, and wires the cluster's proxies to them (docs/design/0004).
hack
benchgate command
Command benchgate fails when benchmarks regressed.
Command benchgate fails when benchmarks regressed.
operator
api/v1alpha1
Package v1alpha1 holds the Inkwall Kubernetes API (group waf.inkwall.dev): the cluster configuration, the policies app teams attach to their routes, and the rule sets those policies use.
Package v1alpha1 holds the Inkwall Kubernetes API (group waf.inkwall.dev): the cluster configuration, the policies app teams attach to their routes, and the rule sets those policies use.
integrations
Package integrations knows the proxies Inkwall wires into (0004 §4.2): how to recognise each one's IngressClass and pods, and which engine adapter its pods use.
Package integrations knows the proxies Inkwall wires into (0004 §4.2): how to recognise each one's IngressClass and pods, and which engine adapter its pods use.
internal/bundle
Package bundle builds, signs and stores policy bundles (0004 §4.6).
Package bundle builds, signs and stores policy bundles (0004 §4.6).
internal/controller
Package controller holds the operator's reconcilers.
Package controller holds the operator's reconcilers.
internal/distribution
Package distribution serves bundles to the engines (0004 §4.7): every operator replica runs the BundleService, pushes each new bundle to its connected engines, and records what they applied.
Package distribution serves bundles to the engines (0004 §4.7): every operator replica runs the BundleService, pushes each new bundle to its connected engines, and records what they applied.
internal/injection
Package injection gets the engine into a proxy's pods (0004 §4.3): a Pod webhook adds it as a native sidecar, and a controller provides what the sidecar needs in the pod's namespace (the trust ConfigMap) and in the operator's (read access to the bundle Secret).
Package injection gets the engine into a proxy's pods (0004 §4.3): a Pod webhook adds it as a native sidecar, and a controller provides what the sidecar needs in the pod's namespace (the trust ConfigMap) and in the operator's (read access to the bundle Secret).
internal/resolver
Package resolver turns the cluster's WAF objects into bundle policies (0004 §4.5): each WAFPolicy's targets are expanded into concrete host / path matches, its rule sets resolved, and conflicts between policies settled.
Package resolver turns the cluster's WAF objects into bundle policies (0004 §4.5): each WAFPolicy's targets are expanded into concrete host / path matches, its rule sets resolved, and conflicts between policies settled.
internal/wiring
Package wiring sends a proxy's protected routes to the engine (0004 §4.4).
Package wiring sends a proxy's protected routes to the engine (0004 §4.4).
manager
Package manager assembles the operator: the controllers and webhooks, in one controller-runtime manager.
Package manager assembles the operator: the controllers and webhooks, in one controller-runtime manager.
test/fakeengine
Package fakeengine is a lightweight engine for operator tests (0004 §9): it speaks the bundle protocol, verifies each bundle's signature and acknowledges it, without inspecting any traffic.
Package fakeengine is a lightweight engine for operator tests (0004 §9): it speaks the bundle protocol, verifies each bundle's signature and acknowledges it, without inspecting any traffic.
test/testenv
Package testenv starts a local API server (envtest) with the Inkwall CRDs installed, for operator tests.
Package testenv starts a local API server (envtest) with the Inkwall CRDs installed, for operator tests.
webhook
Package webhook holds the operator's admission webhooks.
Package webhook holds the operator's admission webhooks.
pkg
adapters/forwardauth
Package forwardauth implements the forward-auth adapter used by Traefik's ForwardAuth middleware.
Package forwardauth implements the forward-auth adapter used by Traefik's ForwardAuth middleware.
adapters/httpcheck
Package httpcheck implements POST /v1/check, the engine's own check API (api/engine/v1).
Package httpcheck implements POST /v1/check, the engine's own check API (api/engine/v1).
adapters/internal/httpadapter
Package httpadapter holds request handling shared by the adapters that receive requests over net/http: the reverse proxy and forward-auth.
Package httpadapter holds request handling shared by the adapters that receive requests over net/http: the reverse proxy and forward-auth.
adapters/proxy
Package proxy implements Inkwall's standalone mode: an HTTP reverse proxy that inspects each request and forwards allowed ones to an upstream.
Package proxy implements Inkwall's standalone mode: an HTTP reverse proxy that inspects each request and forwards allowed ones to an upstream.
agent
Package agent connects the engine to the operator (0002 §5.2): it keeps one stream open, verifies and applies every bundle the operator sends, and reports what it applied.
Package agent connects the engine to the operator (0002 §5.2): it keeps one stream open, verifies and applies every bundle the operator sends, and reports what it applied.
clientip
Package clientip resolves the real client address of a request that may have passed through load balancers or proxies.
Package clientip resolves the real client address of a request that may have passed through load balancers or proxies.
pipeline
Package pipeline turns a request into a verdict: it runs the rule evaluator under a per-request deadline and applies the enforcement mode (detect or block) and the failure mode (fail open or closed).
Package pipeline turns a request into a verdict: it runs the rule evaluator under a per-request deadline and applies the enforcement mode (detect or block) and the failure mode (fail open or closed).
policy
Package policy enforces a bundle: each policy of the bundle gets its own pipeline (mode, failure mode, timeout, skip paths, rules, body settings), and each request is inspected by the policy of its route.
Package policy enforces a bundle: each policy of the bundle gets its own pipeline (mode, failure mode, timeout, skip paths, rules, body settings), and each request is inspected by the policy of its route.
request
Package request defines the canonical HTTP request that every Inkwall adapter produces and the inspection pipeline consumes.
Package request defines the canonical HTTP request that every Inkwall adapter produces and the inspection pipeline consumes.
router
Package router decides, before any rule runs, how much of a request needs inspection (pipeline tier T0).
Package router decides, before any rule runs, how much of a request needs inspection (pipeline tier T0).
rules
Package rules defines the interface between the inspection pipeline and a rule engine.
Package rules defines the interface between the inspection pipeline and a rule engine.
rules/coraza
Package coraza implements rules.Evaluator with OWASP Coraza and the OWASP Core Rule Set (CRS), which is embedded in the binary.
Package coraza implements rules.Evaluator with OWASP Coraza and the OWASP Core Rule Set (CRS), which is embedded in the binary.
telemetry
Package telemetry exposes engine metrics in the Prometheus format and the admin endpoints (/metrics, /healthz, /readyz).
Package telemetry exposes engine metrics in the Prometheus format and the admin endpoints (/metrics, /healthz, /readyz).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL