Elastic Defend high stable eql

Suspicious Ruby Command Execution

This rule monitors for suspicious Ruby command executions by detecting the start of a Ruby process with a command line argument that contains keywords commonly used by attackers to execute malicious code. These command line arguments include operations to execute code, create subprocesses, and encode or decode data.

View Source

Detection Logic

process where event.type == "start" and event.action == "exec" and process.parent.executable != null and
process.executable like~ ("/bin/ruby*", "/usr/bin/ruby*", "/usr/local/bin/ruby*") and
process.args like "-e*" and process.command_line like~ (
  "*system(*", "*exec(*", "*IO.popen(*", "*Open3.popen3(*", "*spawn(*", "*eval(*", "*load(*",
  "*Marshal.load(*", "*Fiddle.dlopen(*", "*Fiddle::Function.new(*", "*base64*", "*zlib*", 
  "*net/http*", "*socket*", "*open-uri*", "*pack(*", "*unpack(*"
) and
not (
  process.working_directory like~ ("/etc/puppet/rack", "/builds/*", "/var/tmp/portage/*") or
  process.command_line like ("*rails_env*", "*pid*Process.spawn*ssh*StrictHostKeyChecking*ServerAliveInterval*ServerAliveCountMax*", "*security-agent.webpros.host*") or
  process.command_line == "ruby -e require \"yaml\"; YAML.safe_load(File.read(\".gitlab-ci.yml\"), aliases: true)" or
  process.parent.args like "/home/*/.vscode-server/cli/servers/Stable-*" or
  process.parent.command_line in ("emacs --daemon", "runc init") or
  process.parent.name in ("emacs-gtk", "mmonit", "make") or
  (process.name == "ruby" and process.parent.name == "ruby") or
  process.parent.executable in ("/opt/gitlab/embedded/bin/gitaly", "/usr/bin/runc") or
  process.parent.executable like "/home/*/bin/claude*"
)

Field Validations

Loading…

Comments (0)

Loading comments...