https://sourceware.org/bugzilla/show_bug.cgi?id=35005
Bug ID: 35005
Summary: eu-unstrip -d writes files outside the output
directory (path traversal via crafted core file)
Product: elfutils
Version: unspecified
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: general
Assignee: unassigned at sourceware dot org
Reporter: adikvelix at gmail dot com
CC: elfutils-devel at sourceware dot org
Target Milestone: ---
Created attachment 17281
--> https://sourceware.org/bugzilla/attachment.cgi?id=17281&action=edit
Proposed fix: sanitize_module_path() patch (git format-patch on top of master
ff9e30d) with regression test tests/run-unstrip-dir-traversal.sh
Component: elfutils, src/unstrip.c, function handle_output_dir_module().
When eu-unstrip processes a core file with -a -d OUT (without -m), the output
path is built as OUT + "/" + file, where file is the module's main file name
taken from the core's link_map l_name — untrusted data read from the core file.
".." components and a leading "/" survive verbatim, so the write escapes the
output directory. This contradicts the documented guarantee that modules are
written to files under OUTPUT-DIRECTORY.
Affected: 0.197 (released 2026-10-19), git master ff9e30d3 (2026-11-05), 0.196,
0.192, and every release that has -d (present already in 0.131). Commit 4f5b7ac
basenamed the module name for the -m branch only; the default branch is
unchanged and still escapes.
Impact: the file written is the ELF libdwfl opened at the attacker-chosen read
path, accepted when its build-id matches the build-id stored in the core's
memory image — both are attacker-controlled in a crafted core. The write
truncates the target file and preserves its owner and mode. Demonstrated in the
lab, 3/3 identical runs: a root-owned 0700 executable replaced by the
attacker's ELF (owner/mode preserved, later executed as root), and a
26,936-byte root binary truncated to the payload's 15,112 bytes so it dies with
SIGSEGV. The full evidence, configuration matrix, honest constraints, and chain
logs are in the attached EVIDENCE-v2.md; the self-contained reproducer is
repro.sh with core-base.core, payload.so and patchcore.py attached.
CVSS 3.1: AV:L/AC:H/PR:N/UI:R/S:U/C:N/I:H/A:H = 6.3 (Medium). AC:H because the
attacker must know or guess the tool's CWD and the output directory depth; if
the panel reads single-file destruction as A:L the score is 5.3.
Fix: the attached unstrip-sanitize-path.patch (git format-patch on top of
master ff9e30d) adds sanitize_module_path() so the module file name loses
leading slashes and every "." or ".." component before it is appended to the
output directory, plus a regression test (tests/run-unstrip-dir-traversal.sh).
Verified: git apply --check clean on pristine master; regression test PASSes on
patched builds and FAILs on the unpatched master build; repro.sh on the patched
build leaves the victim file untouched in 3/3 runs.
--
You are receiving this mail because:
You are on the CC list for the bug.