GHSA-8QFP-98QG-JJWV
qbee-io/transport TAR upload extraction can create escaping symlinks outside the destination root
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Remediación | Parche v1.26.34 | go.qbee.io/transport · -8 d desde divulgación | |
| Divulgación | Publicada | GHSA-8QFP-98QG-JJWV divulgada | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
Summary
qbee-io/transport TAR upload extraction can create escaping symlinks outside the destination root
Details
Affected versions and vulnerable location
Confirmed on the latest released tag:
- `v1.26.27` (also HEAD on `main`, commit `efafee959ac192f4082f2667f5c2adfd2afb8105`).
Vulnerable code (reachable on the device side during uploads):
- `file_transfer.go:422-485` (`extractTarEntries`): routes `tar.TypeSymlink` to `extractSymlink`.
- `file_transfer.go:526-542` (`extractSymlink`): creates the symlink using `os.Symlink(header.Linkname, targetPath)` and ignores the rooted cleanup failure (`_ = root.Remove(relPath)`).
Reachability trace verified
Verified call chain to the vulnerable sink on `v1.26.27`:
- `DeviceClient.handleStream` receives a message and invokes the registered handler for `MessageTypeFile`.
- `HandleFileTransfer` unmarshals `FileTransferRequest` and, for `FileTransferUpload`, calls `handleUpload(stream, req.Path)`.
- `handleUpload` builds a gzip/tar reader over the stream and calls `extractTar(tarReader, destPath)`.
- `extractTar` delegates entry handling to `extractTarEntries(tarReader, destPath, "")`.
- `extractTarEntries` routes `tar.TypeSymlink` to `extractSymlink(destPath, root, relPath, header)`.
- `extractSymlink` calls `os.Symlink(header.Linkname, targetPath)` where `targetPath` is computed as `filepath.Join(destPath, relPath)`.
Why confinement fails:
- The extraction confinement model is enforced for rooted operations (directories and regular files) by `os.OpenRoot(destPath)`.
- `extractSymlink` does not create the symlink relative to the rooted handle, so the kernel resolves symlink parent path components normally, allowing an intermediate symlink planted earlier in the archive to redirect the symlink creation location outside `destPath`.
PoC
Reproduction steps and observed output
Reproduction (executed locally by unit test, calling the same library function path):
- Create a temporary directory `parent`.
- Create:
- `destPath = parent/dest` (as a directory).
- `outsideDir = parent/outside-dir` (as a directory).
- Build an in-memory tar with `tar.TypeSymlink` entries in this order:
- `d` -> `.`
- `evil` -> `d/../outside-dir`
- `evil/boom` -> `target.txt`
- Call `extractTar(tar.NewReader(&buf), destPath)`.
- Check that `os.Readlink(parent/outside-dir/boom)` returns `target.txt`.
Observed output from running the focused residual unit test:
Go test: 1 passed in 1 packagesCommand used:
- `go test -run TestExtractTar_SymlinkParentEscape_IntermediateSymlinkComponent -v ./...` (in `.scratch/transport`).
Impact
Attacker model
- Attacker can supply an attacker-controlled TAR stream and tar headers delivered to the device-side file transfer upload handler (`HandleFileTransfer` with `FileTransferUpload`).
- Attacker can choose an absolute destination path (`FileTransferRequest.Path`), as required by the library API.
- For the escape to be visible, the attacker needs the “outside” parent directory to exist on the filesystem so that the kernel can resolve the symlink parent during `os.Symlink` location resolution.
Severity and CVSS (argued)
Severity is MEDIUM because it enables attacker-controlled filesystem mutation outside the intended extraction root, but the primitive is “escaping symlink creation” rather than a demonstrated direct file content overwrite in the same step.
Suggested CVSS v3.1 (argued): `CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:N/I:H/A:L`.
- `AV:N`: reachable via the networked file transfer upload stream.
- `AC:H`: requires a specific crafted TAR symlink sequence and a pre-existing outside parent directory layout.
- `PR:L`: attacker must be able to initiate a file transfer request into a chosen absolute destination path.
- `I:H`: attacker can plant symlinks outside `destPath`, enabling follow-on unintended file access in downstream workflows.
- `A:L`: primarily persistent filesystem side effects rather than immediate availability loss.
Suggested fix
- Create symlinks using a confinement-anchored mechanism equivalent to rooted directory and file operations.
- Concretely: in `extractSymlink`, obtain the parent directory via the rooted handle (for `filepath.Dir(relPath)`) and create the link with an openat-style syscall (for example, `symlinkat`) relative to that directory file descriptor.
- Stop ignoring rooted cleanup failures: treat `root.Remove(relPath)` errors as fatal except `IsNotExist`.
How I found it and a note on tooling
I traced the tar upload decoder path in `HandleFileTransfer -> handleUpload -> extractTar -> extractTarEntries` and focused on how `tar.TypeSymlink` entries are handled. I compared the intended rooted confinement model for directory and regular file writes against the actual syscall used for symlink creation in `extractSymlink` and then verified the residual behavior by executing a focused unit test that constructs an in-memory TAR and checks for the escaping symlink on `v1.26.27`.
AI tooling
I used AI assistance for the code audit and for drafting this report. I manually verified the finding against the project's source at the location cited above before reporting it, and the severity and impact assessment are my own.
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 |
|---|---|---|---|---|
gogo.qbee.io/transport |
Corregida | v1.26.34 | -8 d | v1.26.46 no afectada |
v1.26.34Arsenal público
Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.
https://github.com/qbee-io/transport/security/advisories/GHSA-8qfp-98qg-jjwvLas referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
