CVE-2026-31891: Cockpit hq/cockpit SQL Injection Vulnerability
HIGHCVE-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
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).
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.
Upgrade cockpit-hq/cockpit to 2.13.5
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
CVE-2026-31891 Affected Cockpit hq/cockpit Versions
1 component(s)| 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?
Which Cockpit hq/cockpit versions are affected?
What version fixes CVE-2026-31891?
Is cockpit-hq/cockpit affected?
What is the CVSS score of CVE-2026-31891?
What CWE is associated with CVE-2026-31891?
How can I check Packagist dependencies for CVE-2026-31891?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"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"
}
}