CVE-2025-31672: Apache POI OOXML Vulnerable to Improper Input Validation in OOXML File Parsing
5.3
CVSS Score
3.1
Basic Information
CVE ID
GHSA ID
EPSS Score
0.20268%
CWE
Published
4/9/2025
Updated
4/18/2025
KEV Status
No
Technology
Java
Technical Details
CVSS Vector
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:N
Package Name | Ecosystem | Vulnerable Versions | First Patched Version |
---|---|---|---|
org.apache.poi:poi-ooxml | maven | < 5.4.0 | 5.4.0 |
Vulnerability Intelligence
Miggo AI
Root Cause Analysis
The vulnerability lies in the improper validation of OOXML files, which are essentially zip archives. Malicious users can craft files with duplicate zip entry names. The fix involves adding checks to detect and throw an exception when such duplicate entries are found.
ZipInputStreamZipEntrySource.ZipInputStreamZipEntrySource
: This constructor is directly involved in reading zip entries. The patch explicitly adds logic to track filenames and throw anInvalidZipException
if a duplicate is encountered. This is a primary vulnerable function that was fixed.ZipSecureFile.validateEntryNames
: This method already contained logic to detect duplicate names. The patch makes minor changes (making variables final). While not the direct fix, it's a key function involved in the validation process. The vulnerability existed because this check might not have been called or its results handled correctly in all scenarios prior to the patch.OPCPackage.open
(multiple overloads): These methods are high-level entry points for opening and parsing OOXML packages. The patches modify them to catch the newly introducedInvalidZipException
(originating from lower-level zip processing) and rethrow it as anInvalidFormatException
. This shows that these methods previously did not handle the duplicate entry scenario correctly and would proceed with parsing, leading to the vulnerability.PackageHelper.open
: This is another utility method for opening packages. It callsOPCPackage.open
and its exception handling was updated in relation to theInvalidFormatException
that can now be caused by duplicate entries.
The test cases added in TestXSSFWorkbook.java
(e.g., testDuplicateFileReadAsOPCFile
, testDuplicateFileReadAsFile
, testDuplicateFileReadAsStream
) confirm that opening a specially crafted file (duplicate-file.xlsx
) now results in exceptions (InvalidFormatException
or InvalidZipException
), whereas previously it would have been processed, demonstrating the fix for the vulnerability in the XSSFWorkbook
constructor and underlying OPCPackage.open
calls.