Netcat Remote Code Execution in Container


Description

Netcat Program runs inside container that allows remote code execution and may be utilized as a part of a variety of reverse shell payload https://github.com/swisskyrepo/PayloadsAllTheThings/. These programs are of higher relevance as they are commonly installed on UNIX-like operating systems. Can fire in combination with the "Redirect STDOUT/STDIN to Network Connection in Container" rule as it utilizes a different evt.type.

Query · falco

spawned_process and container and ((proc.name = "nc" and (proc.cmdline contains " -e" or
                            proc.cmdline contains " -c")) or
     (proc.name = "ncat" and (proc.args contains "--sh-exec" or
                              proc.args contains "--exec" or proc.args contains "-e " or
                              proc.args contains "-c " or proc.args contains "--lua-exec"))
     )

Rule dependencies

Depends on

  • composes · Falco macro container
    A shared condition, not a detection — not indexed on this site.
  • composes · Falco macro spawned_process
    A shared condition, not a detection — not indexed on this site.

Analyst notes

Netcat runs inside container that allows remote code execution | evt_type=%evt.type user=%user.name user_uid=%user.uid user_loginuid=%user.loginuid process=%proc.name proc_exepath=%proc.exepath parent=%proc.pname command=%proc.cmdline terminal=%proc.tty exe_flags=%evt.arg.flags

Raw source Netcat Remote Code Execution in Container · Falco YAML
Esc
Published by falcosecurity/rules ↗, licensed under Apache 2.0 ↗. Reproduced here unmodified.
rule: Netcat Remote Code Execution in Container
desc: 'Netcat Program runs inside container that allows remote code execution and
  may be utilized as a part of a variety of reverse shell payload https://github.com/swisskyrepo/PayloadsAllTheThings/.
  These programs are of higher relevance as they are commonly installed on UNIX-like
  operating systems. Can fire in combination with the "Redirect STDOUT/STDIN to Network
  Connection in Container" rule as it utilizes a different evt.type.

  '
condition: "spawned_process and container and ((proc.name = \"nc\" and (proc.cmdline\
  \ contains \" -e\" or\n                            proc.cmdline contains \" -c\"\
  )) or\n     (proc.name = \"ncat\" and (proc.args contains \"--sh-exec\" or\n   \
  \                           proc.args contains \"--exec\" or proc.args contains\
  \ \"-e \" or\n                              proc.args contains \"-c \" or proc.args\
  \ contains \"--lua-exec\"))\n     )\n"
output: Netcat runs inside container that allows remote code execution | evt_type=%evt.type
  user=%user.name user_uid=%user.uid user_loginuid=%user.loginuid process=%proc.name
  proc_exepath=%proc.exepath parent=%proc.pname command=%proc.cmdline terminal=%proc.tty
  exe_flags=%evt.arg.flags
priority: WARNING
tags:
- maturity_stable
- container
- network
- process
- mitre_execution
- T1059

Detection rules belong to the projects that publish them and remain under their own licenses. This site indexes and links to them; it claims no rights in them.