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

behind-the-curtain-part-02

What’s Behind the Curtain? AWS Bedrock AgentCore Runtime Tear Down – Part II

Recap In Part I, we explored the AgentCore Runtime microVM from the inside and discovered we weren't alone - four platform binaries were running alongside our code, and one of them was quietly shipping logs to an AWS-internal S3 bucket. We left off with a question: what can we learn from these internal components, and…
behind-the-curtain-part-01

What’s Behind the Curtain? AWS Bedrock AgentCore Runtime Tear Down – Part I

Introduction When you deploy an AI agent to AWS Bedrock AgentCore Runtime, your code runs inside a Firecracker microVM - but it doesn't run alone. In this three-part series, we tear down the platform internals, document what we found, and assess how well the isolation holds up. Setting the Stage AWS Bedrock AgentCore Runtime is…
upwind-code

Upwind Code Expands Enterprise Coverage to Azure DevOps and Bitbucket Cloud

Modern development organizations rarely keep all their code in one place. Teams may use different version control platforms because of acquisitions, business-unit preferences, regional requirements, or existing development workflows. But when code is spread across multiple providers, application security coverage can become fragmented too. Today, Upwind Code adds support for Azure DevOps and Bitbucket Cloud.…
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