/

CVE-2026-38991

Severity:

HIGH RISK

(8.8)

Unrestricted File Upload / Type Bypass in Cockpit Bucket

CVE-2026-38991

Deferred

Vulnerability type

Category:

Unrestricted File Upload / Type Bypass

CWE:

CWE-434

Impact:

Remote Code Execution (post-authentication)

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

Cockpit versions 2.13.5 and earlier contain a misconfiguration in the Bucket component's _isFileTypeAllowed function that allows crafted filenames to bypass the extension filter.

An authenticated attacker can exploit this behavior to rename arbitrary files to use a .php extension, potentially enabling arbitrary code execution on the underlying server when those files are interpreted by PHP.

Affected context

The vulnerability occurs in deployments using the Cockpit CMS Bucket component where file type checks rely on filename-based extension filtering.

It becomes relevant when:

  • PHP is enabled on the web server and .php files are executable
  • Buckets accept user-controlled uploads or file renames from authenticated users
  • The _isFileTypeAllowed function is the primary gate for determining which file types are permitted

In such environments, bypassing this filter allows dangerous server-side executable files to be created or renamed into a web-accessible location.

Exploit preconditions

  • Attack surface: Web interface or API endpoints that expose the Cockpit Bucket component's upload or rename functionality.
  • Required access: Valid authenticated account with permission to upload, manage, or rename files within a Bucket.
  • Trigger point: Supplying a specially crafted filename to the Bucket component such that _isFileTypeAllowed incorrectly treats it as allowed, resulting in a .php file being created or renamed.
  • Why exploitation is possible: The file type validation logic focuses on extension checks that can be bypassed by manipulating the filename (e.g., through multiple extensions, special characters, or encoding quirks), allowing disallowed executable types to pass as permitted formats.

Why this happens

The root cause is a flawed file type validation mechanism consistent with CWE-434: Unrestricted Upload of File with Dangerous Type.

Instead of reliably determining the file's true type or enforcing a deny-by-default policy for executable content, the _isFileTypeAllowed function relies on fragile, filename-based extension filtering.

This pattern fails when attacker-controlled filenames can be crafted to evade the extension checks, enabling the creation or renaming of files with a .php extension in a context where the web server executes them.

Potential impact

  • Execution of arbitrary PHP code on the web server within the privileges of the web application process
  • Full compromise of the Cockpit CMS instance and its data
  • Pivoting to other services or systems reachable from the compromised server
  • Installation of web shells or backdoors for persistent access
  • Tampering with website content or data stored in Cockpit

General mitigation guidance

Effective mitigation focuses on hardening file handling and reducing trust in user-controlled filenames:

  • Enforce a strict allowlist of safe, non-executable file types based on content (MIME type, magic bytes) rather than only on file extensions.
  • Reject or strip executable extensions (e.g., .php, .php5, .phtml, .phar) for all user-uploaded or renamed files, even if they pass other filters.
  • Store user-supplied files outside of web-accessible directories, serving them through an application layer that does not execute them.
  • Normalize filenames (e.g., lowercase, remove special characters and multiple extensions) before validation to prevent bypass via obfuscation.
  • Apply least-privilege server configuration: disable execution of scripts in upload directories and restrict PHP handlers where feasible.

How teams detect issues like this

High-level detection can combine code-level analysis with runtime monitoring:

  • Static analysis and code review:
  • Flag code paths where file type checks rely primarily on pathinfo, string suffix checks, or regular expressions against filenames.
  • Identify upload or rename handlers that allow .php or other executable extensions, or that use weak allowlists/denylists.
  • Review storage paths to confirm whether user-controllable files are placed under web-executable directories.
  • Runtime and operational monitoring:
  • Log and alert on uploads or renames resulting in files with executable extensions (e.g., .php) under web roots.
  • Monitor web server logs for unusual access patterns to newly created .php files or unexpected PHP endpoints.
  • Policy and tooling:
  • Enforce secure file upload policies in CI/CD, using SAST/linters to detect unsafe validation patterns.
  • Use web application firewalls or reverse proxies to block requests to suspicious script locations commonly used for web shells.

Sources

SourceLink
felsec.comfelsec.com/posts/cockpit-cms-2.13.5-multi-vulns/
github.comgithub.com/Cockpit-HQ/Cockpit/releases/tag/2.14.0

Frequently asked

questions

Yes, if the Cockpit instance is exposed over the internet and an attacker can obtain valid credentials with permissions to upload or rename files in Buckets, the vulnerability can be triggered remotely via HTTP(S) requests.

Not necessarily. Exploitation requires an authenticated account with sufficient permissions to manage files in the affected Bucket component. In many setups, content editors or similar roles may have these capabilities without full administrative access.

The safest pattern is to decouple user uploads from executable contexts: normalize and strictly validate file types using robust allowlists, prevent any executable extensions from being stored in web-executable directories, and treat all user-supplied filenames as untrusted, replacing them with server-generated safe names.

Adopt secure file handling standards: design upload systems around content-type validation and non-executable storage locations, incorporate security-focused code review for file operations, and use automated analysis to flag extension-based checks and any paths that could result in user-controlled executable files on the server.

Find out what's already
exploitable in your codebase.