
Advisory for textract ⌯⌲ 15 000 weekly downloads
textract through version 2.5.0 allows OS command injection through
the file path supplied to multiple extractors. Several code paths pass
that file path into child_process.exec() with inadequate sanitization.
An attacker who can influence the file name or path can break out of
the command line and run arbitrary commands on the host.
| Product | Affected versions | Fixed version |
|---|---|---|
| textract | all versions through 2.5.0 | no fix available as of 2026-03-24 |
CVE-2026-26831CWE-78 - OS Command Injection9.8 (Critical)CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:Hlib/extractors/doc.jslib/extractors/rtf.jslib/extractors/dxf.jslib/extractors/images.jslib/util.jsOne example is the doc.js extractor:
exec('antiword -m UTF-8.txt "' + filePath + '"', ...)
Another is the rtf.js path handling, which only escapes spaces
before executing the shell command. That does not stop metacharacters
such as ;, backticks, or $().
Applications often use textract on user-uploaded documents. In that
setup, a malicious file name can trigger command execution during text
extraction.
An input file name such as:
test";whoami;".doc
can break out of the quoted command string when the vulnerable extractor runs.
No fixed npm release is available at the time of writing.
If you still depend on this package:
textract.exec() with argument-safe process execution.