Package: cpio
Version: 2.15+dfsg-2
Severity: normal
Tags: security upstream
X-Debbugs-Cc: [email protected]

Dear cpio maintainers and Debian Security Team,

Please triage an out-of-bounds read in GNU cpio 2.15's newc header
parser, and consider backporting the existing upstream fix.

This report covers ONLY the from_ascii() read issue, not the separate
ustar output issue mentioned in my original email of 7 November 2026.
That original report was sent to [email protected] and [email protected].
Collin Funk correctly pointed out that bug-cpio is public. Accordingly,
I am not requesting an embargo or describing this as a private report.
I am filing this here to provide proper package tracking, per Debian's
security FAQ. Please merge/redirect if an existing ticket covers it.

Affected source and root cause
-----------------------------
In GNU cpio 2.15, src/copyin.c, from_ascii() skips leading spaces with:

    for (; *buf == ' '; buf++)
      {
        if (buf == end)
          return 0;
      }

The loop condition dereferences buf before the end-of-field check.
For the final c_chksum field of the stack-allocated 110-byte newc header,
an all-spaces value causes a one-byte read beyond that header buffer.
Other fields can also be read beyond their individual field boundary.

Minimal reproducer
------------------
Generate a malformed 112-byte input in a disposable directory:

    python3 -c "from pathlib import Path; 
Path('poc.cpio').write_bytes(b'070701' + b' ' * (13 * 8) + b'x\x00')"

Then run an AddressSanitizer-instrumented GNU cpio 2.15 build:

    ASAN_OPTIONS=detect_leaks=0 /path/to/asan/cpio -it -F poc.cpio

This uses listing mode; extraction is not required. The existing report's
ASan reproduction identified a stack-buffer-overflow, READ of size 1,
in from_ascii(), called by read_in_new_ascii(), with the access just
past ascii_header. I can provide the original test artifacts on request.
A normal, non-sanitized binary is not guaranteed to crash.

Expected: reject the malformed header without reading beyond its buffer.
Observed in the prior instrumented reproduction: out-of-bounds stack read.

Impact and limitations
----------------------
This is a memory-safety violation reachable while parsing an untrusted
archive (CWE-125). The demonstrated consequence is an ASan abort.
I am NOT claiming a demonstrated attacker-visible memory leak, RCE,
privilege escalation, or a reliable crash of production builds. In
particular, downstream disclosure and availability impact need separate
validation. Severity is left conservative pending maintainer assessment.

Existing upstream fix
---------------------
The fix identified in my original investigation is upstream commit
bf16382, dated 2025-05-29, subject "Fix invalid memory access". It bounds
leading-space scanning before dereferencing buf. Please verify the full
commit and applicability to Debian's current source before backporting.

The original investigation reported Debian 2.15+dfsg-2 and
2.15+dfsg-2.1 without this fix; that is a prior assessment, not a fresh
claim about every currently shipped distribution or package revision.
I am not asserting that I originally discovered the upstream bug: the
upstream fix predates my independent reproduction on 7 November 2026.

Requested action
----------------
Please confirm the issue and affected Debian versions, track/backport the
upstream fix as appropriate, and advise whether an existing CVE covers
this root cause or whether CVE coordination is warranted. I do not want
a duplicate CVE request or to presume CVE eligibility from an ASan trace.

Credit for this report/reproduction, if applicable:
JailBr3ak (Nawaf Al-Thurwi), [email protected]

Thank you,
Nawaf Al-Thurwi (JailBr3ak)

Reply via email to