
Automated exploit toolkit and detection template for CVE-2024-21546, an unauthenticated RCE in UniSharp Laravel Filemanager, with WAF evasion and interactive shell.
This repository contains security assessment tooling, detection templates, and an automated exploit toolkit for identifying and exploiting Unauthenticated Remote Code Execution (RCE) in applications utilizing the UniSharp/laravel-filemanager package (Versions < 2.9.1).
laravel-filemanager.yaml)
cve_2024_21546_rce.py)
The vulnerability stems from two combined conditions:
/laravel-filemanager routes without applying the 'auth' or 'web' middleware pipeline..), allowing attackers to bypass executable file blocklists and place PHP scripts into public storage.LfmUploadValidator.php)In versions prior to v2.9.1, LfmUploadValidator.php checked file extensions against a blocklist using:
public function extensionIsNotExcutable($unallowed_extensions)
{
$extension = strtolower($this->file->getClientOriginalExtension());
if (in_array($extension, $unallowed_extensions)) {
throw new \Exception('File extension is not allowed.');
}
return $this;
}
When an attacker uploads a file named poc.php.:
getClientOriginalExtension() extracts characters following the final dot.getClientOriginalExtension() evaluates to "" (empty string).in_array("", ['php', 'html']) evaluates to false, bypassing the extension block.On Windows and specific storage drivers, the file is persisted as an extensionless hash (<hash>). The exploit chains LFM's RenameController (GET /laravel-filemanager/rename?file=<hash>&new_name=runner.php) to rename the uploaded payload into an active .php file, granting immediate web execution under /storage/app/public/file-manager-files/items/runner.php.
laravel-filemanager.yaml)The upstream community template (http/exposed-panels/laravel-filemanager.yaml) (https://github.com/projectdiscovery/nuclei-templates/blob/main/http/exposed-panels/laravel-filemanager.yaml) relied on a hardcoded English string matcher:
matchers:
- type: word
words:
- "Laravel FileManager" # Fails on localized deployments or non english versions
When applications are localized (e.g. Arabic, French, Chinese), the English string is not present in the HTML body, causing false negatives.
The modernized template detects the panel by matching immutable vendor asset paths and upload form actions:
id: laravel-filemanager
info:
name: Laravel File Manager - Panel Detect
author: digitalsurgn
severity: critical
description: Laravel File Manager panel was detected.
reference:
- https://github.com/UniSharp/laravel-filemanager
classification:
cvss-metrics: CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:N
cwe-id: CWE-200
metadata:
max-request: 1
tags: panel,laravel,filemanager,fileupload,intrusive
http:
- method: GET
path:
- "{{BaseURL}}/laravel-filemanager?type=Files"
matchers-condition: and
matchers:
- type: word
part: body
words:
- "vendor/laravel-filemanager"
- "laravel-filemanager/upload"
condition: or
- type: status
status:
- 200
nuclei -u https://target.com/ -t laravel-filemanager.yaml
cve_2024_21546_rce.py)The standalone Python tool (cve_2024_21546_rce.py) automates end-to-end unauthenticated exploitation with built-in WAF evasion and self-cleaning hygiene.
/laravel-filemanager is accessible without authentication before attempting exploitation.jsonitems) to identify the uploaded hash without relying on hardcoded folder or file names.<?=), dynamic function invocation (('pas'.'sthru')), and Base64-encoded X-Cmd headers to evade inspection rules.--interactive).python3 cve_2024_21546_rce.py [OPTIONS]
python3 cve_2024_21546_rce.py
python3 cve_2024_21546_rce.py -t xyz.com -c "whoami"
python3 cve_2024_21546_rce.py -t 10.10.10.50 -p 8080 --interactive
unisharp/laravel-filemanager to version 2.9.1 or later via Composer:
composer update unisharp/laravel-filemanager
config/lfm.php:
'middlewares' => ['web', 'auth'],
.php scripts in public upload directories (e.g. /storage/).| Metric | Details |
|---|
| Vulnerability Name | UniSharp Laravel Filemanager Unrestricted File Upload to RCE |
| CVE Identifier | CVE-2024-21546 |
| Affected Component | unisharp/laravel-filemanager (< 2.9.1) |
| Common Weakness | CWE-94 (Code Injection) / CWE-434 (Unrestricted Upload) |
| Severity | Critical (CVSS 9.8) |
| Attack Vector | Remote / Unauthenticated HTTP |
| Flag | Parameter | Description |
|---|
-t, --target | <host> | Target domain or IP address (e.g. example.com or 192.168.1.50). |
-p, --port | <port> | Target port if different from standard 80/443 (e.g. 8080, 8443). |
--scheme | http / https | Explicitly specify protocol scheme (default: auto-detected). |
-c, --cmd | <command> | Single command to execute (e.g. whoami, id, ipconfig). |
-i, --interactive | flag | Launch an interactive command execution shell. |
-d, --dir | <path> | Target LFM working directory (default: /items). |