/

CVE-2026-22799

Severity:

HIGH RISK

(8.8)

Unrestricted File Upload in Emlog REST Media Endpoint

CVE-2026-22799

Analyzed

Vulnerability type

Category:

Unrestricted File Upload

CWE:

CWE-434

Impact:

Remote Code Execution

Severity:

HIGH RISK

(8.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

Emlog v2.6.1 and earlier expose a media upload REST API that does not properly validate file type, extension, or content, allowing arbitrary files to be uploaded.

An authenticated attacker with a valid API key or admin session cookie can upload and execute malicious PHP scripts on the server, leading to remote code execution and potential full server compromise.

Affected context

This vulnerability affects Emlog deployments that have the REST API feature exposed and reachable, particularly when:

  • The /index.php?rest-api=upload endpoint is enabled and accessible.
  • Media uploads are accepted without strict checks on file extension, MIME type, or file contents.
  • Uploaded files are stored under a web‑accessible directory where the server executes PHP code.

The risk is elevated when administrator accounts are weakly protected or when the application has additional information disclosure issues that expose API keys.

Exploit preconditions

  • Attack surface: HTTP(S) interface exposing /index.php?rest-api=upload.
  • Required access: Authenticated context via:
  • A valid REST API key, or
  • A valid administrator session cookie.
  • Additional enabling factors:
  • REST API setting turned on by an administrator, or
  • API key obtained via separate information disclosure weaknesses.
  • Trigger point: Sending a crafted upload request containing a PHP script (or other executable server-side code) to the upload endpoint.
  • Why exploitation is possible: The upload handler trusts the client-supplied file name, type, and data, performing insufficient validation and storing the file in a location where the web server will execute it on subsequent requests.

Why this happens

The core issue maps to CWE-434: Unrestricted Upload of File with Dangerous Type.

The REST upload handler accepts user-supplied files and:

  • Does not strictly enforce an allowlist of safe extensions (e.g., images only).
  • Does not reliably verify MIME type or file content signatures.
  • Stores uploaded content in a directory where PHP code is executable by the web server.

This design treats partially trusted authenticated input as benign and fails to separate data files from executable code, allowing attackers to smuggle server-side scripts through a generic upload mechanism.

Potential impact

  • Remote code execution on the web server via uploaded PHP scripts.
  • Full compromise of the Emlog application and hosted website content.
  • Theft or modification of application data, including user information and configuration.
  • Installation of webshells or backdoors for persistent access.
  • Pivoting to other internal systems reachable from the compromised host.
  • Use of the server for spam, phishing pages, or hosting malware.

General mitigation guidance

Effective mitigation generally focuses on hardening the upload pipeline and isolating executable code from user-supplied content:

  • Enforce a strict allowlist of permitted file types and extensions (e.g., only specific image formats), rejecting everything else by default.
  • Validate file content using server-side MIME/type detection and, where possible, file signature checks rather than relying on client-supplied headers or names.
  • Store upload files outside of any directory where the web server executes scripts; serve them via a dedicated static file mechanism or proxy that treats them strictly as data.
  • Apply path normalization and prevent any user control over the final storage path or file extension.
  • Consider renaming uploaded files to server-generated names and stripping original extensions.
  • Restrict the REST upload capability to the minimal set of roles that require it and disable the feature entirely if not needed.
  • Run the web server and application with least-privilege OS accounts and minimal filesystem execute permissions on upload directories.

How teams detect issues like this

Organizations can detect and monitor for this class of issue through a mix of code-level and runtime approaches:

  • Static analysis and code review:
  • Flag upload handlers that accept arbitrary file types or lack extension/MIME validation.
  • Look for patterns where uploaded files are written into webroot or executable directories.
  • Review for missing allowlists and reliance on client-side checks for upload security.
  • Policy and CI enforcement:
  • Add automated checks or linting rules that require explicit type validation for any new upload endpoints.
  • Enforce secure coding guidelines around file handling and separation of code vs. content.
  • Runtime monitoring:
  • Monitor web server logs for uploads of non-media files or unusual extensions.
  • Alert on direct access to recently uploaded files from upload endpoints.
  • Use web application firewalls (WAFs) to detect and block common webshell patterns in upload traffic, where feasible.

Sources

SourceLink
github.comgithub.com/emlog/emlog/commit/429b02fda842254b9b9b39303e9161999c180560
github.comgithub.com/emlog/emlog/security/advisories/GHSA-p837-mrw9-5x5j

Frequently asked

questions

Yes, if the REST API upload endpoint is exposed over the internet and an attacker can obtain a valid API key or admin session, they can exploit this issue remotely to achieve code execution.

The attacker needs authenticated access to the REST API upload endpoint, typically via a valid API key or an administrator session cookie. That access might be acquired through weak admin security, credential theft, or separate information disclosure flaws that leak API keys.

The most robust fix is to strictly limit what can be uploaded and where it is stored: enforce an allowlist of safe file types, verify content server-side, and ensure that uploaded files are stored in non-executable locations that the web server treats purely as data.

Treat all file uploads as untrusted input, design upload flows around allowlists and strong validation, separate user-controlled files from executable code paths, and include checks for file handling and storage locations in security-focused code reviews and CI pipelines.

Find out what's already
exploitable in your codebase.