Description
An integer underflow vulnerability exists in osslsigncode version 2.12 and earlier in the PE page-hash computation code (pe_page_hash_calc()). When page hash processing is performed on a PE file, the function subtracts hdrsize from pagesize without first validating that pagesize >= hdrsize. If a malicious PE file sets SizeOfHeaders (hdrsize) larger than SectionAlignment (pagesize), the subtraction underflows and produces a very large unsigned length.
The code allocates a zero-filled buffer of pagesize bytes and then attempts to hash pagesize - hdrsize bytes from that buffer. After the underflow, this results in an out-of-bounds read from the heap and can crash the process.
The same code area also contained insufficient bounds checking around page-hash size calculations, which was addressed in the 2.13 fix. However, the primary issue described here is the underflow-driven out-of-bounds read.
The vulnerability can be triggered while signing a malicious PE file with page hashing enabled (-ph), or while verifying a malicious signed PE file that already contains page hashes. Verification of an already signed file does not require the verifier to pass -ph.
Impact
- Denial of Service: Application crash during PE page-hash processing
Based on the affected code path, this report should not claim confirmed integrity impact or confirmed information disclosure. The demonstrated effect is an out-of-bounds read that can terminate the process; stronger impact claims would require additional exploitation evidence.
Notes
A proof-of-concept trigger is reported to exist. The upstream 2.13 release groups this issue with other PE page-hash memory corruption fixes.
Fixed in version 2.13: https://github.com/mtrojnar/osslsigncode/releases/tag/2.13
Description
An integer underflow vulnerability exists in osslsigncode version 2.12 and earlier in the PE page-hash computation code (
pe_page_hash_calc()). When page hash processing is performed on a PE file, the function subtractshdrsizefrompagesizewithout first validating thatpagesize >= hdrsize. If a malicious PE file setsSizeOfHeaders(hdrsize) larger thanSectionAlignment(pagesize), the subtraction underflows and produces a very large unsigned length.The code allocates a zero-filled buffer of
pagesizebytes and then attempts to hashpagesize - hdrsizebytes from that buffer. After the underflow, this results in an out-of-bounds read from the heap and can crash the process.The same code area also contained insufficient bounds checking around page-hash size calculations, which was addressed in the 2.13 fix. However, the primary issue described here is the underflow-driven out-of-bounds read.
The vulnerability can be triggered while signing a malicious PE file with page hashing enabled (
-ph), or while verifying a malicious signed PE file that already contains page hashes. Verification of an already signed file does not require the verifier to pass-ph.Impact
Based on the affected code path, this report should not claim confirmed integrity impact or confirmed information disclosure. The demonstrated effect is an out-of-bounds read that can terminate the process; stronger impact claims would require additional exploitation evidence.
Notes
A proof-of-concept trigger is reported to exist. The upstream 2.13 release groups this issue with other PE page-hash memory corruption fixes.
Fixed in version 2.13: https://github.com/mtrojnar/osslsigncode/releases/tag/2.13