A per-node L7 egress gateway for the Kubescape AI sandbox. It sits between sandboxed pods and every destination outside the cluster: Envoy terminates the pod's TLS with a certificate minted for the SNI, an external processor reads the request and the streamed response, and the bytes go on to the original destination unchanged. Plain HTTP is read the same way; anything else is forwarded at L4.
This repo holds the gateway's node controller, its processor and the Envoy config. The eBPF redirect that sends pod connections here lives in kubescape/node-agent. The processor judges each request with the rule evaluator in pkg/evaluator and the provider registry in pkg/providers, and answers a blocked request in the provider's own error shape. A build can add a capture exporter through pkg/processor.Run, or replace the evaluator through pkg/plugin.
Early. The code was seeded from an audit-only proof of concept and has not been released. Flag names, socket paths and the plugin interface will change.
Envoy 1.40 is the minimum version. CI runs 1.40.2.
| Path | What it is |
|---|---|
cmd/node-controller |
Delta ADS server. Serves Envoy its listeners and mints a leaf certificate on demand for each SNI, under a node-wide cap and mint rate limit. See docs/features/node-controller.md. |
cmd/processor |
Envoy external processor (ext_proc, full duplex streamed). Finds the pod that sent each request, parses requests and streamed responses, runs the stall watchdog, writes one record per transaction. See docs/features/processor.md. |
pkg/plugin |
The interface an evaluator implements (contract C6), and the registry a build adds its evaluator to. |
pkg/processor |
The processor program, for builds that add an exporter or an evaluator. |
pkg/evaluator, pkg/providers |
The rule evaluator, and its provider registry: which hosts are model providers, where each puts the model, and each one's deny and stream-error shapes (from armoapi-go armotypes/aiproviders). |
internal/ads, internal/ca, internal/xds |
The ADS server and the minter (cap, rate limit, idle release, renewal), certificate signing, and the listeners. |
internal/extproc, internal/app |
The processor itself, and the code that wires and runs it. |
internal/conntable, internal/lookup |
Who sent a request: the connection and bindings tables node-agent pins, and node-agent's workload lookup. |
internal/policysource, internal/stale |
The processor's informers on the policy objects, and when a workload's policy is too old to trust. |
internal/sse, internal/streamfmt, internal/renumber, internal/eventstream, internal/wsframe, pkg/jsonscan |
Stream parsing: server-sent events, the Anthropic and OpenAI stream formats, removing and renumbering streamed items, AWS event stream (Bedrock), WebSocket frames, and request JSON fields. |
internal/record, internal/otlpemit |
The verdict record (contract C7), and sending it as OTLP logs. |
deploy/envoy/envoy.yaml |
The Envoy config. |
test/ |
Test fixtures (mock-anthropic, sniflood, latbench, streamcheck, processor-it), the integration stack, the SDK job (test/sdk), the latency bench (test/bench) and spikes (test/spike). |
You need Go 1.26 or newer. The integration test also needs Docker.
go build ./...go test -race ./...The integration test builds the images, starts the node controller and a processor build with a stub connection table (test/processor-it) next to Envoy 1.40.2 and a mock provider, and makes one streamed call through the gateway. The client trusts only the gateway's CA, so the call fails unless Envoy served a certificate the node controller minted. It checks a leaf minted for an arbitrary SNI, refusals that fail fast (a .invalid name, an IP-literal SNI, no SNI), a hung handshake ended by its timeout, the plain HTTP and L4 chains, and a connection with no recorded destination. It sends a forged X-Forwarded-For header and a PROXY protocol line and checks that the processor still sees the socket's own address. It checks that the shipped processor image will not start without the tables.
test/integration/run.shTo build the images by hand:
docker build -f build/Dockerfile.node-controller -t sandbox-gateway-node-controller .docker build -f build/Dockerfile.processor -t sandbox-gateway-processor .Both images run as a non-root user (uid 65532). Each creates its unix socket with mode 0660 and, when SANDBOX_GATEWAY_SOCKET_GID is set, hands it to that group so Envoy can connect. Envoy's official image runs with gid 101, so set the variable to 101 and add 101 as a supplementary group of the container. test/integration/compose.yaml shows the full setup.
The processor reads the connection tables node-agent pins under /sys/fs/bpf/kubescape-sandbox/http/ and will not start without them, so it needs CAP_BPF and the bpffs mount. It also asks node-agent who owns a connection over /run/kubescape-sandbox/lookup.sock.
The debug HTTP servers (-debug-addr) have no authentication and listen on loopback by default. Keep them there.
The admin interface is a unix socket private to the gateway pod. It has no authentication and can stop Envoy, so do not expose it on an address a pod can reach.
Set node.id and node.cluster in the bootstrap. Without them Envoy 1.40.2 passes --mode validate and then aborts on the first TLS handshake, when the on-demand certificate lookup opens its subscription.
Keep transport_socket_connect_timeout on the TLS chain. It is the only bound on a handshake that waits for its certificate.
Kubescape keeps its project documents in one place, and the files in this repo point there: contributing, code of conduct, governance, maintainers, community, adopters.
To report a vulnerability, follow SECURITY.md. Do not open a public issue for it.
Apache 2.0. See LICENSE.