Skip to content

Commit 5d69eb1

Browse files
AegrahSamirbous
andauthored
[New Rules] Potential CVE-2025-32463 Exploitation (#5169)
* [New Rules] Potential CVE-2025-32463 Exploitation * Update chroot rule logic * Added IGs * Update rules/linux/privilege_escalation_cve_2025_32463_nsswitch_file_creation.toml * Update rules/linux/privilege_escalation_cve_2025_32463_nsswitch_file_creation.toml Co-authored-by: Samirbous <[email protected]> --------- Co-authored-by: Samirbous <[email protected]>
1 parent b474a81 commit 5d69eb1

File tree

2 files changed

+248
-0
lines changed

2 files changed

+248
-0
lines changed
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
[metadata]
2+
creation_date = "2025/10/01"
3+
integration = ["endpoint", "auditd_manager", "sentinel_one_cloud_funnel", "crowdstrike"]
4+
maturity = "production"
5+
updated_date = "2025/10/01"
6+
7+
[rule]
8+
author = ["Elastic"]
9+
description = """
10+
Detects suspicious creation of the nsswitch.conf file, outside of the regular /etc/nsswitch.conf path,
11+
consistent with attempts to exploit CVE-2025-32463 (the "sudo chroot" privilege escalation), where an
12+
attacker tricks sudo into using attacker-controlled NSS files or libraries to gain root.
13+
"""
14+
from = "now-9m"
15+
index = [
16+
"logs-endpoint.events.file*",
17+
"logs-sentinel_one_cloud_funnel.*",
18+
"endgame-*",
19+
"auditbeat-*",
20+
"logs-auditd_manager.auditd-*",
21+
"logs-crowdstrike.fdr*",
22+
]
23+
language = "eql"
24+
license = "Elastic License v2"
25+
name = "Potential CVE-2025-32463 Nsswitch File Creation"
26+
note = """
27+
## Triage and analysis
28+
29+
> **Disclaimer**:
30+
> This investigation guide was created using generative AI technology and has been reviewed to improve its accuracy and relevance. While every effort has been made to ensure its quality, we recommend validating the content and adapting it to suit your specific environment and operational needs.
31+
32+
### Investigating Potential CVE-2025-32463 Nsswitch File Creation
33+
34+
This rule flags creation of an nsswitch.conf file outside the standard /etc location by a shell, an early sign of staging a fake root to coerce sudo's chroot path and hijack NSS resolution (CVE-2025-32463). A common pattern is writing /tmp/chroot/etc/nsswitch.conf, placing or pointing to a malicious NSS module, then running sudo chroot into that directory so name lookups load attacker-controlled code and escalate to root.
35+
36+
### Possible investigation steps
37+
38+
- Correlate the event with any sudo or chroot executions within ±10 minutes that reference the same directory prefix (e.g., /tmp/chroot), capturing full command line, user, TTY, working directory, and exit codes.
39+
- Inspect the created nsswitch.conf for nonstandard services or module names and enumerate any libnss_*.so* under lib*/ or usr/lib*/ within that prefix, recording owner, hashes, and timestamps.
40+
- List all contemporaneous file writes under the same prefix (etc, lib*, bin, sbin) to determine whether a chroot rootfs is being assembled and attribute it to a toolchain such as tar, rsync, debootstrap, or custom scripts via process ancestry.
41+
- Search file access telemetry to see whether privileged processes subsequently read that specific nsswitch.conf or loaded libnss_* from the same path, which would indicate the chroot was exercised.
42+
- Verify sudo and glibc versions and patch status for CVE-2025-32463 and collect the initiating user’s session context (SSH source, TTY, shell history) to assess exploitability and scope.
43+
44+
### False positive analysis
45+
46+
- An administrator legitimately staging a temporary chroot or test root filesystem may use a shell to create /tmp/*/etc/nsswitch.conf while populating configs, matching the rule even though no privilege escalation is intended.
47+
- OS installation, recovery, or backup-restore workflows run from a shell can populate a mounted target like /mnt/newroot/etc/nsswitch.conf, creating the file outside /etc as part of maintenance and triggering the alert.
48+
49+
### Response and remediation
50+
51+
- Terminate any sudo or chroot processes referencing the created path (e.g., /tmp/chroot/etc/nsswitch.conf), lock the initiating user’s sudo access, and quarantine the parent directory with root-only permissions.
52+
- Remove the staged nsswitch.conf and any libnss_*.so* or ld.so.* artifacts under lib*/ or usr/lib*/ within that prefix after collecting copies, hashes, and timestamps for evidence.
53+
- Restore and verify /etc/nsswitch.conf on the host with correct content and root:root 0644, purge temporary chroot roots under /tmp, /var/tmp, or /mnt, and restart nscd or systemd-resolved to flush cached name-service data.
54+
- Escalate to incident response if sudo chroot was executed against the same directory, if root processes loaded libnss_* from that path, or if nsswitch.conf appears outside /etc on multiple hosts within a short window.
55+
- Apply vendor fixes for CVE-2025-32463 to sudo and glibc, disallow chroot in sudoers and enforce env_reset, noexec, and secure_path, and mount /tmp and /var/tmp with noexec,nosuid,nodev to prevent libraries being sourced from user-writable paths.
56+
- Add controls to block execution from user-created chroot trees by policy (AppArmor or SELinux) and create alerts on creation of */etc/nsswitch.conf or libnss_* writes under non-system paths, with auto-isolation for directories under /tmp or a user’s home.
57+
"""
58+
references = [
59+
"https://www.stratascale.com/vulnerability-alert-CVE-2025-32463-sudo-chroot",
60+
"https://github.com/kh4sh3i/CVE-2025-32463",
61+
]
62+
risk_score = 73
63+
rule_id = "163a8f2f-c8a0-4b7e-9c4a-1184310eb7f3"
64+
setup = """## Setup
65+
66+
This rule requires data coming in from Elastic Defend.
67+
68+
### Elastic Defend Integration Setup
69+
Elastic Defend is integrated into the Elastic Agent using Fleet. Upon configuration, the integration allows the Elastic Agent to monitor events on your host and send data to the Elastic Security app.
70+
71+
#### Prerequisite Requirements:
72+
- Fleet is required for Elastic Defend.
73+
- To configure Fleet Server refer to the [documentation](https://www.elastic.co/guide/en/fleet/current/fleet-server.html).
74+
75+
#### The following steps should be executed in order to add the Elastic Defend integration on a Linux System:
76+
- Go to the Kibana home page and click "Add integrations".
77+
- In the query bar, search for "Elastic Defend" and select the integration to see more details about it.
78+
- Click "Add Elastic Defend".
79+
- Configure the integration name and optionally add a description.
80+
- Select the type of environment you want to protect, either "Traditional Endpoints" or "Cloud Workloads".
81+
- Select a configuration preset. Each preset comes with different default settings for Elastic Agent, you can further customize these later by configuring the Elastic Defend integration policy. [Helper guide](https://www.elastic.co/guide/en/security/current/configure-endpoint-integration-policy.html).
82+
- We suggest selecting "Complete EDR (Endpoint Detection and Response)" as a configuration setting, that provides "All events; all preventions"
83+
- Enter a name for the agent policy in "New agent policy name". If other agent policies already exist, you can click the "Existing hosts" tab and select an existing policy instead.
84+
For more details on Elastic Agent configuration settings, refer to the [helper guide](https://www.elastic.co/guide/en/fleet/8.10/agent-policy.html).
85+
- Click "Save and Continue".
86+
- To complete the integration, select "Add Elastic Agent to your hosts" and continue to the next section to install the Elastic Agent on your hosts.
87+
For more details on Elastic Defend refer to the [helper guide](https://www.elastic.co/guide/en/security/current/install-endpoint.html).
88+
"""
89+
severity = "high"
90+
tags = [
91+
"Domain: Endpoint",
92+
"OS: Linux",
93+
"Use Case: Threat Detection",
94+
"Tactic: Privilege Escalation",
95+
"Data Source: Elastic Defend",
96+
"Data Source: SentinelOne",
97+
"Data Source: Crowdstrike",
98+
"Data Source: Elastic Endgame",
99+
"Data Source: Auditd Manager",
100+
"Use Case: Vulnerability",
101+
"Resources: Investigation Guide",
102+
]
103+
timestamp_override = "event.ingested"
104+
type = "eql"
105+
query = '''
106+
file where host.os.type == "linux" and event.type == "creation" and file.path like "/*/etc/nsswitch.conf" and
107+
process.name in ("bash", "dash", "sh", "tcsh", "csh", "zsh", "ksh", "fish") and
108+
not (
109+
process.name == "dash" and file.path like ("/var/tmp/mkinitramfs_*", "/tmp/tmp.*/mkinitramfs_*")
110+
)
111+
'''
112+
113+
[[rule.threat]]
114+
framework = "MITRE ATT&CK"
115+
116+
[[rule.threat.technique]]
117+
id = "T1068"
118+
name = "Exploitation for Privilege Escalation"
119+
reference = "https://attack.mitre.org/techniques/T1068/"
120+
121+
[rule.threat.tactic]
122+
id = "TA0004"
123+
name = "Privilege Escalation"
124+
reference = "https://attack.mitre.org/tactics/TA0004/"
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
[metadata]
2+
creation_date = "2025/10/01"
3+
integration = ["endpoint", "auditd_manager", "sentinel_one_cloud_funnel", "crowdstrike"]
4+
maturity = "production"
5+
updated_date = "2025/10/01"
6+
7+
[rule]
8+
author = ["Elastic"]
9+
description = """
10+
Detects suspicious use of sudo's --chroot / -R option consistent with attempts to exploit CVE-2025-32463
11+
(the "sudo chroot" privilege escalation), where an attacker tricks sudo into using attacker-controlled
12+
NSS files or libraries to gain root.
13+
"""
14+
from = "now-9m"
15+
index = [
16+
"logs-endpoint.events.process*",
17+
"logs-sentinel_one_cloud_funnel.*",
18+
"endgame-*",
19+
"auditbeat-*",
20+
"logs-auditd_manager.auditd-*",
21+
"logs-crowdstrike.fdr*",
22+
]
23+
language = "eql"
24+
license = "Elastic License v2"
25+
name = "Potential CVE-2025-32463 Sudo Chroot Execution Attempt"
26+
note = """
27+
## Triage and analysis
28+
29+
> **Disclaimer**:
30+
> This investigation guide was created using generative AI technology and has been reviewed to improve its accuracy and relevance. While every effort has been made to ensure its quality, we recommend validating the content and adapting it to suit your specific environment and operational needs.
31+
32+
### Investigating Potential CVE-2025-32463 Sudo Chroot Execution Attempt
33+
34+
This rule highlights sudo invoked with the chroot (-R/--chroot) option outside normal administration, a behavior tied to CVE-2025-32463 where attackers force sudo to load attacker-controlled NSS configs or libraries and escalate to root. An attacker pattern: running sudo -R /tmp/fakechroot /bin/sh after seeding that directory with malicious nsswitch.conf and libnss to obtain a root shell. Treat unexpected chrooted sudo on Linux hosts as high-risk privilege escalation activity.
35+
36+
### Possible investigation steps
37+
38+
- Extract the chroot target path from the event and enumerate its etc and lib directories for attacker-seeded NSS artifacts (nsswitch.conf, libnss_*, ld.so.preload) and fake passwd/group files, noting recent mtime, ownership, and world-writable files.
39+
- Pivot to file-creation and modification telemetry to identify processes and users that populated that path shortly before execution (e.g., curl, wget, tar, git, gcc), linking them to the invoking user to establish intent.
40+
- Review session and process details to see if a shell or interpreter was launched inside the chroot and whether an euid transition to 0 occurred, indicating a successful privilege escalation.
41+
- Confirm sudo’s package version and build options and the user’s sudoers policy (secure_path/env_* settings and any NOPASSWD allowances) to assess exploitability and whether chroot usage was authorized.
42+
- Collect and preserve the chroot directory contents and relevant audit/log artifacts, and scope by searching for similar chroot invocations or NSS file seeds across the host and fleet.
43+
44+
### False positive analysis
45+
46+
- A legitimate offline maintenance session where an administrator chroots into a mounted system under /mnt or /srv using sudo --chroot to run package or initramfs commands, which will trigger when the invoked program is not in the whitelist.
47+
- An image-building or OS bootstrap workflow that stages a root filesystem and uses sudo -R to execute a shell or build/configuration scripts inside the chroot, producing the same pattern from a known user or host context.
48+
49+
### Response and remediation
50+
51+
- Immediately isolate the affected host from the network, revoke the invoking user’s sudo privileges, and terminate any chrooted shells or child processes spawned via “sudo -R <path> /bin/sh” or similar executions.
52+
- Preserve evidence and then remove attacker-seeded NSS and loader artifacts within the chroot path—delete or replace nsswitch.conf, libnss_*.so, ld.so.preload, passwd, and group files, and clean up world-writable staging directories like /tmp/fakechroot.
53+
- Upgrade sudo to a fixed build that addresses CVE-2025-32463, and recover by restoring any modified system NSS and loader files from known-good backups while validating ownership, permissions, and hashes.
54+
- Escalate to full incident response if a root shell or process with euid 0 is observed, if /etc/ld.so.preload or /lib/libnss_*.so outside the chroot show unauthorized changes, or if similar “sudo -R” executions appear across multiple hosts.
55+
- Harden by updating sudoers to remove NOPASSWD for chrooted commands, enforce Defaults env_reset and secure_path with noexec, disable “--chroot” usage for non-admin workflows, and monitor for creation of libnss_*.so or nsswitch.conf in non-standard directories.
56+
- Add platform controls by enabling SELinux/AppArmor policies on sudo and the dynamic loader, applying nodev,nosuid,noexec mounts to /tmp and build paths, and setting immutability (chattr +i) on /etc/nsswitch.conf where operationally feasible.
57+
"""
58+
references = [
59+
"https://www.stratascale.com/vulnerability-alert-CVE-2025-32463-sudo-chroot",
60+
"https://github.com/kh4sh3i/CVE-2025-32463",
61+
]
62+
risk_score = 73
63+
rule_id = "1d485649-c486-4f1d-a99c-8d64795795ad"
64+
setup = """## Setup
65+
66+
This rule requires data coming in from Elastic Defend.
67+
68+
### Elastic Defend Integration Setup
69+
Elastic Defend is integrated into the Elastic Agent using Fleet. Upon configuration, the integration allows the Elastic Agent to monitor events on your host and send data to the Elastic Security app.
70+
71+
#### Prerequisite Requirements:
72+
- Fleet is required for Elastic Defend.
73+
- To configure Fleet Server refer to the [documentation](https://www.elastic.co/guide/en/fleet/current/fleet-server.html).
74+
75+
#### The following steps should be executed in order to add the Elastic Defend integration on a Linux System:
76+
- Go to the Kibana home page and click "Add integrations".
77+
- In the query bar, search for "Elastic Defend" and select the integration to see more details about it.
78+
- Click "Add Elastic Defend".
79+
- Configure the integration name and optionally add a description.
80+
- Select the type of environment you want to protect, either "Traditional Endpoints" or "Cloud Workloads".
81+
- Select a configuration preset. Each preset comes with different default settings for Elastic Agent, you can further customize these later by configuring the Elastic Defend integration policy. [Helper guide](https://www.elastic.co/guide/en/security/current/configure-endpoint-integration-policy.html).
82+
- We suggest selecting "Complete EDR (Endpoint Detection and Response)" as a configuration setting, that provides "All events; all preventions"
83+
- Enter a name for the agent policy in "New agent policy name". If other agent policies already exist, you can click the "Existing hosts" tab and select an existing policy instead.
84+
For more details on Elastic Agent configuration settings, refer to the [helper guide](https://www.elastic.co/guide/en/fleet/8.10/agent-policy.html).
85+
- Click "Save and Continue".
86+
- To complete the integration, select "Add Elastic Agent to your hosts" and continue to the next section to install the Elastic Agent on your hosts.
87+
For more details on Elastic Defend refer to the [helper guide](https://www.elastic.co/guide/en/security/current/install-endpoint.html).
88+
"""
89+
severity = "high"
90+
tags = [
91+
"Domain: Endpoint",
92+
"OS: Linux",
93+
"Use Case: Threat Detection",
94+
"Tactic: Privilege Escalation",
95+
"Data Source: Elastic Defend",
96+
"Data Source: SentinelOne",
97+
"Data Source: Crowdstrike",
98+
"Data Source: Elastic Endgame",
99+
"Data Source: Auditd Manager",
100+
"Use Case: Vulnerability",
101+
"Resources: Investigation Guide",
102+
]
103+
timestamp_override = "event.ingested"
104+
type = "eql"
105+
query = '''
106+
process where host.os.type == "linux" and event.type == "start" and
107+
event.action in ("exec", "exec_event", "start", "executed", "process_started", "ProcessRollup2") and
108+
process.name == "sudo" and process.args in ("-R", "--chroot") and
109+
// To enforce the -R and --chroot arguments to be for sudo specifically, while wildcarding potential full sudo paths
110+
process.command_line like ("*sudo -R*", "*sudo --chroot*")
111+
'''
112+
113+
[[rule.threat]]
114+
framework = "MITRE ATT&CK"
115+
116+
[[rule.threat.technique]]
117+
id = "T1068"
118+
name = "Exploitation for Privilege Escalation"
119+
reference = "https://attack.mitre.org/techniques/T1068/"
120+
121+
[rule.threat.tactic]
122+
id = "TA0004"
123+
name = "Privilege Escalation"
124+
reference = "https://attack.mitre.org/tactics/TA0004/"

0 commit comments

Comments
 (0)