elFinder is an open-source web-based file manager written in JavaScript, widely used in CMS platforms, hosting panels, and web applications. However, poor configuration can expose serious security risks.
Example Exploit:
curl -X POST -F "cmd=upload" -F "target=l1_Lw" -F "upload[]=@shell.php" http://yourdomain.com/elfinder/php/connector.php
Risk: This can lead to remote code execution (RCE).
Fix:
connector.php:
'uploadAllow' => array('image/png', 'image/jpeg', 'application/pdf'),
'uploadDeny' => array('all'),<Directory /var/www/html/elfinder/files>
<FilesMatch "\.php$">
Deny from all
</FilesMatch>
</Directory>Example Exploit:
curl http://yourdomain.com/elfinder/php/connector.php?cmd=open
Risk: Anyone can browse your server files.
Fix:
connector.php:
'bind' => array(
'upload.pre' => array(
'Plugin.Sanitizer.cmdUploadPre',
'Plugin.Authentication.cmdPre',
)
),<Files "connector.php">
Require all denied
</Files>Example Exploit:
curl "http://yourdomain.com/elfinder/php/connector.php?cmd=file&target=l1_L2NvbmZpZy5waHA"
Risk: Attackers can steal database credentials.
Fix:
<FilesMatch "(config\.php|\.env|database\.php)">
Require all denied
</FilesMatch>Example Exploit:
curl -X POST -F "cmd=rename" -F "target=l1_test.txt" -F "name=<script>alert('XSS')</script>" http://yourdomain.com/elfinder/php/connector.php
Risk: Session hijacking, stealing cookies, redirecting users.
Fix:
'plugin' => array(
'Sanitizer' => array(
'enable' => true,
'targets' => array('\\', '/', ':', '*', '?', '"', '<', '>', '|', ' '),
'replace' => '_'
)
)<Directory /var/www/html/elfinder>
AuthType Basic
AuthName "Restricted Access"
AuthUserFile /etc/apache2/.htpasswd
Require valid-user
</Directory>rm -rf /var/www/html/elfinder| Vulnerability | Fix |
|---|---|
| Unrestricted file uploads | Restrict file types, disable PHP execution |
| Authentication bypass | Restrict connector.php, enable authentication |
| Arbitrary file read (LFI) | Block sensitive files using .htaccess |
| Cross-Site Scripting (XSS) | Enable filename sanitization, use CSP |
Keep elFinder updated & restrict access to prevent exploits!