Detection rules › Elastic

Setcap setuid/setgid Capability Set

Source
github.com/elastic/protections-artifacts

This rule monitors for the addition of the cap_setuid+ep or cap_setgid+ep capabilities via setcap. Setuid (Set User ID) and setgid (Set Group ID) are Unix-like OS features that enable processes to run with elevated privileges, based on the file owner or group. Threat actors can exploit these attributes to achieve persistence by creating malicious binaries, allowing them to maintain control over a compromised system with elevated permissions.

MITRE ATT&CK coverage

Rule body

[rule]
description = """
This rule monitors for the addition of the cap_setuid+ep or cap_setgid+ep capabilities via setcap. Setuid (Set User ID)
and setgid (Set Group ID) are Unix-like OS features that enable processes to run with elevated privileges, based on the
file owner or group. Threat actors can exploit these attributes to achieve persistence by creating malicious binaries,
allowing them to maintain control over a compromised system with elevated permissions.
"""
id = "c1556f07-4184-42dc-a55c-866011a63715"
license = "Elastic License v2"
name = "Setcap setuid/setgid Capability Set"
os_list = ["linux"]
version = "1.0.2"

query = '''
process where event.type == "start" and event.action == "exec" and
process.name == "setcap" and process.command_line like "*cap_set?id+ep*" and
not (
  process.parent.name in ("jem", "vzctl") or
  process.args like "/usr/bin/new?idmap" or
  process.parent.executable like "/var/lib/dpkg/info/*.postinst" or
  process.parent.args like "/var/lib/dpkg/info/*.postinst"
)
'''

min_endpoint_version = "7.15.0"
optional_actions = []
[[actions]]
action = "kill_process"
field = "process.entity_id"
state = 0

[[actions]]
action = "kill_process"
field = "process.parent.entity_id"
state = 0

[[threat]]
framework = "MITRE ATT&CK"

[threat.tactic]
id = "TA0003"
name = "Persistence"
reference = "https://attack.mitre.org/tactics/TA0003/"
[[threat]]
framework = "MITRE ATT&CK"
[[threat.technique]]
id = "T1548"
name = "Abuse Elevation Control Mechanism"
reference = "https://attack.mitre.org/techniques/T1548/"
[[threat.technique.subtechnique]]
id = "T1548.001"
name = "Setuid and Setgid"
reference = "https://attack.mitre.org/techniques/T1548/001/"



[threat.tactic]
id = "TA0004"
name = "Privilege Escalation"
reference = "https://attack.mitre.org/tactics/TA0004/"
[[threat]]
framework = "MITRE ATT&CK"
[[threat.technique]]
id = "T1548"
name = "Abuse Elevation Control Mechanism"
reference = "https://attack.mitre.org/techniques/T1548/"
[[threat.technique.subtechnique]]
id = "T1548.001"
name = "Setuid and Setgid"
reference = "https://attack.mitre.org/techniques/T1548/001/"



[threat.tactic]
id = "TA0005"
name = "Defense Evasion"
reference = "https://attack.mitre.org/tactics/TA0005/"

[internal]
min_endpoint_version = "7.15.0"

Stages and Predicates

Stage 1: process

process where event.type == "start" and event.action == "exec" and
process.name == "setcap" and process.command_line like "*cap_set?id+ep*" and
not (
  process.parent.name in ("jem", "vzctl") or
  process.args like "/usr/bin/new?idmap" or
  process.parent.executable like "/var/lib/dpkg/info/*.postinst" or
  process.parent.args like "/var/lib/dpkg/info/*.postinst"
)

Exclusions

The rule actively suppresses these predicates.

Indicators

These rows show field, operator, and value matches.