GHSA-7PXF-2399-4955
Git HTTP redirects bypass CDXGEN_GIT_ALLOWED_HOSTS
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Divulgación | Publicada | GHSA-7PXF-2399-4955 divulgada | |
| Remediación | Parche 12.9.1 | @cyclonedx/cdxgen · 0 d desde divulgación | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
Summary
`CDXGEN_GIT_ALLOWED_HOSTS` and `CDXGEN_SERVER_ALLOWED_HOSTS` were checked only against the URL cdxgen was given. git follows the HTTP redirect of its first request by default, so an allowlisted host that answers with a redirect could send a clone or `ls-remote` to a host the allowlist does not name. In server mode an unauthenticated client chooses that first URL.
Details
`validateAndRejectGitSource()` and `gitClone()` in `lib/inventory/source.js` (`lib/helpers/source.js` in 12.x) compare the host of the requested URL with the allowlist, then run git through `hardenedGitCommand()`. That wrapper set `core.fsmonitor`, `safe.bareRepository`, the protocol allowlist and, in secure mode, ignored the global and system git config, but left `http.followRedirects` at git's default of `initial`. git therefore followed a 3xx answer to `/info/refs` to any host the permitted protocols could reach, and ran the rest of the clone or `ls-remote` against it. The HTTP client checks every redirect hop since GHSA-259h-c659-9x53, but git's own requests never passed through that check.
Proof of concept
Run two local HTTP servers: one on `127.0.0.1:18080` that answers every request with `302` to the same path on `localhost:18081`, and one on `localhost:18081` that logs requests. Start the server with `CDXGEN_GIT_ALLOWED_HOSTS=127.0.0.1 CDXGEN_GIT_ALLOW_PROTOCOL=http cdxgen --server` and request `/sbom?url=http://127.0.0.1:18080/repo.git&type=js`. The second server logs `GET /repo.git/info/refs?service=git-upload-pack`, although `localhost` is not on the allowlist and a direct request for it is refused.
Impact
The host allowlist is the control that keeps server-mode clones away from internal hosts. Where an allowlisted host can be made to return a chosen redirect, a client could probe internal hosts through timing and errors, clone an unauthenticated internal repository and receive its SBOM, or tie up the server on a slow target. Outside secure mode, git also reads the user's HTTP configuration, so a custom `http.extraHeader` could be sent to the redirect target.
Patches
Fixed in `@cyclonedx/cdxgen` 12.9.1 (#4758, commit 44d6ecb https://github.com/cdxgen/cdxgen/commit/44d6ecb2ee8fcccaa292b44db5ecc17c4c96c399). The fix for `@cdxgen/cdxgen` is in #4759 (commit 170bcb3 https://github.com/cdxgen/cdxgen/commit/170bcb320d1f4c0d74481f6d7855f65034591748) and will ship in 13.7.0. `hardenedGitCommand()` now sets `http.followRedirects=false` in git's command scope whenever a git host allowlist or secure mode applies, which covers every clone and `ls-remote`, and prints a hint when git stops at a redirect. With an allowlist set, a renamed repository has to be requested by its current URL. Without an allowlist, git still follows redirects, since any host is allowed there.
Workarounds
Allowlist only hosts that do not issue redirects to arbitrary destinations, or block outbound connections from the cdxgen server to internal networks at the network layer.
Credits
Reported by @andife.
References
- GHSA-259h-c659-9x53
- https://github.com/cdxgen/cdxgen/pull/4758
- https://github.com/cdxgen/cdxgen/pull/4759
Incluye detalles técnicos publicados por el investigador. Úselos solo para validar y corregir sus propios sistemas.
Rangos afectados
Estado del parche por paquete
| Paquete / producto | Estado | Corregida en | Desde divulgación | Última versión |
|---|---|---|---|---|
npm@cyclonedx/cdxgen |
Corregida | 12.9.1 | 0 d | 12.9.2 no afectada |
12.9.113.7.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-7pxf-2399-4955Las referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
