Ecstaticloud
Initializing0%
Ecstaticloud Logo
Back to Insights
Cybersecurity & AIOctober 2, 2026

Zero-Trust LLMs on Kubernetes: Securing Private AI Inference with eBPF and Cilium

As enterprise adoption of self-hosted LLMs explodes, traditional network security fails to catch sub-application layer data exfiltration and malicious prompt injection vectors. Learn how to leverage eBPF and Cilium to enforce granular zero-trust runtime security and observability across your AI inference pipelines.

The shift from managed SaaS AI endpoints to self-hosted, open-weights Large Language Models (LLMs) on Kubernetes is accelerating rapidly. Driven by strict data sovereignty mandates, strict latency budgets, and cost optimizations at scale, enterprise platform teams are deploying engines like vLLM, TGI (Text Generation Inference), and Triton Inference Server directly onto GPU-enabled Kubernetes clusters.

However, moving LLM inference in-house introduces unprecedented security challenges. Large language models are non-deterministic, highly complex, and heavily reliant on massive, dynamic Python dependency stacks (PyTorch, CUDA binaries, Hugging Face transformers). Traditional Kubernetes network security—primarily L3/L4 NetworkPolicies relying on static IP and port rules—is fundamentally blind to sub-application layer threats like prompt-injection-driven SSRF, unauthorized model weight exfiltration, and malicious arbitrary code execution via compromised Python dependencies.

To achieve a true Zero-Trust AI Architecture, we must shift security enforcement down to the Linux kernel. By combining eBPF (Extended Berkeley Packet Filter) and Cilium, we can build a transparent, ultra-performant, zero-trust perimeter around self-hosted LLM inference pipelines without introducing sidecar latency penalties.


The Anatomy of an AI Inference Security Breach

To understand why traditional container security falls short, let's break down the attack vectors specific to self-hosted AI workloads on Kubernetes:

+-----------------------------------------------------------------------------------+
|                            ATTACK VECTORS IN AI PIPELINES                          |
+-----------------------------------------------------------------------------------+
|                                                                                   |
|  [1. Malicious Prompt Injection] ---> ( Ingress Gateway )                         |
|                                                |                                  |
|                                                v                                  |
|  [2. Python RCE / Unsafe Pickle] ---> ( vLLM / Inference Pod )                     |
|                                                |                                  |
|       +----------------------------------------+--------------------------------+ |
|       |                                        |                                | |
|       v                                        v                                v |
| [3. Vector DB Exfiltration]        [4. SSRF via Tool Call]      [5. Weight Scraping] |
| ( Unauthorized Context Read )     ( External C2 Callbacks )    ( Models / S3 Leaks ) |
+-----------------------------------------------------------------------------------+
  1. Unsafe Model Weight Deserialization: While formats like safetensors mitigate risk, legacy PyTorch checkpoints (.pt, .bin) rely on Python’s pickle module. Loading untrusted weights can lead to arbitrary code execution (RCE) at model load time.
  2. Prompt Injection leading to SSRF: When an LLM is paired with agentic capabilities or retrieval-augmented generation (RAG), a prompt injection attack can manipulate the model into orchestrating Server-Side Request Forgery (SSRF) attacks against internal endpoints, AWS IMDS (Instance Metadata Service), or external Command & Control (C2) servers.
  3. Dependency Supply Chain Poisoning: AI runtimes pull hundreds of transitive C++ and Python dependencies. A single compromised PyPI package can quietly scan cluster networks, steal system prompts, or exfiltrate vector embeddings.
  4. Data & Weight Exfiltration: Fine-tuned weights and RAG context embeddings represent core enterprise IP. If an inference pod is compromised, traditional security tools cannot distinguish between legitimate model loading and unauthorized streaming of weights to an external S3 bucket.

The eBPF Paradigm: Kernel-Level Enforcement for AI Workloads

eBPF allows us to run sandboxed programs inside the Linux kernel dynamically without mutating kernel source code or loading kernel modules. Because every system call (networking, file access, process execution) must pass through the kernel, eBPF provides 100% visibility and control over everything happening inside an inference container.

+-----------------------------------------------------------------------------+
|                               USER SPACE                                    |
|                                                                             |
|  +--------------------+   +--------------------+   +---------------------+  |
|  |   vLLM Engine Pod  |   | Vector DB (Qdrant) |   |  Cilium / Hubble    |  |
|  +---------+----------+   +---------+----------+   +----------+----------+  |
+------------|------------------------|-------------------------|-------------+
|            | System Calls           | Packets                 | BPF Maps    |
+------------v------------------------v-------------------------v-------------+
|                               KERNEL SPACE                                  |
|                                                                             |
|  +-----------------------------------------------------------------------+  |
|  |                            eBPF Engine                                |  |
|  |                                                                       |  |
|  |  [ kprobes / tracepoints ]          [ cgroups / sk_skb ]             |  |
|  |   - Syscall interception             - L3/L4/L7 Routing               |  |
|  |   - Process Exec monitoring          - Transparent Encryption         |  |
|  +-----------------------------------------------------------------------+  |
+-----------------------------------------------------------------------------+

By leveraging Cilium (for network routing, L7 policy, and identity management) and Tetragon (for eBPF-based security observability and runtime enforcement), we enforce Zero-Trust at two critical layers:

  1. Network Identity & L7 Layer: Enforcing identity-based access control, strict protocol parsing (gRPC, HTTP/REST), and FQDN-based egress locking.
  2. Runtime Syscall Layer: Intercepting process execution, file descriptors, and socket creation directly in the kernel before malicious code can complete execution.

Implementing Zero-Trust AI Security: Step-by-Step

Let's walk through a production configuration securing a vLLM inference engine serving a Llama-3 70B model with a Qdrant vector database context engine.

Step 1: Enforcing Strict L3/L4 and L7 Microsegmentation

By default, Kubernetes networking is flat and permissive. We start by applying a zero-trust CiliumNetworkPolicy (CNP). This policy:

  • Denies all ingress/egress traffic by default.
  • Allows ingress to the inference service only from the API Gateway on port 8000 via specific REST endpoints (/v1/completions, /v1/chat/completions).
  • Restricts egress strictly to the Qdrant Vector DB on port 6333.
  • Blocks all raw IP internet outbound connectivity, granting temporary, restricted access only to Hugging Face via explicit FQDN filtering for initial model fetching (if local caching isn't available).
apiVersion: "cilium.io/v2"
kind: CiliumNetworkPolicy
metadata:
  name: secure-vllm-inference
  namespace: ai-inference
spec:
  endpointSelector:
    matchLabels:
      app.kubernetes.io/name: vllm-engine
  
  # --- INGRESS RULES ---
  ingress:
  - fromEndpoints:
    - matchLabels:
        app.kubernetes.io/name: api-gateway
        io.kubernetes.pod.namespace: ingress-system
    toPorts:
    - ports:
      - port: "8000"
        protocol: TCP
      rules:
        http:
        - method: "POST"
          path: "/v1/chat/completions"
        - method: "POST"
          path: "/v1/completions"
        - method: "GET"
          path: "/health"

  # --- EGRESS RULES ---
  egress:
  # 1. Allow communication strictly to Qdrant Vector DB
  - toEndpoints:
    - matchLabels:
        app.kubernetes.io/name: qdrant
        io.kubernetes.pod.namespace: ai-inference
    toPorts:
    - ports:
      - port: "6333"
        protocol: TCP

  # 2. Allow CoreDNS access for interior resolution
  - toEndpoints:
    - matchLabels:
        k8s-app: kube-dns
        io.kubernetes.pod.namespace: kube-system
    toPorts:
    - ports:
      - port: "53"
        protocol: UDP
      rules:
        dns:
        - matchPattern: "*"

  # 3. Secure Egress to Hugging Face Hub over HTTPS via FQDN filtering
  - toFQDNs:
    - matchName: "huggingface.co"
    - matchPattern: "*.hf.co"
    toPorts:
    - ports:
      - port: "443"
        protocol: TCP

Step 2: Runtime Kernel Protection against Code Execution via Tetragon

Network policies cannot stop a bad actor if an attacker successfully sends an exploit payload inside a valid HTTP POST request that tricks a vulnerable Python library into executing an in-memory binary or launching a reverse shell (/bin/sh).

To stop runtime exploits, we use Tetragon (Cilium's eBPF-based security observability and runtime enforcement tool). The following TracingPolicy hooks into kernel tracepoints (sys_execve) to enforce that the vLLM container can never spawn shell binaries or unexpected child processes, terminating violating processes instantly in kernel space.

apiVersion: cilium.io/v1alpha1
kind: TracingPolicy
metadata:
  name: prevent-llm-rce-and-shells
  namespace: ai-inference
spec:
  kprobes:
    - call: "sys_execve"
      syscall: true
      args:
        - index: 0
          type: "string" # The path to the binary being executed
      selectors:
        - matchNamespaces:
            - "ai-inference"
          matchArgs:
            - index: 0
              operator: "In"
              values:
                - "/bin/sh"
                - "/bin/bash"
                - "/usr/bin/python" # Block execution of secondary ad-hoc python scripts
                - "/usr/bin/curl"
                - "/usr/bin/wget"
                - "/usr/bin/nc"
          # Kills the process instantaneously at the kernel layer before context switches
          matchActions:
            - action: Sigkill

If a prompt-injection payload triggers a code execution exploit trying to run curl to exfiltrate cached embeddings, the Linux kernel intercepts the sys_execve call instantly, sends a SIGKILL to the process, and generates an auditable security event in real time.


Runtime Observability with Hubble

Securing AI pipelines requires deep real-time visibility. Traditional logging drops network-level details, while service meshes inject heavy sidecar proxies that increase latency—an unacceptable tradeoff for time-to-first-token (TTFT) metrics in LLMs.

Cilium’s Hubble uses eBPF to extract flow logs directly from kernel sockmaps without proxies.

You can inspect flows live targeting your inference namespace via the Hubble CLI:

# Observe real-time HTTP L7 inference requests, monitoring for non-200 responses or anomalous drops
hubble observe --namespace ai-inference \
  --pod vllm-engine-7d949479b4-x8z9l \
  --protocol http \
  --follow

Example JSON telemetry output provided directly from eBPF maps:

{
  "flow": {
    "time": "2026-03-31T14:22:01.401827412Z",
    "verdict": "FORWARDED",
    "IP": {
      "source": "10.244.1.12",
      "destination": "10.244.2.45"
    },
    "l4": {
      "TCP": {
        "source_port": 49152,
        "destination_port": 8000
      }
    },
    "source": {
      "namespace": "ingress-system",
      "pod_name": "api-gateway-68798d7f8d-4j2x9",
      "labels": ["app.kubernetes.io/name=api-gateway"]
    },
    "destination": {
      "namespace": "ai-inference",
      "pod_name": "vllm-engine-7d949479b4-x8z9l",
      "labels": ["app.kubernetes.io/name=vllm-engine"]
    },
    "l7": {
      "type": "REQUEST",
      "http": {
        "method": "POST",
        "protocol": "HTTP/1.1",
        "path": "/v1/chat/completions",
        "url": "http://vllm-engine.ai-inference.svc.cluster.local:8000/v1/chat/completions"
      }
    }
  }
}

If an attacker attempts to egress to an unapproved external IP address via a tool call, Hubble reports the exact rule dropping the flow:

TIMESTAMP             SOURCE                                   DESTINATION                 TYPE          VERDICT
Mar 31 14:23:10.104   ai-inference/vllm-engine-7d949479b4      198.51.100.42:443           to-stack      DROPPED (Policy denied)

Architectural Best Practices for Production AI Workloads

To build an enterprise-grade, bulletproof inference setup, adhere to the following architecture rules:

1. Zero-Trust Local Storage Strategy

  • Pre-fetch Weights: Do not allow production inference pods to download models from Hugging Face on startup. Use init containers or CSI drivers (e.g., Mountpoint for Amazon S3) to mount models directly into the pod as read-only volumes.
  • Strict Egress Lock: Drop HF egress policies entirely once models are stored locally. Set egress: [] (deny-all egress) on production inference deployment specs.

2. File Format Hygiene

  • Mandate the use of .safetensors model formats.
  • Configure runtime flags (e.g., in vLLM or TGI) to explicitly disallow unsafe serialization formats (trust_remote_code=False).

3. Transparent In-Kernel Encryption

  • Avoid heavy Envoy sidecars for node-to-node TLS encryption within your GPU cluster.
  • Use Cilium's native WireGuard or IPsec kernel acceleration to encrypt intra-cluster data vectors transparently without adding tail-latency overhead to inference tokens:
# Cilium Helm values configuration
helm upgrade cilium cilium/cilium \
  --namespace kube-system \
  --set encryption.enabled=true \
  --set encryption.type=wireguard

Conclusion

Securing self-hosted LLM workloads requires moving beyond standard perimeter defenses. AI applications operate over dynamic, vulnerable environments where application logic is inherently probabilistic and susceptible to injection attacks.

By adopting eBPF and Cilium, enterprise cloud engineers can construct a resilient Zero-Trust architecture. This approach enforces deep L7 visibility, identity-driven network segmentations, and hard kernel-level execution boundaries directly at the Linux kernel—protecting AI systems, enterprise context, and fine-tuned IP from modern exploit vectors with minimal latency.