GHSA-v5px-423j-pf7p Nuclio: Unsanitized cron trigger event headers/body injected into CronJob shell command leads to persistent RCE
SummaryNuclio controller builds a `curl` invocation string for each cron trigger and stores it as the `args` of a Kubernetes CronJob container (`/bin/sh`, `-c`, `<command>`). Two fields in the trigger specification flow into this string without adequate sanitization:`event.headers` keys — interpolated verbatim inside double-quoted `--header` arguments (`lazy.go:2150`); any key containing `"` breaks the quoting context.`event.body` — processed with `strconv.Quote`, which escapes `"` and `\` but not `$()`, allowing command substitution (`lazy.go:2188`).Both paths were dynamically verified on Nuclio 1.15.27 (latest as of 2026-05-17).**CVSS 3.1**: `CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H` — **9.9 (Critical)****CWE**: CWE-78 (Improper Neutralization of Special Elements used in an OS Command)**Affected versions**: Nuclio <= 1.15.27 (latest, dynamically verified)DetailsRoot CauseWhen a NuclioFunction with a `cron` trigger is reconciled by the controller, it calls `generateCronTriggerCronJobSpec` in `pkg/platform/kube/functionres/lazy.go:2113`. This function builds a shell command string by concatenating user-supplied values and passes it directly to `/bin/sh -c`.**Path-A — Header key injection (`lazy.go:2146-2151`)**`headerKey` is taken from `event.headers` in the trigger specification. Since it is interpolated directly inside a double-quoted shell argument, a key containing `"` terminates the quoting context. The remainder of the key is then interpreted as raw shell syntax.Attack string for `headerKey`:Resulting shell command fragment:**Path-B — Body command substitution (`lazy.go:2173-2192`)**`strconv.Quote` wraps the string in double quotes and escapes `"` and `\`, but does not escape `$`, `(`, or `)`. A body value of `$(CMD)` becomes the Go string `"$(CMD)"`, which the shell expands as command substitution when executing the `/bin/sh -c` string.Attack string for `event.body`:Resulting shell command:**Execution sink (`lazy.go:2212`)**The entire concatenated string — including any injected content — is executed by the shell.**Persistence mechanism**The CronJob created by the controller carries no `ownerReferences` linking it to the NuclioFunction. Kubernetes cascade deletion only applies to owned resources. If the controller crashes between function deletion and explicit CronJob deletion, the CronJob continues executing on its schedule indefinitely. The controller code itself acknowledges this at `lazy.go:522`:PoCEnvironment SetupThe following steps reproduce the vulnerability in an isolated local environment.**Step 1 — Install prerequisites****Step 2 — Create isolated kind cluster**Expected output:**Step 3 — Deploy Nuclio (latest 1.15.27)**Wait for the controller to become ready:**Step 4 — Create a NuclioProject****Step 5 — Prepare a placeholder image for the function deployment**The controller needs a non-empty image field to create the function Deployment. Load any small image that is already present on the host:Exploitation — Path-A: Header Key Injection**Step 6 — Create a NuclioFunction with malicious header key**The injection payload in the header key is:**Step 7 — Trigger the controller to create the CronJob**Wait ~10 seconds for the controller to reconcile, then list CronJobs:Expected output:**Step 8 — Inspect the generated CronJob command (static confirmation)**Actual output from verification:The injected commands are clearly embedded between the shell-separated statements.**Step 9 — Manually trigger a CronJob run (dynamic confirmation)**Actual pod log output from verification:Line 1: `curl` exits immediately at `"X-Inject"` (no curl binary in alpine)Line 2: `echo "===RCE_CONFIRMED==="` executes — injection confirmedLine 3: `id` executes — container runs as `uid=0 (root)`Line 4: `cat .../token | head -c 50` exfiltrates the first 50 bytes of the K8s SA tokenExploitation — Path-B: Body Command Substitution**Step 10 — Create a NuclioFunction with malicious event body****Step 11 — Verify CronJob command (static)**Actual output from verification:`$()` is present unescaped inside a double-quoted string passed to `/bin/sh -c`.**Step 12 — Dynamic execution**Actual pod log output from verification:`id` ran as root via `$()` expansion before `curl` was even attempted.Persistence Verification**Step 13 — Confirm CronJob has no ownerReferences**Expected: empty (no output)**Step 14 — Simulate controller crash during function deletion**Actual output from verification:**Step 15 — Execute the persistent backdoor**Actual pod log output from verification:The injected command executes after the source function has been deleted.CleanupImpact**Remote Code Execution**: An attacker with network access to the Dashboard API (unauthenticated by default) can execute arbitrary shell commands inside the CronJob pod on every scheduled tick.**Runs as root**: Every CronJob pod confirmed running as `uid=0(root)` during verification.**ServiceAccount token exfiltration**: The pod's mounted SA token (`/var/run/secrets/ kubernetes.io/serviceaccount/token`) is readable by the injected commands and can be exfiltrated to an attacker-controlled host via the injected `curl` call. This token enables:Enumeration of Kubernetes API resources in the `nuclio` namespaceIn misconfigured clusters, cluster-wide API access**Persistent backdoor**: The CronJob resource has no `ownerReferences` and is not garbage-collected by Kubernetes. In the window between controller unavailability and explicit cleanup, the CronJob continues executing the attacker's commands on the configured schedule (minimum every 1 minute) — persisting beyond function deletion, Nuclio redeployments, or loss of attacker Dashboard access.**Cloud environment lateral movement**: In managed Kubernetes environments (AWS EKS, GCP GKE, Azure AKS), the injected commands can access the cloud instance metadata service to retrieve IAM credentials, enabling lateral movement outside the cluster.Severity**Critical — CVSS 3.1 Score: 9.9**| Metric | Value | Rationale |
|---|---|---|
| Attack Vector | Network | Dashboard is network-accessible |
| Attack Complexity | Low | No preconditions; straightforward payload |
| Privileges Required | None | NOP auth is the default configuration |
| User Interaction | None | Fully automated via API |
| Scope | Changed | Impact crosses pod boundary into cluster |
| Confidentiality | High | SA token, secrets readable |
| Integrity | High | Arbitrary command execution as root |
| Availability | High | Persistent CronJob can exhaust cluster resources |Affected VersionsAll Nuclio versions that support Kubernetes CronJob-based cron triggers, which includes the current production release.**Confirmed affected**: 1.15.27 (latest as of 2026-05-17, dynamically verified)**Earliest affected**: introduced when CronJob-based cron trigger support was added (cronTriggerCreationMode: kube)Patched Versionshttps://github.com/nuclio/nuclio/releases/tag/1.16.4Workarounds**Network-level restriction**: Place the Nuclio Dashboard behind an authenticated
reverse proxy or restrict port 8070 to trusted networks only. This limits who can
submit function specifications.**Disable cron triggers**: If cron trigger functionality is not required, avoid creating
functions with `kind: cron` triggers.**RBAC restriction**: Remove the `batch` API group permission from the Nuclio controller
ServiceAccount to prevent CronJob creation. Note: this disables cron trigger
functionality entirely.None of the above eliminate the root cause; they only reduce exposure.ResourcesVulnerable file: `pkg/platform/kube/functionres/lazy.go`Path-A: line 2150 — header key interpolationPath-B: lines 2188-2189 — body interpolation with `strconv.Quote`Execution sink: line 2212 — `Args: []string{"/bin/sh", "-c", curlCommand}`Go `strconv.Quote` documentation: does not escape `$`, `(`, `)`, or backticksCWE-78: Improper Neutralization of Special Elements used in an OS CommandCVSS 3.1 Calculator: `AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H`Remediation**P0 — Eliminate the shell layer (preferred fix)**Replace the `/bin/sh -c <string>` invocation with an exec-format argument list. This
removes shell interpretation entirely:With exec format, each argument is passed directly to the process without shell
interpretation. No quoting or escaping is needed.**P1 — Shell-safe quoting (fallback if shell is required)**If the shell invocation must be retained, apply proper POSIX shell quoting to all
user-supplied values before interpolation. The equivalent of Python's `shlex.quote`
must be implemented in Go:Apply to both `headerKey`, `headerValue`, and `eventBody` before inserting into the
command string.
CVSS v3.1 score: 10