The vulnerability lies in the decryption functionality of the excelize library, specifically when handling OLE/CFB encrypted workbooks. The root cause is a lack of robust input validation in multiple internal functions within crypt.go. As detailed in the vulnerability report, specially crafted malformed encrypted files can trigger a variety of unhandled runtime panics, including slice out-of-bounds errors, index out of range errors, and division by zero.
The analysis of the patch commit 22f76f9acb94 confirms this. The patch introduces numerous validation checks in functions like standardDecrypt, agileDecrypt, convertPasswdToKey, decrypt, decryptPackage, and createIV. These checks validate buffer lengths, key sizes, block sizes, and the existence of required XML elements before they are used in ways that could cause a panic. For example, standardDecrypt now checks len(encryptionInfoBuf) and len(encryptedPackageBuf) to prevent slice bounds panics, and createIV checks for encryptedKey.BlockSize <= 0 to avoid division by zero.
The vulnerability is not just in these low-level functions but also in the higher-level API. The public functions OpenFile, OpenReader, and OpenBytes invoke the decryption logic via the Decrypt function. Crucially, Decrypt and its callers lacked a panic recovery mechanism. Consequently, when a panic was triggered in the underlying crypto functions, it was not caught and converted into a regular error, leading to the termination of the entire calling service. An attacker could exploit this for a remote denial-of-service attack by providing a malformed file. The proposed fix mentioned in the advisory is to add a recover() boundary in Decrypt to catch these panics and return an error instead of crashing the process.