/

CVE-2026-38992

Severity:

CRITICAL RISK

(9.8)

Code Injection in Cockpit filter Parameter

CVE-2026-38992

Deferred

Vulnerability type

Category:

Code Injection

CWE:

CWE-94

Impact:

Remote Code Execution

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

Cockpit v2.13.5 and earlier contains a code injection vulnerability where the filter parameter is interpreted in a way that permits execution of arbitrary system commands through the MongoLite $func operator.

An attacker who can send crafted requests to affected endpoints may be able to run commands on the underlying server, leading to full compromise of the hosting infrastructure.

Affected context

This vulnerability appears in Cockpit instances that:

  • Expose endpoints accepting a filter parameter backed by MongoLite queries
  • Allow the $func operator to be passed directly from user input into query or function evaluation logic
  • Execute callbacks or command invocations derived from that operator within the server context

It is most relevant when Cockpit is reachable over a network (internet or internal) and when authentication and authorization controls do not fully constrain who can issue requests containing the filter parameter.

Exploit preconditions

  • Attack surface: HTTP(S) endpoints in Cockpit that accept a filter parameter processed by MongoLite
  • Required access: Ability to send crafted requests to those endpoints (may be unauthenticated or low-privileged depending on deployment configuration)
  • Trigger point: Submission of a filter value that leverages the $func operator to cause evaluation of attacker-controlled code or command strings
  • Why exploitation is possible: The server-side code treats parts of the filter parameter, including $func, as executable logic rather than opaque data. This blurs the boundary between data and code, allowing injection and execution of commands in the application's execution environment.

Why this happens

The underlying bug belongs to the CWE-94: Improper Control of Generation of Code ('Code Injection') class.

In this pattern, user-provided input is fed into a mechanism that can generate or invoke executable logic (here, the MongoLite $func operator) without strict validation or restriction. Instead of handling the filter parameter as pure data for query construction, the application allows dynamic behaviors to be defined by the client. When these behaviors are interpreted on the server—such as function callbacks or shell commands—they execute with the privileges of the Cockpit process. The absence of strong whitelisting, sandboxing, or safe evaluation boundaries enables an attacker to transform a data field into an execution channel.

Potential impact

  • Execution of arbitrary system commands on the host running Cockpit
  • Full compromise of the Cockpit application and associated data
  • Theft or modification of content, configuration, or credentials managed by Cockpit
  • Pivoting to other internal services reachable from the compromised server
  • Deployment of malware, backdoors, or cryptominers on the underlying infrastructure
  • Interruption of service availability through destructive commands

General mitigation guidance

Effective mitigation focuses on preventing user input from being interpreted as executable logic and constraining any dynamic behaviors:

  • Treat the filter parameter and similar query fields as data-only, disallowing operators like $func from being influenced by client input.
  • Apply strict whitelisting of allowed query operators and fields; reject or ignore anything not explicitly permitted.
  • Avoid evaluation mechanisms that can invoke arbitrary code, shell commands, or untrusted callbacks; prefer fixed, parameterized query builders and static functions.
  • Enforce input validation that normalizes and rejects structured input containing unexpected executable constructs.
  • Run the Cockpit process with least privilege, using restricted OS accounts and limiting access to the filesystem and system utilities where practical.
  • Consider introducing application-level policies that separate high-risk operations from routine query handling, or that constrain complex querying to trusted back-office flows.

How teams detect issues like this

Detection can combine code-centric and operational techniques:

  • Static analysis and code review:
  • Search for uses of MongoLite or similar libraries where client-controlled input influences operators like $func.
  • Flag any code paths that evaluate or execute data from HTTP parameters, especially within query builders, callback resolution, or shell invocation routines.
  • Review for generic "eval-like" behavior, dynamic function name resolution, or string-based command construction tied to request data.
  • Configuration and policy checks:
  • Enforce coding standards that ban execution of dynamically computed commands or function identifiers derived from request fields.
  • Integrate automated code review tools or linters that detect unsafe dynamic evaluation patterns.
  • Runtime and log analysis:
  • Monitor application and system logs for abnormal query patterns involving $func or unexpected operators in filter parameters.
  • Alert on suspicious command execution behavior, such as unusual processes launched by the Cockpit service account.

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 affected endpoints are network-accessible and accept attacker-controlled filter parameters, an attacker can exploit the issue remotely without needing local access to the server.

It depends on how Cockpit is deployed and which endpoints are protected. If endpoints using the vulnerable filter handling are accessible to unauthenticated or low-privileged users, those users could leverage the flaw. Strong authentication and authorization can reduce who can attempt exploitation but do not by themselves fix the underlying code issue.

The safest pattern is to remove any capability for user input to control executable logic. Concretely, this means treating client-supplied filters as data-only, disallowing $func or similar dynamic operators from being sourced from requests, and refactoring query generation to use fixed, parameterized constructs with a strict whitelist of allowed operators and fields.

Adopt a design rule that input from clients must never be executed or dynamically evaluated. Enforce strict validation and whitelisting on structured inputs, prohibit eval-like mechanisms and dynamic command construction, and include security-focused code review and automated checks that flag any use of user input in code-generation or command-execution paths.

Find out what's already
exploitable in your codebase.