/

CVE-2026-34965

Severity:

HIGH RISK

(8.8)

Code Injection in Cockpit CMS Collection Rules Handling

CVE-2026-34965

Deferred

Vulnerability type

Category:

Code Injection

CWE:

CWE-94

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

Cockpit CMS contains an authenticated code injection flaw in the /cockpit/collections/save_collection endpoint that allows users with collection management privileges to inject arbitrary PHP into collection rules.

The injected PHP is written into server-side files and later executed via include(), enabling attackers to run arbitrary commands on the underlying server under the web server's privileges.

Affected context

This vulnerability affects Cockpit CMS deployments where authenticated users can manage or configure collections through the /cockpit/collections/save_collection endpoint.

The issue arises in environments where rule parameters from collection configurations are persisted to PHP files without strict validation or sanitization and are subsequently loaded via include() or similar constructs.

It is most relevant in multi-user or shared admin setups where collection management rights may be granted to non-owners or integrated systems.

Exploit preconditions

  • Attack surface: HTTP interface of Cockpit CMS, specifically the /cockpit/collections/save_collection endpoint.
  • Required access: Valid authenticated account with permissions to create or modify collections (collection management privileges).
  • Trigger point: Submission or update of collection configurations whose rule parameters are stored to PHP files and later loaded via include().
  • Why exploitation is possible: The application treats rule parameters as trusted content, writing them directly into executable PHP files without neutralizing code, and then executes them through include(), giving attackers a path to inject and execute arbitrary PHP.

Why this happens

The core issue is improper neutralization of user-controllable input before it is incorporated into executable code, which aligns with CWE-94: Improper Control of Generation of Code ('Code Injection').

Cockpit CMS allows collection rule parameters, supplied by authenticated users, to be written directly into PHP files that are later evaluated via include().

This pattern effectively turns configuration input into application logic without strict separation or sanitization, meaning that any PHP code embedded in these parameters is executed in the server context.

The lack of a strict, non-executable format for rules and absence of robust validation or encoding of rule content leads to full code injection capabilities.

Potential impact

  • Execution of arbitrary PHP code on the server
  • Execution of arbitrary OS commands with the web server's privileges
  • Reading, modifying, or deleting CMS data and configuration
  • Access to credentials, API keys, or other secrets stored on the server
  • Pivoting into internal networks reachable from the CMS host
  • Complete takeover of the affected Cockpit CMS instance

General mitigation guidance

Effective mitigation focuses on treating rule definitions as data, not executable code, and minimizing the trust placed in configuration content:

  • Use a non-executable representation (e.g., JSON, structured arrays, or a constrained expression language) for collection rules rather than embedding raw PHP.
  • Implement strict validation and whitelisting for rule parameters, limiting them to well-defined, non-code constructs.
  • Avoid include() or similar dynamic-code-loading mechanisms for user-modifiable configuration; interpret rules with a fixed, non-eval-based engine.
  • Enforce principle of least privilege for CMS roles, granting collection management rights only to highly trusted accounts.
  • Run the web server and PHP runtime with minimal OS privileges and restrict filesystem write access, especially to directories containing executable code.
  • Consider using separate configuration and code directories, treating configuration paths as non-executable in the web and PHP configuration.

How teams detect issues like this

Organizations can detect and monitor for this class of weakness through a combination of code-focused and operational controls:

  • Static analysis rules that flag:
  • Use of include(), require(), or similar functions with paths influenced by user input.
  • Construction of PHP files or dynamic code from request parameters or database-stored configuration.
  • Code review checklists focusing on:
  • Any flow where configuration or admin-defined rules are written to .php files.
  • Any mechanism where user-influenced data is treated as executable PHP.
  • Runtime monitoring such as:
  • File integrity monitoring for unexpected changes to PHP files in configuration or module directories.
  • Logging and alerting on unusual admin activity related to collection creation or modification.
  • Integration of automated security testing tools in CI pipelines that look for dynamic code generation and inclusion patterns.

Sources

SourceLink
gist.github.comgist.github.com/thepiyushkumarshukla/64d2318518b17f529bc3ccb11fd5be90
github.comgithub.com/agentejo/cockpit
github.comgithub.com/agentejo/cockpit/commits/494765e4f0fb9484f320aee0c6ee889b6fa789b9
vulncheck.comvulncheck.com/advisories/cockpit-cms-authenticated-remote-code-execution-via-collections

Frequently asked

questions

Yes, but it requires authenticated access. An attacker must be able to send HTTP requests to the Cockpit CMS instance and authenticate with an account that has collection management privileges.

The attacker needs a valid Cockpit CMS account with permissions to create or modify collections via /cockpit/collections/save_collection. Guest or unauthenticated users cannot directly exploit this issue.

The safest pattern is to remove any dependence on dynamically executed PHP for rules: store rules in a non-executable format, interpret them with fixed logic, and prevent any user-controlled input from being written into executable PHP files. Avoid include() for content that can be influenced by administrators or other users.

Adopt a design rule that configuration is always data, never code. Avoid dynamic code generation or inclusion based on user input, enforce strict validation and whitelisting on administrative inputs, and incorporate security reviews and static analysis focused on dynamic execution sinks early in the development lifecycle.

Find out what's already
exploitable in your codebase.