Shell or Suspicious Process Spawned by Ray Worker
Description
Detects a Ray worker (ray/_private/workers/default_worker.py) spawning a shell, an inline Python
command (python -c / python3 -c), or a discovery or download utility. Ray runs job entrypoints from
that worker through a shell, so a Python reverse shell shows up as sh -c or bash -c whose command
line contains python -c and the program it starts, such as /bin/sh -i. On an exposed cluster this is
exploitation of the public-facing Ray jobs API (CVE-2023-48022). Ray commonly hosts LLM
training, fine-tuning, and serving, so this can be an attack on that infrastructure: theft of model
weights, datasets, or API and cloud tokens, tampering with a served model, or use of the GPUs for
cryptomining.
Query · esql
FROM logs-endpoint.events.process-* METADATA _id, _version, _index
| WHERE KQL("""event.category:process and event.type:start""")
AND TO_LOWER(process.parent.name) LIKE "python*"
AND (
TO_LOWER(process.parent.command_line) LIKE """*\\ray\\_private\\workers\\default_worker.py*"""
OR TO_LOWER(process.parent.command_line) LIKE "*/ray/_private/workers/default_worker.py*"
)
AND (
TO_LOWER(process.name) IN (
"cmd.exe", "powershell.exe", "pwsh.exe",
"bash", "bash.exe", "sh", "zsh", "dash",
"curl", "curl.exe", "wget", "wget.exe",
"whoami", "whoami.exe", "id", "uname", "hostname", "hostname.exe"
)
// Direct python -c child of the worker.
OR (
TO_LOWER(process.name) LIKE "python*"
AND MV_CONTAINS(process.args, "-c")
)
)
| KEEP
_id,
_version,
_index,
data_stream.namespace,
@timestamp,
host.name,
host.id,
host.os.type,
agent.id,
user.name,
user.domain,
process.name,
process.executable,
process.command_line,
process.args,
process.parent.name,
process.parent.executable,
process.parent.command_line,
process.parent.entity_id
Investigation fields
Pivot points the source recommends for triage.
host.nameuser.nameprocess.parent.nameprocess.parent.executableprocess.parent.command_lineprocess.nameprocess.executableprocess.command_line
Implementation guide
This rule is designed for data generated by Elastic Defend, which provides native endpoint detection and response, along with event enrichments designed to work with our detection rules.
Setup instructions: https://ela.st/install-elastic-defend
Analyst notes
Investigating Shell or Suspicious Process Spawned by Ray Worker
A Python process running ray/_private/workers/default_worker.py started cmd, PowerShell, a Unix shell,
inline python -c / python3 -c, curl, wget, whoami, id, uname, or hostname. Ray's job
supervisor is that worker. It runs the entrypoint with a shell, so the direct child is usually sh -c or
cmd.exe /c and the entrypoint text is on that command line. A python3 -c reverse shell that then runs
/bin/sh -i is visible on that shell command line. The python3 -c process and the interactive /bin/sh
are children of the shell, not of the worker, so they are separate events.
Possible investigation steps
- Review
process.command_linefor the entrypoint. Downloaders,whoami,id, encoded commands, and reverse shells are higher priority than a known training or serving command. - Confirm
process.parent.command_linecontainsray/_private/workers/default_worker.py. - On the same host, review the child and grandchild processes and any outbound connections from that tree.
- Check whether the Ray dashboard (port 8265 by default) is reachable from outside the cluster, and who submitted the job. The submitter is not the parent process.
- Ask the workload owner whether this entrypoint is an approved Ray job.
False positive analysis
- Approved Ray jobs start their entrypoint from this same worker, usually through
cmd.exe /con Windows orsh -con Linux. Expect this rule on clusters that run jobs. - Tune with the entrypoint command line, the Ray working directory, the host, or the user. Do not exclude
pythonordefault_worker.pybroadly, or the worker respawn noise returns and the entrypoint shell is missed.
Response and remediation
- If the entrypoint is not an approved job, stop the child process and isolate the host if it made outbound connections or read credentials.
- Remove unapproved files dropped by the job and rotate credentials present in the Ray environment.
- Stop exposing the dashboard. Bind it to a trusted interface and require authentication in front of it.