GHSA-PP2G-C3J7-J725
mv: cross-device (EXDEV) directory fallback removes then path-recreates the destination (symlink race)
CVSS:3.1/AV:L/AC:L/PR:L/UI:R/S:U/C:N/I:H/A:H
Fuente: GitHub
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Remediación | Parche 0.10.0 | uu_mv · -35 d desde divulgación | |
| Divulgación | Publicada | GHSA-PP2G-C3J7-J725 divulgada · CVSS 6.6 (GitHub) | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
`mv`'s cross-filesystem fallback for directories (`rename_dir_fallback`, `mv.rs:1028`) does `fs::remove_dir_all(to)` then recreates and populates the destination with path-based `fs::create_dir_all`/`fs::copy`. Between the removal and the recreate, an attacker with write access to the destination's parent can plant a symlink; the subsequent path-based copy follows it, writing off-tree, and the source is then deleted.
Verified (code, current HEAD): the directory fallback still uses the remove-then-path-recreate pattern. The single-file fallback (now O_NOFOLLOW `safe_copy`, `515d74b99`) and the symlink fallback (temp + `renameat`) were hardened -- the directory path was not. Relates to CVE-2026-35364 (Zellic), whose fix covered the file path only.
Impact: a privileged cross-device `mv` into an attacker-writable parent can be redirected to overwrite arbitrary files and deletes the source. Fix: apply the same fd-anchored / no-unlink-then-path-recreate approach used for the single-file and symlink paths.
---
_Source: Cantina audit (2026-05-03). Independently verified 2026-05-30 against uutils/coreutils `e0ad63471` with a sandboxed PoC; GNU coreutils 9.7 used as control. See cantina-report/VERIFICATION-2026-05-30.md._
---
Fix and measurement (2026-07-29)
Branch https://github.com/sylvestre/coreutils/tree/mv-cross-device-dir-fail-closed replaces `fs::create_dir_all` with a fail-closed `fs::create_dir` at the top-level destination and for each subdirectory, so a path that reappeared between the removal and the recreate is refused with `EEXIST` rather than followed.
This is the most easily exploited issue of the cluster — effectively deterministic, not a narrow race. The racer is a tight `symlink(victim, dest)` loop, which only succeeds while `dest` does not exist, i.e. exactly the window described above. 30 rounds of a cross-device `mv -T srcdir dest`, counting rounds where the source files landed inside an off-tree victim directory:
| build | rounds that wrote off-tree |
|---|---|
| uutils `0.9.0-575` (before) | 30/30 |
| uutils with this fix | 0/30 |
| GNU coreutils 9.10 | 0/30 |
This is a genuine GNU divergence: GNU never wrote off-tree in any round.
Also observed: pre-planted symlink destination diverges from GNU
Independent of the race, with `dest` already a symlink to a directory before `mv` starts:
$ mv -T <srcdir on tmpfs> dest # dest -> victim/
GNU 9.10 : mv: cannot overwrite non-directory 'dest' with directory 'srcdir' (exit 1, symlink intact)
uutils : exit 0 — the symlink is replaced by a real directoryNo off-tree write occurs there, so it is a compatibility divergence rather than a security issue, and this fix does not change it.
Verified not to regress
Destination-absent, `mv srcdir existingdir/`, and `-T` onto an existing empty directory all still behave as before and match GNU. 126/126 mv tests pass, plus a regression test mirroring the existing file-level `test_mv_cross_device_refuses_planted_symlink_dest` for the directory case.
Scope
The recursive copy is still path-derived (`to_dir.join(name)` per child) rather than anchored to a directory fd. This closes the destination-recreate hole without making the whole walk fd-safe; `create_dir_all_safe` in `uucore::safe_traversal` is the primitive for that follow-up.
Open PR #13334 covers the *file* and special-file destroy-before-create ordering and does not touch the directory fallback, so the two changes do not overlap.
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 |
|---|---|---|---|---|
crates.iouu_mv |
Corregida | 0.10.0 | -35 d | 0.12.0 no afectada |
0.10.0Arsenal público
Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.
https://github.com/uutils/coreutils/security/advisories/GHSA-pp2g-c3j7-j725Las referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
