Severity:

CRITICAL RISK

(9.8)

Unrestricted File Upload in Laravel Mediable

CVE-2026-4809

Deferred

Vulnerability type

Category:

Unrestricted File Upload

CWE:

CWE-434

Impact:

Remote Code Execution via Arbitrary File Upload

Severity:

CRITICAL RISK

(9.8)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

A file upload validation weakness in plank/laravel-mediable through version 6.4.0 can allow dangerous files to bypass checks when an application relies on client-supplied MIME types.

An attacker can upload a PHP file while declaring a safe image MIME type; if that file is placed in a web-accessible executable location, it can lead to remote code execution.

Affected context

This vulnerability affects Laravel applications that integrate the plank/laravel-mediable package (through 6.4.0) and are configured to trust or prefer MIME types sent by the client during upload.

It is most relevant where:

  • File type validation is performed using only the request-provided MIME type or similar client-controlled metadata
  • Uploaded files are stored under web-accessible paths
  • The web server is configured to execute PHP in the upload directory or subdirectories

The issue does not inherently affect every installation of the package; it manifests when application-level configuration and deployment choices allow MIME type trust and executable storage paths to combine.

Exploit preconditions

  • Attack surface: Public or authenticated file upload endpoints that pass uploads through laravel-mediable.
  • Required access: Ability to reach the upload functionality (e.g., any user permitted to upload media).
  • Trigger point: Submission of a file containing executable PHP code (or another server-executable format) while declaring a benign MIME type such as an image or document type.
  • Why exploitation is possible:
  • The application relies on client-supplied MIME information for validation, which is under attacker control.
  • Laravel-mediable accepts or prefers that MIME type and classifies the file as safe.
  • The resulting file is stored in a location that the web server can both serve and execute, allowing an attacker to later request the file and trigger code execution.

Why this happens

The root cause aligns with CWE-434: Unrestricted Upload of File with Dangerous Type.

The package, when used in a configuration that trusts client-provided MIME types, does not robustly confirm that an uploaded file's actual content and extension correspond to the expected safe types.

Instead of deriving trust from server-side inspection (e.g., content sniffing, controlled extension mapping, segregated storage), the validation path can be driven by attacker-controlled metadata such as the Content-Type header.

This mismatch between perceived file type and real file behavior allows executable content to be introduced into locations where the runtime or web server will interpret it as code.

Potential impact

  • Remote execution of arbitrary PHP code if uploads are stored in an executable web directory
  • Full compromise of the affected web application instance
  • Unauthorized access to application data, including configuration files and database credentials
  • Abuse of the compromised server to pivot deeper into the infrastructure
  • Use of the server as a platform for further attacks (spam distribution, malware hosting, etc.)
  • Defacement or alteration of site content by modifying application files or templates

General mitigation guidance

Effective mitigation focuses on strict server-side file validation and safe storage practices, independent of client-provided metadata:

  • Treat all client-supplied MIME types, file extensions, and filenames as untrusted hints rather than authoritative facts.
  • Implement server-side inspection for uploaded files, using trusted libraries or OS-level mechanisms to determine content type and enforce a strict allowlist (e.g., specific image formats only).
  • Normalize and control file extensions on the server side, overriding any extension provided by the client, and rejecting uploads that cannot be safely mapped.
  • Store uploaded files outside of web-accessible and executable directories; serve them via controlled endpoints or a dedicated static file/CDN layer configured to never execute dynamic code from upload paths.
  • Configure the web server so that upload directories are explicitly non-executable (e.g., no PHP handler, no script execution permissions).
  • Apply least-privilege principles to the process handling uploads so that, even in case of misclassification, the impact of a malicious file is constrained.

How teams detect issues like this

Detection is best approached through a combination of code-level and configuration-level analysis:

  • Static analysis and code review:
  • Look for upload flows that rely on $request->getMimeType(), $request->getClientMimeType(), or other request-derived properties when deciding whether a file is allowed.
  • Identify use of laravel-mediable where type validation or media collections are defined based solely on MIME types without secondary checks on file content or enforced extensions.
  • Flag any logic that directly maps client-provided MIME types or extensions to storage paths or trust levels.
  • Configuration and deployment review:
  • Inspect web server (e.g., Nginx, Apache) configuration to ensure upload directories do not have PHP or other script handlers enabled.
  • Verify that filesystem permissions and execution policies prevent execution from upload locations.
  • Automated tooling:
  • Use SAST tools or custom rules targeting unrestricted file upload patterns (CWE-434) and trust of client MIME types.
  • Employ runtime monitoring or WAF rules to detect suspicious access to newly uploaded executable files or atypical script execution paths under upload directories.

Sources

SourceLink
github.comgithub.com/plank/laravel-mediable
github.comgithub.com/plank/laravel-mediable/releases/tag/6.4.0

Frequently asked

questions

Yes. If an upload endpoint is accessible over the network and uses laravel-mediable in a configuration that trusts client-supplied MIME types, an attacker can exploit it remotely by uploading a crafted file and then requesting it if it is web-accessible.

The attacker needs whatever access is required to use the file upload functionality. In many applications this may be available to unauthenticated users (e.g., contact forms) or low-privilege accounts, which significantly broadens exposure.

The safest pattern is to perform strict, server-side validation of uploaded files using a positive allowlist, ignore or de-prioritize client-supplied MIME types for trust decisions, and store all uploads in non-executable locations outside the web root or behind non-executable static file handlers.

Design upload flows with the assumption that all client metadata is untrusted, enforce content-based and extension-based validation on the server, segregate uploaded files from executable code, and incorporate security-focused review and automated checks for file upload paths as part of your regular development and deployment process.

Find out what's already
exploitable in your codebase.