GHSA-C24X-H627-MPRH
sort writes its temporary files with the umask, so other local users can read the data being sorted
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-C24X-H627-MPRH divulgada · CVSS 5 (GitHub) | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
Summary
When its input does not fit in memory, `sort` writes sorted chunks to temporary files under `TMPDIR`, by default `/tmp`, and merges them at the end. uutils creates the temporary directory with `create_dir` and each chunk with `File::create`, so both get the process umask: 0755 and 0644 under the usual 022. Every local user can read the chunks, which are the input in sorted pieces, for as long as the sort runs, and afterwards if the run is interrupted. GNU coreutils creates each temporary file with `mkstemp`, mode 0600, and the contents are private to the user.
Details
`src/uu/sort/src/tmp_dir.rs:116-118` creates the directory:
tempfile::Builder::new()
.prefix("uutils_sort")
.tempdir_in(&self.parent_path)`tempfile`'s directory builder uses the default `create_dir` mode unless `.permissions()` is given, so the directory is 0777 masked by the umask. Each chunk is then opened at `tmp_dir.rs:149`:
File::create(&path).map_err(|error| SortError::OpenTmpFileFailed { error })?,which is 0666 masked by the umask. Neither call restricts the mode. With `--compress-program` the chunk file is handed to the program as its stdout, so the same mode applies to compressed chunks.
GNU's `sort.c` opens temporaries through `mkostemp`, which creates them 0600 regardless of the umask, directly in `TMPDIR`.
Suggested fix. Give the directory `.permissions(Permissions::from_mode(0o700))` in the builder, and open chunks with `OpenOptions::new().write(true).create_new(true).mode(0o600)`. A 0700 directory alone already closes the exposure; restricting the files as well protects a directory whose mode is later relaxed.
PoC
Verified on 0.11.0, source `bf65901e1ed82963436844c2cf8e796ba9158c65` (2026-08-30), the current release; first observed on 0.9.0 (`f66e155d8`, 2026-07-27) with identical output. Ubuntu 24.04.2 LTS, Linux 6.8.0 x86_64. Console output captured with `LANG=C`, `sort` resolving to uutils. `TMPDIR` is set to a scratch directory only to keep the listing short; the default is `/tmp`. `-S 64K` makes a modest input spill; without it any input larger than the buffer, a few hundred megabytes by default, behaves the same. Sort's output is sent into a pipe that nobody reads, so it stops part way through the merge and its temporary files stay in place for as long as `sleep` runs; with `> out` instead they exist for about a second on this machine and the listing has to be taken while sort is still running.
$ cd "$(mktemp -d)" ; mkdir tmp ; export TMPDIR=$PWD/tmp ; umask 022
$ seq 1 2000000 | shuf > big
$ sort -S 64K big | sleep 30 &
$ sleep 2 ; find tmp -mindepth 1 | head -3 | xargs stat -c "%A %U %s %n"
drwxr-xr-x user 4096 tmp/uutils_sortWL2FaP
-rw-r--r-- user 73728 tmp/uutils_sortWL2FaP/131
-rw-r--r-- user 73724 tmp/uutils_sortWL2FaP/186
$ head -c 40 tmp/uutils_sort*/8 | od -c | head -2
0000000 1 0 0 0 0 0 6 \n 1 0 0 0 0 5 7 \n
0000020 1 0 0 0 1 3 \n 1 0 0 0 4 4 8 \n 1The chunk is the input, sorted. Any other account on the machine can run that `head` while the sort is in progress. The exposure also outlives the run: when `sleep` ends, sort is killed by SIGPIPE and the directory with its 202 chunk files is left behind, still world-readable, where GNU sort removes its files from its signal handler.
$ kill %1 ; sleep 1 ; find tmp -mindepth 1 -type f | wc -l
202GNU coreutils 9.11, same commands:
$ sleep 2 ; find tmp -mindepth 1 | head -3 | xargs stat -c "%A %U %s %n"
-rw------- user 2891 tmp/sort6Y4BRN
-rw------- user 3612 tmp/sorta2xuxC
-rw------- user 3613 tmp/sortubRV75
$ kill %1 ; sleep 1 ; find tmp -mindepth 1 | wc -l
0Impact
`sort` is routinely run over data that is private to its owner: log files, exports of user tables, password or token lists being deduplicated, anything piped through `sort | uniq`. On a multi-user host with the default `/tmp`, uutils copies that data into world-readable files for the duration of the sort. Nothing in the input, the command or the output changes, so the owner has no sign of it, and the files are gone when the sort finishes, so an audit afterwards finds nothing.
The window is the run time of the sort, which for an input large enough to spill is seconds to hours, and the reader needs only to list `/tmp` at the right moment. If the sort is interrupted, or fails as in the companion report, the directory stays with the same modes until something removes it.
The umask does not help in the usual case, since 022 is the default almost everywhere; only a user who runs with 077 is protected, and a process that inherits a permissive umask from a service manager is not.
In short, the temporary copy of a sort's input is created with the umask rather than mode 0600, allowing any local user to read it while the sort runs, and potential local information disclosure of whatever private data is being sorted.
My Acknowledgement Information
Hongkai Chen of SEFCOM Lab at Arizona State University
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_sort |
Sin parche | — | — | — |
Arsenal 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-c24x-h627-mprhLas referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
