/

CVE-2020-37279

Severity:

HIGH RISK

(8.1)

OS Command Injection (CWE-78) in Node easy-pdf-merge

CVE-2020-37279

Deferred

Vulnerability type

Category:

OS Command Injection

CWE:

CWE-78

Impact:

Arbitrary Command Execution

Severity:

HIGH RISK

(8.1)

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

easy-pdf-merge may allow OS command injection when shell metacharacters are included in source paths, the destination path, or the maxHeap option. If attacker-controlled values reach the package's child_process.exec() call, commands could run with the privileges of the Node.js process.

easy-pdf-merge may allow OS command injection when shell metacharacters are included in source paths, the destination path, or the maxHeap option. If attacker-controlled values reach the package's child_process.exec() call, commands could run with the privileges of the Node.js process.

Affected context

The vulnerability occurs in applications using affected easy-pdf-merge releases to construct PDF merge commands from user-controlled or insufficiently trusted values. Risk is higher when file names, output paths, or memory-related options can be influenced by external users and are passed to a shell without strict validation or safe argument handling.

The vulnerability occurs in applications using affected easy-pdf-merge releases to construct PDF merge commands from user-controlled or insufficiently trusted values. Risk is higher when file names, output paths, or memory-related options can be influenced by external users and are passed to a shell without strict validation or safe argument handling.

Exploit preconditions

  • Attack surface: Application functionality that invokes easy-pdf-merge for PDF merging
  • Required access: Ability to influence a source path, destination path, or maxHeap option
  • Trigger point: Construction and execution of the merge command
  • Why exploitation is possible: Input reaches child_process.exec(), which interprets shell metacharacters through a command shell
  • Attack surface: Application functionality that invokes easy-pdf-merge for PDF merging
  • Required access: Ability to influence a source path, destination path, or maxHeap option
  • Trigger point: Construction and execution of the merge command
  • Why exploitation is possible: Input reaches child_process.exec(), which interprets shell metacharacters through a command shell

Why this happens

The underlying bug is the use of a shell-based process execution API with values that may contain attacker-controlled file paths or options. Characters such as command separators, command substitutions, backticks, or quotation marks can alter the intended command structure instead of remaining data. This behavior maps to CWE-78: Improper Neutralization of Special Elements used in an OS Command, commonly known as OS command injection.

The underlying bug is the use of a shell-based process execution API with values that may contain attacker-controlled file paths or options. Characters such as command separators, command substitutions, backticks, or quotation marks can alter the intended command structure instead of remaining data. This behavior maps to CWE-78: Improper Neutralization of Special Elements used in an OS Command, commonly known as OS command injection.

Potential impact

  • An attacker may execute arbitrary operating-system commands
  • The Node.js process could be compromised with its runtime privileges
  • Sensitive files or environment variables could be read or modified
  • The host or container could be used for further unauthorized activity
  • Application availability or generated PDF processing could be disrupted
  • An attacker may execute arbitrary operating-system commands
  • The Node.js process could be compromised with its runtime privileges
  • Sensitive files or environment variables could be read or modified
  • The host or container could be used for further unauthorized activity
  • Application availability or generated PDF processing could be disrupted

General mitigation guidance

Mitigation generally focuses on removing shell interpretation from process execution and reducing trust in command inputs.

Common defensive patterns include:

  • Prefer non-shell process APIs that accept executable names and structured argument arrays
  • Apply strict allowlists and canonicalization to source and destination paths
  • Validate numeric options such as memory limits against bounded formats and ranges
  • Avoid building command strings through concatenation or interpolation
  • Restrict the Node.js process to a dedicated, least-privileged account or container
  • Limit filesystem access and isolate temporary PDF-processing directories
  • Treat user-supplied file names and options as data rather than executable command fragments

Mitigation generally focuses on removing shell interpretation from process execution and reducing trust in command inputs.

Common defensive patterns include:

  • Prefer non-shell process APIs that accept executable names and structured argument arrays
  • Apply strict allowlists and canonicalization to source and destination paths
  • Validate numeric options such as memory limits against bounded formats and ranges
  • Avoid building command strings through concatenation or interpolation
  • Restrict the Node.js process to a dedicated, least-privileged account or container
  • Limit filesystem access and isolate temporary PDF-processing directories
  • Treat user-supplied file names and options as data rather than executable command fragments

How teams detect issues like this

Organizations can look for this vulnerability through:

  • Static analysis rules identifying child_process.exec() or equivalent shell APIs fed by request, file, or option values
  • Code review checks for command construction using string concatenation, interpolation, or quoting as the primary defense
  • Dependency and call-graph analysis showing whether PDF-processing inputs originate outside a trusted boundary
  • Runtime monitoring for unexpected child processes, shell interpreters, or command separators in process arguments
  • Policy enforcement that restricts shell-based process execution and requires structured argument APIs

Automated security review tools may help identify these patterns during development.

Organizations can look for this vulnerability through:

  • Static analysis rules identifying child_process.exec() or equivalent shell APIs fed by request, file, or option values
  • Code review checks for command construction using string concatenation, interpolation, or quoting as the primary defense
  • Dependency and call-graph analysis showing whether PDF-processing inputs originate outside a trusted boundary
  • Runtime monitoring for unexpected child processes, shell interpreters, or command separators in process arguments
  • Policy enforcement that restricts shell-based process execution and requires structured argument APIs

Automated security review tools may help identify these patterns during development.

Sources

SourceLink
github.comgithub.com/karuppiah7890/easy-pdf-merge
github.comgithub.com/karuppiah7890/easy-pdf-merge/blob/v0.2.6/source/lib/PDFMerger.js#L71-L75
github.comgithub.com/karuppiah7890/easy-pdf-merge/pull/28
github.comgithub.com/karuppiah7890/easy-pdf-merge/pull/45
vulncheck.comvulncheck.com/advisories/easy-pdf-merge-0.1.0-through-0.2.6-os-command-injection-via-merge-function

Frequently asked

questions

It can be exploitable through an application interface if external users can influence the affected paths or options and the application processes those values with easy-pdf-merge.

The attacker generally needs the ability to supply or modify a source path, destination path, or maxHeap value that reaches the vulnerable command execution path.

Avoid shell-based command construction and invoke the underlying program through a structured argument interface with strict validation of every input.

Use allowlisted input formats, keep file-processing components least-privileged, review process-spawning code carefully, and enforce static-analysis or policy checks against unsafe shell execution.

It can be exploitable through an application interface if external users can influence the affected paths or options and the application processes those values with easy-pdf-merge.

The attacker generally needs the ability to supply or modify a source path, destination path, or maxHeap value that reaches the vulnerable command execution path.

Avoid shell-based command construction and invoke the underlying program through a structured argument interface with strict validation of every input.

Use allowlisted input formats, keep file-processing components least-privileged, review process-spawning code carefully, and enforce static-analysis or policy checks against unsafe shell execution.

Find out what's already
exploitable in your codebase.