Severity:

CRITICAL RISK

(9.8)

OS Command Injection (CWE-78) in Cockpit Remote Login

CVE-2026-4631

Awaiting Analysis

Vulnerability type

Category:

OS Command Injection

CWE:

CWE-78

Impact:

Unauthenticated 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

A critical command-injection vulnerability in Cockpit's remote login feature allows attacker-controlled hostnames and usernames to influence SSH client invocation. An attacker with network access to the Cockpit web service may execute commands on the Cockpit host through a crafted login request, without valid credentials, before authentication completes.

Affected context

The vulnerability occurs in Cockpit deployments that expose the remote login feature and pass web-supplied hostnames or usernames into an SSH client without adequate validation, sanitization, or argument isolation. Risk is highest when the Cockpit service is reachable by untrusted networks and the host process has meaningful operating-system privileges.

Exploit preconditions

  • Attack surface: Cockpit's remotely accessible web login endpoint
  • Required access: Network access to the Cockpit web service; valid credentials are not required
  • Trigger point: Processing of user-supplied hostname or username values during the SSH-based authentication flow
  • Why exploitation is possible: Untrusted values are incorporated into SSH client execution without reliably separating data from options or shell-controlled command content

Why this happens

The underlying flaw is OS command injection, mapped to CWE-78. The application treats values received from the web interface as trusted process or command parameters instead of enforcing a strict input contract and preserving argument boundaries. As a result, specially crafted data may alter SSH client behavior or cause additional commands to be interpreted by the Cockpit host before authentication succeeds.

Potential impact

  • An attacker may execute arbitrary commands on the Cockpit host
  • The Cockpit service account or its accessible resources could be compromised
  • Local data may be read, modified, or destroyed
  • The host could be used for lateral movement or persistence
  • Connected systems and administrative credentials could be exposed

General mitigation guidance

Mitigation generally focuses on eliminating command interpretation and reducing trust in web-provided connection parameters.

Common defensive patterns include:

  • Invoke SSH through a process API that passes a fixed argument array rather than a shell command
  • Apply strict allowlists and canonical validation to hostnames, usernames, and connection options
  • Reject unexpected option prefixes, control characters, separators, and shell metacharacters
  • Keep user-controlled values isolated from fixed client options and executable content
  • Run the Cockpit service with least privilege and restrict its access to sensitive host resources
  • Apply network segmentation and access controls to the Cockpit web service

How teams detect issues like this

Organizations can look for command-injection exposure through:

  • Static analysis rules identifying shell construction, string concatenation, or interpolation involving request parameters
  • Code review checks for subprocess calls that accept untrusted values without argument arrays or explicit escaping
  • Tests using boundary-focused input validation cases, including option-like values and command-control characters
  • Runtime monitoring for unexpected SSH client arguments, child processes, or shell descendants spawned by Cockpit
  • Policy enforcement requiring approved process-execution wrappers and allowlisted remote connection parameters

Neutral automated code-review and software-composition tools may help identify unsafe process invocation patterns.

Sources

SourceLink
access.redhat.comaccess.redhat.com/errata/RHBA-2026:21387
access.redhat.comaccess.redhat.com/errata/RHBA-2026:21388
access.redhat.comaccess.redhat.com/errata/RHSA-2026:7381
access.redhat.comaccess.redhat.com/errata/RHSA-2026:7382
access.redhat.comaccess.redhat.com/errata/RHSA-2026:7383
access.redhat.comaccess.redhat.com/errata/RHSA-2026:7384
access.redhat.comaccess.redhat.com/security/cve/CVE-2026-4631
bugzilla.redhat.combugzilla.redhat.com/show_bug.cgi?id=2450246
github.comgithub.com/cockpit-project/cockpit/security/advisories/GHSA-m4gv-x78h-3427
openwall.comopenwall.com/lists/oss-security/2026/04/10/5
security.access.redhat.comsecurity.access.redhat.com/data/csaf/v2/vex/2026/cve-2026-4631.json

Frequently asked

questions

Yes. An attacker generally needs network access to the Cockpit web service, and exploitation can occur through the remote login endpoint without completing authentication.

No. The injection occurs during the login flow before credential verification, so valid Cockpit or remote-host credentials are not required for the described attack path.

Pass validated values as separate process arguments through a non-shell execution API, and enforce strict allowlists for hostnames, usernames, and supported SSH options.

Treat all web-provided connection data as untrusted, prohibit shell-based command construction, test process-invocation boundaries, and operate the service with least privilege and restricted network exposure.

Find out what's already
exploitable in your codebase.