Summary
buildebooks before 0.2.2 contains an OS command injection vulnerability in its Kindle conversion workflow. When Kindle generation is enabled, a crafted EPUB filename, front-matter filename, or project folder name may be incorporated into a command executed with the privileges of the buildebooks process.
buildebooks before 0.2.2 contains an OS command injection vulnerability in its Kindle conversion workflow. When Kindle generation is enabled, a crafted EPUB filename, front-matter filename, or project folder name may be incorporated into a command executed with the privileges of the buildebooks process.
Affected context
The vulnerability occurs in the Kindle generation path implemented in lib/kindle.js, where project- or book-derived names are passed to the kindlegen utility through a shell command. Risk depends on an attacker being able to create or influence a book project, its metadata, or its containing directory while Kindle generation is enabled.
The vulnerability occurs in the Kindle generation path implemented in lib/kindle.js, where project- or book-derived names are passed to the kindlegen utility through a shell command. Risk depends on an attacker being able to create or influence a book project, its metadata, or its containing directory while Kindle generation is enabled.
Exploit preconditions
- Attack surface: The buildebooks Kindle conversion workflow and its use of
child_process.exec - Required access: Ability to supply or modify a book project, EPUB-related metadata, or the project directory name
- Trigger point: Processing a project with
kindle: true - Why exploitation is possible: Attacker-controlled naming data is incorporated into a shell command without sufficient separation from command syntax
- Attack surface: The buildebooks Kindle conversion workflow and its use of
child_process.exec - Required access: Ability to supply or modify a book project, EPUB-related metadata, or the project directory name
- Trigger point: Processing a project with
kindle: true - Why exploitation is possible: Attacker-controlled naming data is incorporated into a shell command without sufficient separation from command syntax
Why this happens
The underlying bug is command construction from untrusted filename or path components followed by execution through a shell-enabled process API. This behavior maps to CWE-78: Improper Neutralization of Special Elements used in an OS Command, because data intended as an argument can be interpreted as command syntax. The insecure pattern is passing externally influenced values to child_process.exec without robust argument handling, context-aware validation, or shell avoidance.
The underlying bug is command construction from untrusted filename or path components followed by execution through a shell-enabled process API. This behavior maps to CWE-78: Improper Neutralization of Special Elements used in an OS Command, because data intended as an argument can be interpreted as command syntax. The insecure pattern is passing externally influenced values to child_process.exec without robust argument handling, context-aware validation, or shell avoidance.
Potential impact
- An attacker may execute arbitrary operating-system commands as the user running buildebooks
- Local files, credentials, or build artifacts could be accessed or modified
- The build environment could be used to tamper with generated books or downstream packages
- Compromise could spread to other systems if the process has excessive permissions or access
- An attacker may execute arbitrary operating-system commands as the user running buildebooks
- Local files, credentials, or build artifacts could be accessed or modified
- The build environment could be used to tamper with generated books or downstream packages
- Compromise could spread to other systems if the process has excessive permissions or access
General mitigation guidance
Mitigation generally focuses on eliminating shell interpretation and reducing trust in project-controlled names.
Common defensive patterns include:
- Prefer process-spawning APIs that pass executable arguments separately and do not invoke a shell
- Apply strict, allowlisted validation to filenames, directory names, and metadata used by build commands
- Treat project content and front matter as untrusted input even when supplied by internal workflows
- Run conversion tasks with a dedicated low-privilege account, restricted filesystem access, and limited network permissions
- Use isolated build environments and avoid exposing secrets to document-conversion processes
- Preserve safe-by-default behavior when optional Kindle conversion is not explicitly required
Mitigation generally focuses on eliminating shell interpretation and reducing trust in project-controlled names.
Common defensive patterns include:
- Prefer process-spawning APIs that pass executable arguments separately and do not invoke a shell
- Apply strict, allowlisted validation to filenames, directory names, and metadata used by build commands
- Treat project content and front matter as untrusted input even when supplied by internal workflows
- Run conversion tasks with a dedicated low-privilege account, restricted filesystem access, and limited network permissions
- Use isolated build environments and avoid exposing secrets to document-conversion processes
- Preserve safe-by-default behavior when optional Kindle conversion is not explicitly required
How teams detect issues like this
Detection can include static analysis for child_process.exec or similar shell APIs receiving filename, path, metadata, or project-derived values. Code reviews should examine command construction, string concatenation, quoting assumptions, and whether a non-shell process API can be used instead.
Build policies may flag shell execution in document-processing code, require allowlisted path handling, and test representative untrusted names in isolated environments. Automated code review and software composition analysis tools can help identify these patterns, but findings should be validated against the actual execution path.
Detection can include static analysis for child_process.exec or similar shell APIs receiving filename, path, metadata, or project-derived values. Code reviews should examine command construction, string concatenation, quoting assumptions, and whether a non-shell process API can be used instead.
Build policies may flag shell execution in document-processing code, require allowlisted path handling, and test representative untrusted names in isolated environments. Automated code review and software composition analysis tools can help identify these patterns, but findings should be validated against the actual execution path.

