CVE-2021-21263: Laravel/framework Query Binding Exploitation Vulnerability

HIGH
Advisory Identifier: GHSA-3p32-j457-pg5x
CVSS 7.2
CWE-89 CWE-74
Published
Advisory Summary

CVE-2021-21263 is a HIGH (CVSS 7.2) query binding exploitation vulnerability (CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')) affecting Laravel/framework libraries in the Packagist ecosystem. The issue involves query binding exploitation. Remediation is available by upgrading affected packages to version 8.22.1, 7.30.3, 6.20.12, 6.20.11, 7.30.2.

CVE-2021-21263 at a Glance

CVE Identifier CVE-2021-21263
GHSA Identifier GHSA-3p32-j457-pg5x
Severity HIGH
CVSS v3.1 Base Score 7.2
CWE Classification CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
Affected Product Laravel/framework
Package Ecosystem Packagist
Published Date
Last Updated

Security Impact

CVSS: 7.2

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:C/C:L/I:L/A:N).

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

How to Fix CVE-2021-21263

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

laravel/framework fixed: 8.22.1
Upgrade laravel/framework to 8.22.1
illuminate/database fixed: 7.30.3
Upgrade illuminate/database to 7.30.3
illuminate/database fixed: 8.22.1
Upgrade illuminate/database to 8.22.1
illuminate/database fixed: 6.20.12
Upgrade illuminate/database to 6.20.12
laravel/framework fixed: 6.20.11
Upgrade laravel/framework to 6.20.11
laravel/framework fixed: 7.30.2
Upgrade laravel/framework to 7.30.2
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 laravel/framework

How to Check if You Are Affected

To determine whether your application is affected by CVE-2021-21263, inspect your project dependencies for Laravel/framework:

inspect dependencies for laravel/framework

Analyze the terminal output to locate any version of Laravel/framework in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 8.22.1), 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 Laravel/framework, 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

### Description Laravel versions <6.20.12, <7.30.3 & <8.22.1 contain a query binding exploitation. If a request is crafted where a field that is normally a non-array value is an array, and that input is not validated or cast to its expected type before being passed to the query builder, an unexpected number of query bindings can be added to the query. In some situations, this will simply lead to no results being returned by the query builder; however, it is possible certain queries could be affected in a way that causes the query to return unexpected results. This vulnerability was discovered by Tim Groenevelt (tim.g@foodbyus.com). ### References - https://github.com/laravel/framework/pull/35865

CVE-2021-21263 Affected Laravel/framework Versions

6 component(s)
Fixed Versions:
8.22.17.30.36.20.126.20.117.30.2
Product / Package Ecosystem Affected Versions Fixed Version
laravel/framework
Packagist
≥ 8.0.0
< 8.22.1
8.22.1
illuminate/database
Packagist
≥ 7.0.0
< 7.30.3
7.30.3
illuminate/database
Packagist
≥ 8.0.0
< 8.22.1
8.22.1
illuminate/database
Packagist
≥ 6.0.0
< 6.20.12
6.20.12
laravel/framework
Packagist
≥ 6.0.0
< 6.20.11
6.20.11
laravel/framework
Packagist
≥ 7.0.0
< 7.30.2
7.30.2

References

Frequently Asked Questions

What is CVE-2021-21263?
CVE-2021-21263 is a security vulnerability in Laravel/framework involving Query Binding Exploitation under CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection').
Which Laravel/framework versions are affected?
Affected versions include releases prior to 8.22.1, 7.30.3, 6.20.12, 6.20.11, 7.30.2 across affected packages: laravel/framework, illuminate/database.
What version fixes CVE-2021-21263?
Upgrading to 8.22.1, 7.30.3, 6.20.12, 6.20.11, 7.30.2 (or the latest patched release for your respective branch) resolves the vulnerability.
Is laravel/framework affected?
Yes, laravel/framework is affected in releases prior to 8.22.1, 6.20.11, 7.30.2. Upgrade your dependency to 8.22.1, 6.20.11, 7.30.2 or later.
Is illuminate/database affected?
Yes, illuminate/database is affected in releases prior to 7.30.3, 8.22.1, 6.20.12. Upgrade your dependency to 7.30.3, 8.22.1, 6.20.12 or later.
What is the CVSS score of CVE-2021-21263?
CVE-2021-21263 has a CVSS v3.1 base score of 7.2 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:L/I:L/A:N.
What CWE is associated with CVE-2021-21263?
CVE-2021-21263 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-2021-21263?
Run the dependency tree command: 'inspect dependencies for laravel/framework'. 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-3p32-j457-pg5x",
  "modified" : "2021-03-29T17:41:17Z",
  "published" : "2021-01-19T19:36:51Z",
  "aliases" : [ "CVE-2021-21263" ],
  "summary" : "Query Binding Exploitation",
  "details" : "### Description\n\nLaravel versions <6.20.12, <7.30.3 & <8.22.1 contain a query binding exploitation.\n\nIf a request is crafted where a field that is normally a non-array value is an array, and that input is not validated or cast to its expected type before being passed to the query builder, an unexpected number of query bindings can be added to the query. In some situations, this will simply lead to no results being returned by the query builder; however, it is possible certain queries could be affected in a way that causes the query to return unexpected results.\n\nThis vulnerability was discovered by Tim Groenevelt (tim.g@foodbyus.com).\n\n### References\n\n- https://github.com/laravel/framework/pull/35865",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:L/I:L/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Packagist",
      "name" : "laravel/framework"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "8.0.0"
      }, {
        "fixed" : "8.22.1"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "Packagist",
      "name" : "illuminate/database"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "7.0.0"
      }, {
        "fixed" : "7.30.3"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "Packagist",
      "name" : "illuminate/database"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "8.0.0"
      }, {
        "fixed" : "8.22.1"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "Packagist",
      "name" : "illuminate/database"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "6.0.0"
      }, {
        "fixed" : "6.20.12"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "Packagist",
      "name" : "laravel/framework"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "6.0.0"
      }, {
        "fixed" : "6.20.11"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "Packagist",
      "name" : "laravel/framework"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "7.0.0"
      }, {
        "fixed" : "7.30.2"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/laravel/framework/security/advisories/GHSA-3p32-j457-pg5x"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-21263"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/laravel/framework/pull/35865"
  }, {
    "type" : "WEB",
    "url" : "https://blog.laravel.com/security-laravel-62011-7302-8221-released"
  }, {
    "type" : "WEB",
    "url" : "https://blog.laravel.com/security-laravel-62012-7303-released"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/FriendsOfPHP/security-advisories/blob/master/illuminate/database/CVE-2021-21263.yaml"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/FriendsOfPHP/security-advisories/blob/master/laravel/framework/CVE-2021-21263.yaml"
  }, {
    "type" : "WEB",
    "url" : "https://packagist.org/packages/illuminate/database"
  }, {
    "type" : "WEB",
    "url" : "https://packagist.org/packages/laravel/framework"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-74", "CWE-89" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2021-01-19T19:36:31Z",
    "nvd_published_at" : "2021-01-19T20:15:00Z"
  }
}