/

CVE-2026-26831

Severity:

CRITICAL RISK

(9.8)

OS Command Injection in textract Extractors

CVE-2026-26831

Analyzed

Vulnerability type

Category:

OS Command Injection

CWE:

CWE-78, CWE-94

Impact:

Remote Code Execution

Severity:

CRITICAL RISK

(9.8)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

textract versions through 2.5.0 contain an OS command injection flaw where user-controlled file paths are passed directly into shell execution.

An attacker who can influence the filename or file path being processed may execute arbitrary system commands with the privileges of the textract process.

Affected context

This vulnerability affects applications that use textract (through version 2.5.0) to process documents, images, or other files where filenames or file paths can be influenced by external input.

The issue resides in multiple extractors (e.g., DOC, RTF, DXF, images) and utility code that call child_process.exec() with file paths derived from incoming data.

Risk is elevated in web services, APIs, or batch processors that accept user-supplied uploads or paths without robust normalization and validation.

Exploit preconditions

  • Attack surface: Any interface that ultimately passes a filename or file path into textract for processing (web upload endpoints, CLI wrappers, message queue workers, etc.).
  • Required access: Ability to supply or control the name/location of a file that textract is asked to extract text from.
  • Trigger point: Invocation of affected extractors (e.g., DOC, RTF, DXF, images) where the filePath parameter is constructed from untrusted input.
  • Why exploitation is possible: The filePath string is interpolated directly into shell commands via child_process.exec() with inadequate sanitization, allowing shell metacharacters and command sequences to be interpreted and executed by the OS.

Why this happens

The underlying bug is an instance of OS command injection, aligned with CWE-94 where dynamically constructed commands are built from untrusted data.

Instead of treating the file path purely as data passed to an argument-safe API, the code composes command strings that embed the path directly and executes them via child_process.exec(), which invokes a shell.

Because there is insufficient validation, escaping, or use of safer process-spawning primitives, an attacker can inject additional shell syntax into the path, causing unintended commands to run.

This reflects the insecure pattern of mixing user-controlled input with executable command strings without strictly constraining or separating data from code.

Potential impact

  • Execution of arbitrary OS commands with the privileges of the textract-running service or user account
  • Full compromise of the host running textract, including installation of malware or backdoors
  • Unauthorized access, modification, or exfiltration of application and system data
  • Pivoting to other internal services or infrastructure reachable from the compromised host
  • Interference with normal service operation, including denial-of-service and data corruption

General mitigation guidance

Effective mitigation focuses on eliminating command construction from untrusted data and tightening trust boundaries around file handling:

  • Prefer process-spawning APIs that do not invoke a shell (e.g., spawn/execFile-style calls with argument arrays) so that paths are treated strictly as data.
  • Avoid building shell command strings from file paths; if shell utilities are unavoidable, constrain inputs to a minimal, validated character set and avoid shell metacharacters entirely.
  • Apply strong input validation and normalization for all filenames and paths before they reach textract, rejecting or sanitizing unexpected patterns such as embedded shell operators, newlines, or control characters.
  • Isolate document-processing components with least-privilege OS accounts, constrained filesystem permissions, and sandboxing or containerization to reduce blast radius if a flaw is present.
  • Design upload and processing workflows so that external users never control raw command fragments or environment details, and treat all file-related input as untrusted by default.

How teams detect issues like this

Organizations can identify and monitor this class of issue using:

  • Static analysis rules that flag uses of child_process.exec() and similar shell-invoking APIs where arguments are derived from request parameters, upload paths, or other untrusted sources.
  • Code review practices that highlight any dynamic command-string construction, especially in utility modules and file-processing pipelines, and require explicit justification or refactoring to safer patterns.
  • Security linters or SAST tools configured to recognize OS command injection patterns (e.g., concatenation or template literals combining user input with shell commands).
  • Runtime logging and monitoring for anomalous command executions originating from textract-related services, including unexpected binaries, network tooling, or atypical arguments.

Sources

SourceLink
github.comgithub.com/dbashford/textract
github.comgithub.com/dbashford/textract/blob/master/lib/extractors/doc.js
github.comgithub.com/dbashford/textract/blob/master/lib/extractors/rtf.js
github.comgithub.com/dbashford/textract/blob/master/lib/util.js
github.comgithub.com/zebbernCVE/CVE-2026-26831
npmjs.comnpmjs.com/package/textract

Frequently asked

questions

It can be remotely exploitable when textract is used in networked services that accept user-supplied files or paths; an attacker need only reach the interface that triggers textract processing with a crafted filename.

The attacker typically needs the ability to supply or influence the file path passed to textract, such as uploading a file with a malicious name or controlling a path parameter in an API or job configuration.

The safest approach is to remove shell-based command construction entirely for file paths and use APIs that pass arguments as arrays to subprocesses, combined with strict validation of acceptable path formats.

Establish development guidelines that forbid constructing shell commands from untrusted data, require safer process APIs by default, enforce security-focused code review of any command execution logic, and incorporate static analysis rules that detect command injection patterns early in the development lifecycle.

Find out what's already
exploitable in your codebase.