GHSA-54X6-C4C8-44FR
`install` fd-based copy path creates the destination `0666` and without `O_EXCL`
CVSS:3.1/AV:L/AC:L/PR:L/UI:R/S:U/C:H/I:N/A:N
Fuente: GitHub
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Divulgación | Publicada | GHSA-54X6-C4C8-44FR divulgada · CVSS 5 (GitHub) | |
| Remediación | Parche 0.12.0 | coreutils · 0 d desde divulgación | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
Hi, @sylvestre
`install` has two copy implementations that are documented as equivalent. The path-based one is deliberately hardened:
let mut dest = OpenOptions::new()
.write(true)
.create_new(true) // O_EXCL
.mode(0o600) // no exposure window
.open(to)?;The fd-based one — reached by `install -D SRC DST`, the form used pervasively by packaging Makefiles, it protection is strictly weaker:
// src/uu/install/src/install.rs:966-968 — copy_file_safe()
let mut src = File::open(from)?;
let mut dst = to_parent_fd.open_file_at(to_filename)?;
copy_fast(&mut src, &mut dst)?;// src/uucore/src/lib/features/safe_traversal.rs:465-472 — open_file_at()
let flags = OFlag::O_CREAT | OFlag::O_WRONLY | OFlag::O_TRUNC
| OFlag::O_CLOEXEC | OFlag::O_NOFOLLOW;
let mode = Mode::from_bits_truncate(0o666); // Default file permissionsTwo distinct weaknesses follow.
(a) Permission-exposure window. `install -m 600 secret.key /etc/…` creates the file with mode `0666 and ~umask` (typically `0644`), writes the secret content into it, and only afterwards chmods it to `0600`. Any local user can read the secret during the copy. This is exactly the defect `uucore::safe_copy` was written to prevent:
> `DEST_INITIAL_MODE` = `0o600` — "ensures no other user can open the file during the copy, see issue #10011"
Also The fd-based path bypasses that module entirely.
(b) Hard-link planting race. The caller unlinks the target and then opens with `O_CREAT|O_TRUNC`:
// src/uu/install/src/install.rs:791-800
if let Err(e) = parent_fd.unlink_at(filename.as_os_str(), false) ...
copy_file_safe(source, parent_fd, filename.as_os_str())?;`O_NOFOLLOW` blocks symlinks but does not block hard links. An attacker with write access to the target directory can plant a hard link to a victim file in that window. `install` running as root then truncates and overwrites the victim file, and F-04 below proceeds to `chown`/`chmod` it to the requested owner and mode. `create_new(true)` in the sibling function closes precisely this hole by failing if the name exists.
the impact is Disclosure of secrets installed with restrictive modes to the attacker-writable target directory, arbitrary file overwrite plus the attacker chosen ownership and mode that leads by example to local privilege escalation when `install -D` is run as root common in `make install` and packaging.
To fix that:
- Add an `O_EXCL` variant of `DirFd::open_file_at()` and a create mode of `0o600`, matching `safe_copy::DEST_INITIAL_MODE`.
- Or route the impl trought `copy_file_safe()` through `safe_copy::create_dest_restrictive()` so both paths share one implementation. That is the duplication noted in the code comment at the following location `install.rs:947-950` is the root cause of the vuln.
Desglose de métricas
Rangos afectados
Estado del parche por paquete
| Paquete / producto | Estado | Corregida en | Desde divulgación | Última versión |
|---|---|---|---|---|
crates.iocoreutils |
Corregida | 0.12.0 | 0 d | 0.12.0 no afectada |
0.12.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-54x6-c4c8-44frLas referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
