
LeitWacht v1.21.0
Leitwacht control plane — sicurezza runtime per CI/CD di GitLab Runner: authoring di policy, multi-tenancy, audit, integrazione con GitLab
GitLab Runner Leitwacht
Network egress enforcement for GitLab Runner CI/CD containers. Leitwacht prevents supply chain attacks from exfiltrating secrets by controlling what each job container can access on the network.
How It Works
Leitwacht is a standalone agent that runs alongside GitLab Runner on each node. It intercepts container start events, attaches enforcement primitives, and reports all network activity to a central backend. No modifications to GitLab Runner required.
Enforcement Stack (per container)
Container Process
|
| DNS query (port 53)
v
nftables redirect ──> DNS Proxy (:15353)
|
|── Allowlist check (FQDN match)
|── Block: sinkhole IP answer (192.0.2.1)
|── Allow: forward to upstream, add resolved IPs to eBPF allow map
|── Record: domain, resolved IPs, PID, process name
v
Upstream DNS (CoreDNS / external)
Container Process
|
| TCP/UDP egress (any port)
v
eBPF cgroup-skb/egress filter
|── IP in allow map? ──> ALLOW (counted)
|── IP in trusted CIDRs? ──> ALLOW (Docker/Podman bridge nets; leave empty on Kubernetes)
|── Cloud metadata (169.254.169.254)? ──> BLOCK (always)
|── DoT (port 853)? ──> BLOCK (always)
|── IPv6 (non-loopback)? ──> BLOCK (always)
|── Default ──> BLOCK (drop event to ringbuf)
Pod-Level Sharing (Kubernetes)
All containers in a K8s pod share one network namespace. Leitwacht creates a single NetnsContext per pod that owns the shared state (DNS proxy, nftables rules, eBPF maps). Each container gets its own cgroup-skb attachment so no sibling can bypass the filter.
Pod (shared netns)
+-- NetnsContext (1 per pod)
| +-- DNS Proxy (1 goroutine pair)
| +-- nftables redirect rules
| +-- eBPF program + maps
| +-- Ringbuf reader
|
+-- Container A
| +-- CgroupLink (eBPF attached to A's cgroup)
| +-- ViolationRecorder
|
+-- Container B
+-- CgroupLink (eBPF attached to B's cgroup)
+-- ViolationRecorder
Agent-Backend Communication
+------------------+ gRPC +------------------+
| Leitwacht Agent | ──────────────────────> | Leitwacht Server |
| (per node) | | (central) |
| | GetPolicy(project) | |
| - Watcher | <───────────────────── | - Policy store |
| - Enforcer | | - Violation DB |
| - DNS Proxy | ReportViolations(job) | - REST API |
| - Reporter | ──────────────────────> | - Frontend SPA |
| - Credwatch / | | - Notifications |
| proc_mem LSM | Heartbeat() | - Baselines |
| | ──────────────────────> | - Anomaly det. |
+------------------+ +------------------+
Architecture
Components
| Component | Description |
|---|---|
Agent (cmd/agent) | DaemonSet on runner nodes. Watches containerd for job containers, attaches eBPF + DNS proxy, reports violations. Requires root + Linux. |
Server (cmd/server) | Central backend. REST API for the frontend, gRPC for agents. Stores policies, violations, baselines. Postgres or SQLite. |
Frontend (frontend/) | SvelteKit SPA. Policy management, violation viewer, baseline management, anomaly detection, audit log. |
Key Packages
This repository is the EE server + EE-licensed agent. The network-enforcement data plane shown in the diagrams above (eBPF, DNS proxy, nftables, the containerd watcher) lives in the separate, MPL-2.0 Community-Edition module
leitwacht-agent, which this repo consumes as a dependency;cmd/agent+ee/are the EE build that reuses it and wires it to the backend.
| Package | Purpose |
|---|---|
internal/agentgrpc | gRPC server: ingests agent violation reports, serves policy + rule streams |
internal/api | REST API handlers, auth middleware, RBAC scoping |
internal/auth | OIDC (GitLab) authentication, sessions, CSRF |
internal/store | GORM data access (projects, violations, baselines) + ClickHouse |
internal/license, internal/licensemgr | EE license verify (Ed25519 JWS) + lifecycle and config gate (see LICENSE) |
internal/notify | Alert delivery (email/SES, Slack) + templates |
internal/retention | Data-retention / pruning |
internal/mcp, internal/mcpauth | MCP server + auth |
ee/reporter | EE agent gRPC client pushing violations + advisories to the backend |
ee/policycache, ee/rulewatcher, ee/rulestore | EE agent policy cache + rule watch/store (BBolt) |
contract/ | Shared Go module: .proto sources + generated agentpb wire types |
Deployment
Prerequisites
- Kubernetes cluster with containerd runtime
- GitLab Runner using the Kubernetes executor
FF_NETWORK_PER_BUILD=trueon runners (each job gets its own network namespace)
Helm Charts
Server (helm/) — published as an OCI chart. Needs Postgres + ClickHouse and
a few pre-created secrets (DB DSN, auth keys). See
docs/DEPLOY.md for the full runbook.
helm install leitwacht \
oci://registry.gitlab.com/leitwacht/leitwacht/charts/leitwacht --version 1.31.0 \
--set image.tag=1.31.0 \
--set ingress.domain=example.com --set ingress.hosts[0]=leitwacht.example.com \
--set grpcIngress.domain=example.com --set grpcIngress.hosts[0]=grpc-leitwacht.example.com \
--set app.oidcIssuer=https://gitlab.com --set app.oidcClientId=<oauth-app-id> \
--set clickhouse.embedded.password=<password>
Agent (helm/agent/):
helm install leitwacht-agent \
oci://registry.gitlab.com/leitwacht/leitwacht/charts/leitwacht-agent --version 1.31.0 \
--set agent.backendAddr="leitwacht.namespace.svc.cluster.local:9090" \
--set agent.defaultAction=audit \
--set agent.dnsUpstream="10.96.0.10:53"
Harden job pods. For Kubernetes runners:
- Do not set pod or service CIDRs in
agent.trustedCIDRs. Block mode already drops cluster-internal addresses by default; trusting those ranges lets jobs reach internal services unrecorded and makes DNS denies for*.cluster.localineffective.trustedCIDRsis for Docker/Podman executors, where service and helper containers sit on bridge networks. In block mode, jobs that need in-cluster services (GitLab, cache, registry) need explicit allow rules above the seeded*.cluster.localdeny. (AclusterCIDRsvalue that warns whentrustedCIDRsoverlaps the cluster ranges is planned.) - DNS: the chart's runner patch also sets
ndots:2on job pods (fewer lookups and lower latency; in-cluster short names still resolve via the search list), and the agent drops the noise from search-list expansions of public-looking domains when the cluster DNS says the name does not exist under the cluster domain (agent.dnsExpansionSuppression, defaultstructural,"off"to disable;agent.clusterDomain, defaultcluster.local; the per-container DNS answer cache isagent.dnsCacheSize, default 1024,0disables). Details incmd/agent/README.md. - Disable the service-account token in job pods. The chart's runner
pod_spec patch (
helm/agent/files/runner-pod-spec-patch.yaml) setsautomountServiceAccountToken: false(it overrides the runner's own setting; remove the line for runners whose jobs need a token); the runnerconfig.tomlequivalent is[runners.kubernetes] automount_service_account_token = false(or aservice_accountwithout RBAC). A job token can call the API server, which IP-level egress rules do not stop.