Summary
ExcelJS contains a path traversal vulnerability in the Workbook.addImage() function because supplied file paths are not adequately validated. An attacker who can influence the image path may cause the Node.js process to read arbitrary files accessible to its account and embed their contents in a generated workbook.
Affected context
The issue occurs in applications that use ExcelJS to create workbooks and call Workbook.addImage() with file paths influenced by external or insufficiently trusted input. Risk depends on the Node.js process having access to sensitive files and on the resulting workbook being returned, stored, or otherwise exposed to the attacker.
Exploit preconditions
- Attack surface: Application functionality that generates Excel workbooks with ExcelJS images
- Required access: Ability to influence an image path directly or through application-controlled data
- Trigger point: Invocation of
Workbook.addImage()during workbook generation - Why exploitation is possible: The supplied path is not sufficiently constrained to an approved directory or validated against traversal sequences, allowing file reads outside the intended image location
Why this happens
The vulnerability results from accepting a file path as an image source without enforcing a trusted path boundary. When externally influenced path data is passed to file-reading logic, traversal components or absolute paths can redirect access to unintended files. This maps to CWE-73: External Control of File Name or Path, where attacker-controlled path information influences filesystem operations.
Potential impact
- Sensitive local files may be read by the Node.js process
- File contents may be embedded in generated workbooks
- Credentials, configuration data, or source code may be disclosed
- Exposed files may enable follow-on compromise or privilege escalation
General mitigation guidance
Mitigation generally focuses on reducing trust in file path inputs and enforcing a controlled filesystem boundary.
Common defensive patterns include:
- Accepting approved image identifiers or opaque asset references instead of arbitrary paths
- Resolving paths against a fixed, dedicated asset directory and verifying that the result remains within that directory
- Rejecting absolute paths, traversal components, symbolic-link escapes, and unexpected file types
- Applying strict allowlists for permitted files and image formats
- Running the Node.js process with the minimum filesystem permissions required
- Avoiding inclusion of generated workbooks or embedded assets in responses unless access has been authorized
How teams detect issues like this
Organizations can detect this class of issue through:
- Static analysis rules for filesystem APIs that consume request-derived or configuration-derived paths
- Code review checks for path concatenation, missing canonicalization, and absent directory-boundary validation
- Tests using traversal markers, absolute paths, symbolic links, and encoded path variants
- Runtime monitoring for unexpected reads outside designated asset directories
- Policy enforcement requiring approved asset abstractions and least-privilege filesystem access
Automated security review tools may help identify untrusted data flows into workbook image or file-reading APIs.

