CVE-2021-23394 is a critical-severity (CVSS 9.8) Unrestricted File Upload vulnerability in studio-42/elfinder. 2 public exploit references exist, so weaponization risk is real. A fix is available for studio-42/elfinder — see the affected versions and patch details below.
elFinder unsafe upload filtering leading to remote code execution
EPSS Exploitation Probability
Probability of exploitation in the next 30 days, from FIRST.org EPSS.
How urgent is this, really
CVE-2021-23394 by exploitation likelihood (EPSS) against impact (CVSS). Outside the shaded patch-first corner.
Where this sits among everything scored
Of 385,738 CVEs with a current EPSS score, this one falls in the 10–50% band (highlighted). Counts from FIRST.org, log-scaled.
Real-World Exposure
studio-42/elfinderReal-time download stats are indexed for npm and PyPI packages. This vulnerability affects Packagist packages — download data is not available via public APIs for these ecosystems.
Description
Impact
Before elFinder 2.1.58, the upload filter did not disallow the upload of .phar files. As several Linux distributions are now shipping Apache configured in a way it will process these files as PHP scripts, attackers could gain arbitrary code execution on the server hosting the PHP connector (even in minimal configuration).
Patches
The issue has been addressed with https://github.com/Studio-42/elFinder/commit/75ea92decc16a5daf7f618f85dc621d1b534b5e1, associating .phar files to the right MIME type. Unless explicitly allowed in the configuration, such files cannot be uploaded anymore. This patch is part of the last release of elFinder, 2.1.58.
Workarounds
If you can't update to 2.1.58, make sure your connector is not exposed without authentication.
Important tips
Server-side scripts can often be created as text files. Currently, elFinder has an appropriate MIME type set for file extensions that are generally runnable on a web server.
However, the server has various settings. In some cases, the executable file may be judged as "text/plain". Therefore, elFinder installers should understand the extensions that can be executed on the web server where elFinder is installed, and check if there are any missing items in the elFinder settings.
The elFinder PHP connector has an option "additionalMimeMap" that specifies the MIME type for each extension. See #3295(comment) for more information.
References
- https://snyk.io/vuln/composer:studio-42%2Felfinder
- https://github.com/Studio-42/elFinder/issues/3295
- Further technical details will be disclosed on https://blog.sonarsource.com/tag/security after some time.
For more information
If you have any questions or comments about this advisory, you can contact:
- The original reporters, by sending an email to support [at] snyk.io or vulnerability.research [at] sonarsource.com;
- The maintainers, by opening an issue on this repository.
Affected Packages
| Ecosystem | Package | Vulnerable range | Fix |
|---|---|---|---|
| 🐘Packagist | studio-42/elfinder | all versions | 2.1.58composer require studio-42/elfinder:^2.1.58 |
Affected Products
elfinderstd42Research use only. For defensive security, authorized penetration testing, and academic research only. Never execute exploit code against systems without explicit written authorization.
Detection & mitigation playbook
Open-source dependencyDetect
Scan your dependency tree (package-lock.json, pnpm-lock.yaml, requirements.txt, go.sum, etc.) for studio-42/elfinder, including transitive dependencies — a direct dependency you never call can still pull in a vulnerable version.
Fix
Update studio-42/elfinder to 2.1.58 or later, then make sure no transitive (indirect) dependency still pins the vulnerable range — O3 confirms CVE-2021-23394 is resolved across your whole dependency graph.
Workarounds
Treat uploaded files as untrusted until proven otherwise: validate the actual content type rather than the supplied extension, store uploads outside the web root on a volume mounted without execute permission, and rename them to server-generated identifiers so an attacker cannot choose the path a request will later resolve.
How to detect CVE-2021-23394
A community-maintained Nuclei template exists for this CVE. You can scan for it directly:
nuclei -id cve-2021-23394 -u https://target- Template
- elFinder < 2.1.58 - Remote Code Execution
- Severity
- high
- Impact
- Attackers can execute arbitrary PHP code on the server, potentially leading to full server compromise.
- Remediation
- Update to version 2.1.58 or later.
Template by ProjectDiscovery nuclei-templates (0xanis), MIT licensed. View the full template. Scan only systems you are authorised to test.
Frequently Asked Questions
Is CVE-2021-23394 in your dependencies?
Find it across Packagist, including transitive dependencies.