Package: catdoc Version: 1:0.95-6 Severity: normal Tags: security, upstream
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
[email protected]
poc-idx.xls
Description: poc-idx.xls
poc-rk.xls
Description: poc-rk.xls
fix-catdoc-xls.patch
Description: fix-catdoc-xls.patch

