Executive brief
Tesseract is an open-source OCR (optical character recognition) engine used to extract text from images. When processing specially crafted training data files (.traineddata), the engine fails to validate array bounds, allowing attackers to write beyond allocated memory. This can crash the application or potentially corrupt heap memory, affecting the availability and integrity of any system processing untrusted OCR training data.
Technical details
The vulnerability is a heap out-of-bounds write in the Classify::ReadIntTemplates function (src/classify/intproto.cpp). When reading deserialization data from a .traineddata file's TESSDATA_INTTEMP component, the code reads three counts (NumClassPruners, NumClasses, NumProtoSets) directly from the untrusted file and uses them as loop bounds without validation against compile-time array capacity constants (MAX_NUM_CLASS_PRUNERS=1024, MAX_NUM_CLASSES=32767, MAX_NUM_PROTO_SETS=8). An attacker-supplied count larger than the fixed-size array capacity triggers pointer writes past array bounds during legacy classifier initialization, before any OCR processing occurs. The attack requires providing a maliciously crafted .traineddata file; no user interaction or authentication is needed. A patch has been committed and fixes input validation, but no formal release had been issued as of the advisory date.
Affected products
- Tesseract OCR Tesseract 5.5.3 and earlier
Timeline
- 2026-08-25: disclosed: Security advisory published
- 2026-08-25: patched: Fix committed to repository (commit 8b05746)