Get a Demo
Under Attack?
A pink background with concentric circles features a white bug icon in a circle and text below reading Critical RCE Vulnerability in jsonpath-plus (CVE-2024-21534). The word upwind appears in the top right corner.

Critical RCE Vulnerability in jsonpath-plus (CVE-2024-21534)

Moshe Hassan October 17, 2024

A critical Remote Code Execution (RCE) vulnerability identified as CVE-2024-21534 has been discovered in versions of the jsonpath-plus package before 10.0.0. This vulnerability allows attackers to execute arbitrary code on affected systems by exploiting improper input sanitization and the unsafe default usage of the vm module in Node.js. jsonpath-plus is a JavaScript implementation of JSONPath with additional operators, widely used for querying and manipulating JSON data in Node.js applications. Unfortunately, versions prior to 10.0.0 are vulnerable due to improper input handling, which can be exploited to execute malicious code.

Vulnerability Details

The vulnerability arises from the unsafe default usage of the Node.js vm module within jsonpath-plus. Specifically, the package fails to properly sanitize user inputs, allowing attackers to inject and execute arbitrary code on the server.

Even after the release of version 10.0.0, which mitigated the vulnerability by changing the default behavior, the unsafe functionality remains available but is no longer enabled by default. This means systems that have not updated or have re-enabled the unsafe behavior are still at risk.

Proof of Concept (PoC)

An attacker can craft a malicious JSONPath expression that includes arbitrary JavaScript code. When this expression is evaluated by jsonpath-plus, the injected code executes on the server. Here’s how the exploitation process works:

  1. Malicious Input Crafting: The attacker creates a JSONPath expression that embeds JavaScript code intended to perform unauthorized actions, such as reading sensitive files or executing system commands.
  2. Injection Point: The malicious JSONPath is supplied to an application endpoint that utilizes jsonpath-plus to process user-provided queries on JSON data.
  3. Code Execution: The application evaluates the expression using the vm module without proper sanitization. This leads to the execution of the attacker’s code on the server.

When this code is run (node index.js), it executes the cat /etc/passwd command, displaying the contents of the /etc/passwd file. This demonstrates how an attacker could execute arbitrary system commands.

// index.js
const { JSONPath } = require("jsonpath-plus");
const data = {};
const maliciousCode = 'require("child_process").exec("cat /etc/passwd")';
const maliciousPath = `$[(this.constructor.constructor("${maliciousCode}")())]`;

const result = JSONPath({
    json: data,
    path: maliciousPath
});

Impact

  • Unauthorized Access: Attackers can gain unauthorized access to your system.
  • Data Breach: Sensitive information could be exposed or stolen.
  • System Compromise: Full system compromise leading to service disruptions or further attacks.

To protect your system from this critical vulnerability, it is essential to:

  1. Update the jsonpath-plus Package: Upgrade to version 10.0.0 or later where the default behavior has been changed to be safer.
  2. Audit Your Codebase: Check for any custom configurations that might re-enable the unsafe functionality and adjust them accordingly.
  3. Sanitize Inputs: Always ensure that user inputs are properly sanitized to prevent injection attacks.

How Upwind Helps Protect You From the jsonpath-plus Vulnerability

Upwind Cloud Security Platform provides comprehensive protection and vulnerability management, offering tools to identify and mitigate risks from this vulnerability:

  • SBOM Explorer: Use Upwind’s SBOM Explorer to locate all instances of jsonpath-plus in your environment and check which versions are affected by this vulnerability.
  • Vulnerable Resource Detection: Identify all resources in your environment running vulnerable versions of jsonpath-plus, and assess which clusters, VMs, and resources are exposed to this vulnerability.
  • Risk Context: Understand the potential impact of this vulnerability on your system, particularly in environments with sensitive data, internet exposure, or communication with critical services.
  • Prioritize Fixes: Upwind helps you prioritize patching or updating vulnerable resources, streamlining the process to secure your environment against this RCE vulnerability.
jsonpath-plus-sidepane--1024x601

Get Further Help from Upwind

Upwind’s expert security team also provides 24/7 managed detection and response services, giving you real-time support for CVE-2024-21534 and all critical vulnerability findings. For additional help finding vulnerable packages, identifying the scope of resource usage with the CVE, understanding their risk context and prioritizing package upgrades contact the Upwind MDR team at [email protected] or schedule a demo.

Contents

Further Reading

Yuval_ArgoCD Research

ArgoCD repoURL XSS: How a Missing Scheme Check Becomes Cluster Takeover 

Executive Summary  This stored cross-site scripting (XSS) vulnerability in ArgoCD [versions <= 3.4.4] allows an attacker who can create or modify an Application to persist a malicious repoURL, which is subsequently executed in an administrator's browser within the Argo CD origin. Because the payload executes in the context of the administrator's authenticated session, and because…
Custom-Reporting-Hero

Security Reporting Built Around Your Program

We've all been there: it's 3:00 PM on a Friday, and you get that "quick" request for a specific security status report. Suddenly, your afternoon is gone as you juggle filters, export CSVs, and try to explain to someone outside the security team why these numbers actually matter. Reporting shouldn't feel like a fire drill…
Blue-agent-blog

Introducing the Upwind Blue Agent: Autonomous Threat Investigation for the SOC

We’re excited to announce that the Upwind Blue Agent is now available in Beta. Blue is an AI-powered SOC investigator that autonomously investigates Upwind Threat Stories end to end. It gathers and correlates security context across the customer environment, evaluates the available evidence, and delivers one of three clear verdicts: Each verdict includes supporting reasoning…
Add the Upwind RSS Feed to Slack
Connect the Upwind RSS Feed to your Slack.
Follow the how-to here.
Threat RSS
Add the Upwind RSS Feed to Slack
Connect the Upwind RSS Feed to your Slack.
Follow the how-to here.
Main RSS