CVE-2026-31891: Cockpit hq/cockpit SQL Injection Vulnerability

HIGH
Advisory Identifier: GHSA-7x5c-vfhj-9628
CVSS 7.7
CWE-89
Published
Advisory Summary

CVE-2026-31891 is a HIGH (CVSS 7.7) sql injection vulnerability (CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')) affecting Cockpit hq/cockpit libraries in the Packagist ecosystem. The issue involves cockpit cms has sql injection in mongolite aggregation optimizer via tojsonextractraw(). Remediation is available by upgrading affected packages to version 2.13.5.

CVE-2026-31891 at a Glance

CVE Identifier CVE-2026-31891
GHSA Identifier GHSA-7x5c-vfhj-9628
Severity HIGH
CVSS v3.1 Base Score 7.7
CWE Classification CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
Affected Product Cockpit hq/cockpit
Package Ecosystem Packagist
Published Date
Last Updated

Security Impact

CVSS: 7.7

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:N/A:N).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required Low (PR:L)
User Interaction None (UI:N)
Scope Changed (S:C)
Confidentiality High (C:H)
Integrity None (I:N)
Availability None (A:N)

How to Fix CVE-2026-31891

To remediate this vulnerability, upgrade all affected Cockpit hq/cockpit dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

cockpit-hq/cockpit fixed: 2.13.5
Upgrade cockpit-hq/cockpit to 2.13.5
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for cockpit-hq/cockpit

How to Check if You Are Affected

To determine whether your application is affected by CVE-2026-31891, inspect your project dependencies for Cockpit hq/cockpit:

inspect dependencies for cockpit-hq/cockpit

Analyze the terminal output to locate any version of Cockpit hq/cockpit in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 2.13.5), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection'), where the product constructs all or part of an sql command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended sql command when it is sent to a downstream component. without sufficient removal or quoting of sql syntax in user-controllable inputs, the generated sql query can cause those inputs to be interpreted as sql instead of ordinary user data. In Cockpit hq/cockpit, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### Impact This is a SQL Injection vulnerability in the MongoLite Aggregation Optimizer. Any Cockpit CMS instance running version **2.13.4 or earlier** with API access enabled is potentially affected. **Who is impacted:** - Any deployment where the `/api/content/aggregate/{model}` endpoint is publicly accessible or reachable by untrusted users. - Attackers in possession of a **valid read-only API key** (the lowest privilege level) can exploit this vulnerability — no admin access is required. **What an attacker can do:** - Inject arbitrary SQL via unsanitized field names in aggregation queries. - Bypass the `_state=1` published-content filter to access unpublished or restricted content. - Extract unauthorized data from the underlying SQLite content database. **Confidentiality impact is High.** Integrity and availability are not directly affected by this vulnerability. ### Patches This vulnerability has been **patched in version 2.13.5**. All users running Cockpit CMS version **2.13.4 or earlier** are strongly advised to upgrade to **2.13.5 or later** immediately. - https://github.com/Cockpit-HQ/Cockpit/releases/tag/2.13.5 The fix applies the same field-name sanitization introduced in v2.13.3 for `toJsonPath()` to the `toJsonExtractRaw()` method in `lib/MongoLite/Aggregation/Optimizer.php`, closing the injection vector in the Aggregation Optimizer.

CVE-2026-31891 Affected Cockpit hq/cockpit Versions

1 component(s)
Fixed Versions:
2.13.5
Product / Package Ecosystem Affected Versions Fixed Version
cockpit-hq/cockpit
Packagist
< 2.13.5
2.13.5

References

Frequently Asked Questions

What is CVE-2026-31891?
CVE-2026-31891 is a security vulnerability in Cockpit hq/cockpit involving Cockpit CMS has SQL Injection in MongoLite Aggregation Optimizer via toJsonExtractRaw() under CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection').
Which Cockpit hq/cockpit versions are affected?
Affected versions include releases prior to 2.13.5 across affected packages: cockpit-hq/cockpit.
What version fixes CVE-2026-31891?
Upgrading to 2.13.5 (or the latest patched release for your respective branch) resolves the vulnerability.
Is cockpit-hq/cockpit affected?
Yes, cockpit-hq/cockpit is affected in releases prior to 2.13.5. Upgrade your dependency to 2.13.5 or later.
What is the CVSS score of CVE-2026-31891?
CVE-2026-31891 has a CVSS v3.1 base score of 7.7 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:N/A:N.
What CWE is associated with CVE-2026-31891?
CVE-2026-31891 is classified under CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') (The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component. Without sufficient removal or quoting of SQL syntax in user-controllable inputs, the generated SQL query can cause those inputs to be interpreted as SQL instead of ordinary user data.).
How can I check Packagist dependencies for CVE-2026-31891?
Run the dependency tree command: 'inspect dependencies for cockpit-hq/cockpit'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-7x5c-vfhj-9628",
  "modified" : "2026-03-19T19:01:18Z",
  "published" : "2026-03-17T17:07:41Z",
  "aliases" : [ "CVE-2026-31891" ],
  "summary" : "Cockpit CMS has SQL Injection in MongoLite Aggregation Optimizer via toJsonExtractRaw() ",
  "details" : "### Impact\n\nThis is a SQL Injection vulnerability in the MongoLite Aggregation Optimizer.\n\nAny Cockpit CMS instance running version **2.13.4 or earlier** with API access enabled\nis potentially affected.\n\n**Who is impacted:**\n- Any deployment where the `/api/content/aggregate/{model}` endpoint is publicly\n  accessible or reachable by untrusted users.\n- Attackers in possession of a **valid read-only API key** (the lowest privilege level)\n  can exploit this vulnerability — no admin access is required.\n\n**What an attacker can do:**\n- Inject arbitrary SQL via unsanitized field names in aggregation queries.\n- Bypass the `_state=1` published-content filter to access unpublished or restricted content.\n- Extract unauthorized data from the underlying SQLite content database.\n\n**Confidentiality impact is High.** Integrity and availability are not directly affected\nby this vulnerability.\n\n### Patches\n\nThis vulnerability has been **patched in version 2.13.5**.\n\nAll users running Cockpit CMS version **2.13.4 or earlier** are strongly advised to\nupgrade to **2.13.5 or later** immediately.\n\n- https://github.com/Cockpit-HQ/Cockpit/releases/tag/2.13.5\n\nThe fix applies the same field-name sanitization introduced in v2.13.3 for `toJsonPath()`\nto the `toJsonExtractRaw()` method in `lib/MongoLite/Aggregation/Optimizer.php`,\nclosing the injection vector in the Aggregation Optimizer.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:N/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Packagist",
      "name" : "cockpit-hq/cockpit"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "2.13.5"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/Cockpit-HQ/Cockpit/security/advisories/GHSA-7x5c-vfhj-9628"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-31891"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/Cockpit-HQ/Cockpit"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/Cockpit-HQ/Cockpit/releases/tag/2.13.5"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-89" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-03-17T17:07:41Z",
    "nvd_published_at" : "2026-03-18T04:17:19Z"
  }
}