CVE-2023-22727: CakePHP Database\\Query SQL Injection Vulnerability
CRITICALCVE-2023-22727 is a CRITICAL (CVSS 9.8) sql injection vulnerability (CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')) affecting CakePHP Database\\Query libraries in the Packagist ecosystem. The issue involves :offset() and limit() methods are vulnerable to sql injection. Remediation is available by upgrading affected packages to version 4.2.12, 4.3.11, 4.4.10.
CVE-2023-22727 at a Glance
Security Impact
CVSS: 9.8
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H).
How to Fix CVE-2023-22727
To remediate this vulnerability, upgrade all affected CakePHP Database\\Query 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 cakephp/cakephp to 4.2.12
Upgrade cakephp/cakephp to 4.3.11
Upgrade cakephp/cakephp to 4.4.10
Upgrade cakephp/database to 4.2.12
Upgrade cakephp/database to 4.3.11
Upgrade cakephp/database to 4.4.10
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
inspect dependencies for cakephp/cakephp
How to Check if You Are Affected
To determine whether your application is affected by CVE-2023-22727, inspect your project dependencies for CakePHP Database\\Query:
inspect dependencies for cakephp/cakephp
Analyze the terminal output to locate any version of CakePHP Database\\Query in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 4.2.12), 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 CakePHP Database\\Query, 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-2023-22727 Affected CakePHP Database\\Query Versions
6 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
cakephp/cakephp
|
Packagist |
≥ 4.2.0
< 4.2.12
|
4.2.12
|
|
cakephp/cakephp
|
Packagist |
≥ 4.3.0
< 4.3.11
|
4.3.11
|
|
cakephp/cakephp
|
Packagist |
≥ 4.4.0
< 4.4.10
|
4.4.10
|
|
cakephp/database
|
Packagist |
≥ 4.2.0
< 4.2.12
|
4.2.12
|
|
cakephp/database
|
Packagist |
≥ 4.3.0
< 4.3.11
|
4.3.11
|
|
cakephp/database
|
Packagist |
≥ 4.4.0
< 4.4.10
|
4.4.10
|
References
Frequently Asked Questions
What is CVE-2023-22727?
Which CakePHP Database\\Query versions are affected?
What version fixes CVE-2023-22727?
Is cakephp/cakephp affected?
Is cakephp/database affected?
What is the CVSS score of CVE-2023-22727?
What CWE is associated with CVE-2023-22727?
How can I check Packagist dependencies for CVE-2023-22727?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-6g8q-qfpv-57wp",
"modified" : "2023-01-25T16:09:33Z",
"published" : "2023-01-20T17:30:20Z",
"aliases" : [ "CVE-2023-22727" ],
"summary" : "CakePHP Database\\\\Query::offset() and limit() methods are vulnerable to SQL injection",
"details" : "### Impact\n\nThe `Cake\\Database\\Query::limit()` and `Cake\\Database\\Query::offset()` methods are vulnerable to SQL injection if passed un-sanitized user request data.\n\n### Patches\nThis issue has been fixed in 4.2.12, 4.3.11, 4.4.10\n\n### Workarounds\n\nUsing CakePHP's Pagination library will mitigate this issue, as will validating or casting parameters to these methods.\n\n### References\n\nhttps://bakery.cakephp.org/2023/01/06/cakephp_4211_4311_4410_released.html\n",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "Packagist",
"name" : "cakephp/cakephp"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "4.2.0"
}, {
"fixed" : "4.2.12"
} ]
} ]
}, {
"package" : {
"ecosystem" : "Packagist",
"name" : "cakephp/cakephp"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "4.3.0"
}, {
"fixed" : "4.3.11"
} ]
} ]
}, {
"package" : {
"ecosystem" : "Packagist",
"name" : "cakephp/cakephp"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "4.4.0"
}, {
"fixed" : "4.4.10"
} ]
} ]
}, {
"package" : {
"ecosystem" : "Packagist",
"name" : "cakephp/database"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "4.2.0"
}, {
"fixed" : "4.2.12"
} ]
} ]
}, {
"package" : {
"ecosystem" : "Packagist",
"name" : "cakephp/database"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "4.3.0"
}, {
"fixed" : "4.3.11"
} ]
} ]
}, {
"package" : {
"ecosystem" : "Packagist",
"name" : "cakephp/database"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "4.4.0"
}, {
"fixed" : "4.4.10"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/cakephp/cakephp/security/advisories/GHSA-6g8q-qfpv-57wp"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2023-22727"
}, {
"type" : "WEB",
"url" : "https://github.com/cakephp/cakephp/commit/3f463e7084b5a15e67205ced3a622577cca7a239"
}, {
"type" : "WEB",
"url" : "https://bakery.cakephp.org/2023/01/06/cakephp_4211_4311_4410_released.html"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/cakephp/cakephp"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-89" ],
"severity" : "CRITICAL",
"github_reviewed" : true,
"github_reviewed_at" : "2023-01-20T17:30:20Z",
"nvd_published_at" : "2023-01-17T21:15:00Z"
}
}