Detection rules › Elastic
Setcap setuid/setgid Capability Set
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
| Tactic | Techniques |
|---|---|
| Privilege Escalation |
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.
| Field | Kind | Excluded values | Search |
|---|---|---|---|
process.args | eq | /usr/bin/new?idmap | excludes:process.args field:"process.args" value:"/usr/bin/new?idmap" |
process.parent.args | wildcard | /var/lib/dpkg/info/*.postinst | excludes:process.parent.args field:"process.parent.args" value:"/var/lib/dpkg/info/*.postinst" |
process.parent.executable | wildcard | /var/lib/dpkg/info/*.postinst | excludes:process.parent.executable field:"process.parent.executable" value:"/var/lib/dpkg/info/*.postinst" |
process.parent.name | in | jem, vzctl | excludes:process.parent.name field:"process.parent.name" value:"jem" field:"process.parent.name" value:"vzctl" |
Indicators
These rows show field, operator, and value matches.
| Field | Kind | Values | Search |
|---|---|---|---|
event.action | eq |
| field:"EventType" kind:eq value:"exec" |
event.type | eq |
| field:"event.type" kind:eq value:"start" |
process.command_line | wildcard |
| field:"CommandLine" kind:wildcard value:"*cap_set?id+ep*" |
process.name | eq |
| field:"process_name" kind:eq value:"setcap" |