root@thehacksparrow:~/writeups$ SYSTEM ONLINE
root@sparrow:~/writeups$ cat environment.md
// writeups

Environment

3 May 2025 · 11 min read · root access
Environment - maquina de Hack The Box

Executive summary — Environment is a Medium Linux box built on Laravel 11.30.0 that chains two 2024 CVEs. First, a misconfigured PHP directive lets a query parameter (CVE-2024-52301) slip in as if it were a command-line flag, forcing the framework to boot in an alternate environment with login effectively disabled. Inside, the file manager bundled with the dashboard carries its own validation flaw (CVE-2024-21546): renaming the payload shell.php.. (an extra trailing dot) and adding GIF magic bytes gets RCE as www-data. An encrypted GPG backup reveals the real user hish's credentials, and the final escalation abuses sudo preserving BASH_ENV for a binary that internally invokes bash, running arbitrary code as root.

PlatformHack The Box
Operating systemLinux
DifficultyMedium
StatusRetired
Target IP10.129.232.3

Attack map

[1] Recon -- SSH (OpenSSH 9.2p1) + nginx serving Laravel 11.30.0
        |
[2] CVE-2024-52301 -- register_argc_argv poisons argv via the query string
      +-> POST /login?--env=preprod -> authentication bypass (Burp)
        |
[3] CVE-2024-21546 (UniSharp Laravel-Filemanager) -- shell.php.. (double extension)
      + GIF89a magic bytes
      +-> backend normalises the name -> executable .php.  ->  RCE as www-data
        |
[4] user.txt in /home/hish (find + cat)
        |
[5] keyvault.gpg exfiltrated -- gpg --import + gpg --decrypt ->
      ENVIRONMENT.HTB -> marineSPm@ster!!  ->  ssh hish@environment.htb
        |
[6] sudo -l -- hish can run /usr/bin/systeminfo as root with BASH_ENV preserved
      (env_keep in sudoers) -- systeminfo internally invokes bash
      +-> BASH_ENV=/tmp/root.sh runs BEFORE the target script, as root
      +-> sudo /usr/bin/systeminfo  ->  root.txt

1. Enumeration

nmap -sV -sC 10.129.232.3

Result: SSH (OpenSSH 9.2p1) and HTTP (nginx serving a Laravel 11.30.0 application). Only two ports open, so the entire attack surface sits in the web app.

The exact framework version matters: Laravel 11.30.0 is vulnerable to a documented authentication bypass (CVE-2024-52301), fixed in 11.31.0 — this instance is exactly one patch release behind the fix.

Laravel resolves routes and configuration per virtual host based on the Host header, so without the right hostname the app may respond with different or incomplete content. We add the hostname to local resolution:

echo "10.129.232.3 environment.htb" | sudo tee -a /etc/hosts
🔒 Clearance required

This content is Root Access only. Everything else on the site — the free tier, the whole public library — stays open.

See Root Access plans

No account? Create one free then upgrade from your console.