Elastic Defend high stable eql

Suspicious Shell Command Execution via Node.js Parent

This rule detects when a shell command is executed as a child process of a Node.js process. Attackers may use Node.js to run shell commands for various malicious purposes, such as downloading and executing payloads, establishing persistence, or exfiltrating data.

View Source

Detection Logic

process where event.type == "start" and event.action == "exec" and
process.parent.executable in ("/bin/node", "/usr/bin/node", "/usr/local/bin/node") and
process.name in ("bash", "dash", "sh", "tcsh", "csh", "zsh", "ksh", "fish") and process.args == "-c" and (
  (process.command_line like "*echo *" and process.command_line like (
    "*./.*", "*http://*", "*https://*", "*/dev/tcp*", "*/dev/udp/*", "*import*pty*spawn*",
    "*import*subprocess*call*", "*TCPSocket.new*", "*TCPSocket.open*", "*io.popen*", "*os.execute*",
    "*fsockopen*", "*disown*", "*wget*", "*curl*"
    )
  ) or
  (
    process.command_line like (
      "*/etc/cron*", "*/etc/rc.local*", "*/dev/tcp/*", "*/etc/init.d*", "*/etc/update-motd.d*",
      "*/etc/ld.so*", "*/etc/sudoers*", "*base64 *", "*base32 *", "*base16 *", "*/etc/profile.d/*",
      "*/dev/shm/*", "*/etc/ssh*", "*/home/*/.ssh/*", "*/root/.ssh*" , "*~/.ssh/*", "*autostart*",
      "*xxd *", "*/etc/shadow*", "*/var/tmp/*"
    )
  ) or
  (process.command_line regex~ """.*http?://[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.*""")
) and 
not (
  process.executable like "/tmp/newroot/*" or
  process.command_line like (
    "*169.254.169.254*", "*localhost*", "*127.0.0.1*", "*SNAPSHOT_FILE=*", "*/tmp/claude-shell-snapshot*",
    "/home/*/.openclaw/*", "/api.notion.com/*", "/shubble.git/*"
  ) or
  process.args like ("-l SNAPSHOT_FILE*", "-l source*", "NODE_TLS_REJECT_UNAUTHORIZED=0*", "*.claude/*", "ssh-keyscan*", "supergateway --sse*") or
  (
    process.command_line like "/bin/sh -c rm -rf /dev/shm/streams/*" and
    process.parent.args == "/usr/local/lib/node_modules/pm2/lib/ProcessContainerFork.js"
  ) or
  process.parent.args like ("/home/*/openclaw/*", "openclaw-gateway", "/opt/cursor-agent/node", "/usr/lib/node_modules/openclaw/dist/index.js", "/usr/local/bin/gemini") or
  process.parent.command_line like ("*@playwright/cli*", "*playwright-cli*") or
  process.command_line in (
    """/bin/sh -c echo BROWSER=none > .env && echo DEMO=true >> .env && echo PORT=3000 >> .env && printf "PUBLIC_URL=http://$(hostname -I
| awk '{print $1}'):3000/\n" >> .env && echo WDS_SOCKET_PORT=3000 >> .env && printf "WDS_SOCKET_HOST=$(hostname -I
| awk '{print $1}')\n" >> .env && echo JSX_IMPORT_SOURCE=@ac/library-utils/dist/web-components/wc-jsx >> .env""",
    "/bin/sh -c chmod +x /etc/init.d/pm2-docker-deployer", """/bin/sh -c grep "^#[ ]*Port[ ]*[0-9]*" /etc/ssh/sshd_config 2>/dev/null"""
  ) or
  (process.command_line like "*shubblecompose-app*" and process.parent.command_line == "node -r dotenv/config dist/server.mjs")
)

Field Validations

Loading…

Comments (0)

Loading comments...