#1153724 catdoc: xls2csv global-buffer-overflow write in SetFormatIdxUsed (plus an OOB read in format_rk)

Package:
catdoc
Source:
catdoc
Description:
text extractor for MS-Office files
Submitter:
zwf zwf
Date:
2026-11-11 14:21:02 UTC
Severity:
normal
Tags:
#1153724#5
Date:
2026-11-11 10:32:26 UTC
From:
To:
Hello,

xls2csv in catdoc 0.95 crashes on crafted .xls input in two independent places, and one of
them is an out-of-bounds **write**. Both reproduce against the current Debian source (0.95
plus the 11 patches in debian/patches, i.e. what bookworm, trixie and sid ship) built with
ASan, and both are fixed by the patch attached.

1. Global buffer overflow write in SetFormatIdxUsed(), src/xlsparse.c:621

    static char FormatIdxUsed[NUMOFDATEFORMATS]; /* NUMOFDATEFORMATS == 12, index 0..11 */
    ...
    dateindex = BuiltInDateFormatIdx(format_code); /* 0x2D..0x2F returns 10..12 */
    if (dateindex) FormatIdxUsed[dateindex] = 1; /* index 12 is one past the end */

A FORMAT record (0x041E) whose format_code is 0x2F makes BuiltInDateFormatIdx() return 12,
and the guard only tests for non-zero, so the write lands one byte past the array. ASan:

    WRITE of size 1 at 0x... (global-buffer-overflow)
      #0 SetFormatIdxUsed src/xlsparse.c:621
      #1 process_item src/xlsparse.c:169
      #2 do_table src/xlsparse.c:119

Note line 592 of the same file already uses `dateindex <= NUMOFDATEFORMATS` for the read
side, so the boundary is known to be off by one in both places.

2. Global buffer overflow read in format_rk(), src/xlsparse.c:729

    case RK:
        ...
        format_code = getshort(rec,4);
        *pcell = strdup(format_rk(rec+6, format_code)); /* reads 8 bytes from rec+6 */

The RK record needs at least 10 bytes; reclen is never checked, so a short RK record makes
format_rk() read past the global record buffer. The MULRK branch has the same problem, there
`format_rk(rec+offset+2, ...)` is called without checking offset against reclen. ASan:

    global-buffer-overflow READ
      #0 format_rk src/xlsparse.c:729
      #1 process_item src/xlsparse.c:329
      #2 do_table src/xlsparse.c:119

Reproduction: `xls2csv poc-idx.xls` and `xls2csv poc-rk.xls` (attached), both abort under
ASan, both return cleanly with the patch applied. 20 ordinary .xls files from the test data
parse identically before and after the patch.

The patch (attached, against 0.95 with the Debian patches applied) adds the missing bounds
checks:

    case RK: if (reclen < 10) break;
    case MULRK: if (offset + 10 > (int) reclen) break;
    SetFormatIdxUsed: if (dateindex > 0 && dateindex < NUMOFDATEFORMATS)

Two further crashes turned up in the same run that look like plain NULL dereferences and are
lower value, mentioned only for completeness:

- `read_charset()` is called with the result of `charset_from_codepage()` without a NULL
  check (src/xlsparse.c:162 -> src/charsets.c:79 -> stradd() -> strlen(NULL))
- `calcFileBlockOffset()` dereferences a NULL pointer for a truncated property chain
  (src/ole.c:544 via ole_read():587)

There is no upstream release after 0.95 (2011), so Debian is effectively the maintainer
here; catdoc already has 10 CVEs, most recently CVE-2026-111126/CVE-2026-111127 for
out-of-bounds reads in this same file, which is why a CVE seems worth requesting for the
write in (1).

Thanks,
netwind
zwfnetwind@hotmail.com

#1153724#10
Date:
2026-11-11 14:19:02 UTC
From:
To:
Follow-up for #1153724 (and its duplicate #1153726, merged separately via control@).

Two points, both about whether this is worth a CVE from Debian's side.

1. It is a write, not a read

The primary defect is a global-buffer-overflow *write* in SetFormatIdxUsed()
(src/xlsparse.c:621): FormatIdxUsed[] has NUMOFDATEFORMATS == 12 elements, and
BuiltInDateFormatIdx() returns 10..12 for format_code 0x2D..0x2F, so a FORMAT record with
format_code 0x2F writes one byte past the array. The existing guard is `if (dateindex)`,
i.e. only a non-zero test.

2. It is a different code path from the catdoc CVEs already on record

    CVE-2024-52035 / CVE-2024-54028 OLE FAT / DIFAT integer overflow and underflow
    CVE-2026-111126 xls2csv MULRK record handler, out-of-bounds read
    CVE-2026-111127 copy_unicode_string(), out-of-bounds read

None of those cover SetFormatIdxUsed(), and none cover the RK record path in format_rk()
(item 2 of the original report). Both defects were found by fuzzing 0.95 *plus the current
debian/patches* (0.95-6), so they are present in what bookworm, trixie and sid ship today,
not merely in the 2011 tarball.

If Debian would rather handle this as a straight security upload, the patch attached to the
original report is three hunks in src/xlsparse.c and applies to 0.95-6 unmodified; I am
happy to re-roll it against whatever tree you prefer. If a CVE is warranted, please consider
requesting one for the write in item 1 at least.

netwind