linuxLevram

Privilege Escalation via Python Binary with cap_setuid

Summary

  • Discovered only two open ports: SSH (22) and a web server (8000) running Gerapy.

  • Gerapy was running a vulnerable version, which led to authenticated command execution.

  • Exploited CVE-2021-43857 to gain an initial foothold.

  • Privilege escalation achieved using cap_setuid capability assigned to Python3 binary, allowing elevation to root.

🧡 Let's Unpack


Enumeration

sudo nmap -A -T4 -sV -sC -p- -Pn 192.168.229.24 --open

Open Ports:

  • 22/tcp β†’ OpenSSH 8.9p1 Ubuntu

  • 8000/tcp β†’ Gerapy (WSGIServer/0.2 CPython/3.10.6)

πŸ“Œ Interesting Findings:

  • Gerapy panel hosted on port 8000.

  • Web title confirmed it was running Gerapy.

  • robots.txt or web paths not exposed; had to manually verify version and exploit.


Initial Foothold

  • Used public exploit for Gerapy RCE: β†’ CVE-2021-43857arrow-up-right

  • The exploit chain allowed remote code execution by abusing insecure project configuration and file inclusion.

  • βœ… Received reverse shell from Gerapy web context.


Privilege Escalation

Found this:

  • This capability allows the binary to change its user ID β€” effectively enabling escalation to root.

From GTFOBins – Pythonarrow-up-right:

  • 🧨 Boom! Got a root shell.


Last updated