libxls xls_preparseWorkSheet MULBLANK Code Execution Vulnerability
An integer overflow in libxls's handling of a MULBLANK record in an XLS file causes the worksheet's last column to be set to a small value, leading to an undersized cell array allocation and an out-of-bounds write when the record is later parsed. An attacker could send a malicious XLS file to trigger memory corruption and potentially achieve remote code execution.
Originally disclosed on Cisco Talos
An exploitable integer overflow vulnerability exists in the xlspreparseWorkSheet function of libxls 1.4 when handling a MULBLANK record. A specially crafted XLS file can cause a memory corruption resulting in remote code execution.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely an integer overflow in the calculation of the last column index from the MULBLANK record's column field and record size, which wraps to a small value and causes an undersized allocation.
What the attacker needed
Victim opens a malicious XLS file
How it was found
- Craft an XLS file containing a MULBLANK record with a large column value.
- Open the file with a vulnerable application using libxls.
- The preparse function updates lastcol to an overflowed small value.
- The table allocation uses this small lastcol to allocate the cell array.
- During final parsing, the large column value is used as an index, causing an out-of-bounds write.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
When a program reads an Excel file, it calculates how many columns to allocate memory for. A malformed record can trick this calculation into producing a tiny number, so the program allocates too little memory. Later, when it tries to store data for a column that is actually very large, it writes past the end of the allocated memory, which can crash the program or let an attacker run their own code.
What is Memory corruption?
Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.