node-tesseract-ocr shell injection (CVE-2026-26832)
CVE-2026-26832
node-tesseract-ocr is an npm package that provides a Node.js wrapper for Tesseract OCR. In all versions through 2.2.1, the recognize() function in src/index.js is vulnerable to OS Command Injection. T...
Overview
A critical security vulnerability, tracked as CVE-2026-26832, has been discovered in the node-tesseract-ocr npm package. This package is a popular Node.js wrapper for the Tesseract optical character recognition (OCR) engine. The flaw allows attackers to execute arbitrary operating system commands on the host server, posing a severe risk to any application using this library.
Vulnerability Details
The vulnerability resides in the recognize() function within the package’s src/index.js file. This function constructs a shell command to process image files for text extraction. However, the user-supplied file path parameter is directly concatenated into the command string without any sanitization and is then executed using child_process.exec(). This lack of input validation makes it susceptible to OS command injection.
An attacker can exploit this by crafting a malicious file path parameter that includes shell metacharacters (like ;, &, |, or backticks) to break out of the intended command and execute their own code on the underlying system.
Impact
With a maximum CVSS score of 9.8 (Critical), this vulnerability has a severe impact. Successful exploitation grants an attacker the ability to run any command with the same privileges as the Node.js process. This could lead to:
- Complete compromise of the application server.
- Unauthorized access to sensitive data and file systems.
- Installation of malware or ransomware.
- Use of the server as a pivot point for attacks on internal networks.
For context on how such vulnerabilities can lead to major incidents, review historical data breach reports at breach reports.
Remediation and Mitigation
Immediate action is required to secure affected systems.
Primary Fix: Update the Package
The recommended solution is to upgrade node-tesseract-ocr to version 2.2.2 or later, if a patched version is available. Update the package in your package.json and run npm update.
Immediate Mitigation (If Update is Not Possible):
- Input Sanitization: Strictly validate and sanitize all user input passed to the
recognize()function. Reject any paths containing shell metacharacters or path traversal sequences (../). - Use Safer Alternatives: Consider refactoring the code to use the
child_process.execFile()orchild_process.spawn()functions with argument arrays, which do not invoke a system shell by default. - Principle of Least Privilege: Ensure the Node.js process runs with the minimum necessary system permissions to limit the potential damage of a successful exploit.
Stay informed on emerging threats and patches by monitoring our security news section. Organizations using this package should audit their applications and apply the patch without delay to prevent potential exploitation.
Never miss a critical vulnerability
Get real-time security alerts delivered to your preferred platform.
Related Advisories
A improper neutralization of special elements used in an os command ('os command injection') vulnerability in Fortinet FortiSandbox 4.4.0 through 4.4.8 may allow attacker to execute unauthorized code ...
Anthropic Claude Code CLI and Claude Agent SDK contain an OS command injection vulnerability in authentication helper execution where helper configuration values are executed using shell=true without ...
PraisonAI is a multi-agent teams system. From version 4.5.15 to before version 4.5.69, the --mcp CLI argument is passed directly to shlex.split() and forwarded through the call chain to anyio.open_pro...
Improper neutralization of special elements used in an os command ('os command injection') in Microsoft Bing Images allows an unauthorized attacker to execute code over a network....