# CVE-2021-21263: Query Binding Exploitation in Laravel

> Attackers can manipulate query bindings by passing arrays instead of expected types, potentially causing SQL queries to return unexpected results.

- **Severity:** High 7.2 (`CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:L/I:L/A:N`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 19 Jan 2021
- **Updated:** 3 Aug 2024
- **Also known as:** BIT-laravel-2021-21263, CLSA-2026-1774486145, DEBIAN-CVE-2021-21263, GHSA-3p32-j457-pg5x

## What is CVE-2021-21263?

CVE-2021-21263 is a high-severity SQL injection vulnerability in laravel framework, published on 19 Jan 2021. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

Laravel is a web application framework. Versions of Laravel before 6.20.11, 7.30.2 and 8.22.1 contain a query binding exploitation. This same exploit applies to the illuminate/database package which is used by Laravel. 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.

Weakness: CWE-89 (Improper Neutralization of Special Elements used in an SQL Command), CWE-74 (Improper Neutralization of Special Elements in Output Used by a Downstream Component)

## Which versions are affected by CVE-2021-21263?

13 open source packages ship an affected version, including laravel/framework, laravel and illuminate/database. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `laravel/framework` | Packagist | From 6.0.0 | 6.20.11 |
| `laravel/framework` | Packagist | From 6.0.0 | 6.20.11 |
| `laravel/framework` | Packagist | From 7.0.0 | 7.30.2 |
| `laravel/framework` | Packagist | From 7.0.0 | 7.30.2 |
| `laravel/framework` | Packagist | From 8.0.0 | 8.22.1 |
| `laravel/framework` | Packagist | From 8.0.0 | 8.22.1 |
| `laravel` | Bitnami | From 6.0.0 | 6.20.11, 7.30.2, 8.22.1 |
| `illuminate/database` | Packagist | From 6.0.0 | 6.20.12 |
| `illuminate/database` | Packagist | From 6.0.0 | 6.20.12 |
| `illuminate/database` | Packagist | From 7.0.0 | 7.30.3 |
| `illuminate/database` | Packagist | From 7.0.0 | 7.30.3 |
| `illuminate/database` | Packagist | From 8.0.0 | 8.22.1 |
| `illuminate/database` | Packagist | From 8.0.0 | 8.22.1 |

Products: Laravel Laravel.

## How do I fix CVE-2021-21263?

Upgrade laravel/framework to a fixed version for your release line: 6.20.11, 7.30.2 or 8.22.1.

## Is CVE-2021-21263 being exploited?

There is no known exploitation of CVE-2021-21263 in the wild and no public exploit code.

## Other vulnerabilities in laravel framework

- [CVE-2018-15133](https://insights.sbomify.com/CVE-2018-15133/): Laravel Deserialization of Untrusted Data (high 8.1, exploited in the wild)
- [CVE-2021-28254](https://insights.sbomify.com/CVE-2021-28254/): Deserialization in n/a (critical 9.8)
- [CVE-2020-24940](https://insights.sbomify.com/CVE-2020-24940/): Guard bypass in Eloquent models affecting Laravel illuminate database component (high 7.5)
- [CVE-2020-24941](https://insights.sbomify.com/CVE-2020-24941/): Improper Input Validation in Laravel (high 7.5)
- [CVE-2017-16894](https://insights.sbomify.com/CVE-2017-16894/): Information disclosure in n/a (high 7.5)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2021-21263 and fix it if it is affected.

What it is: CVE-2021-21263 is a high-severity SQL injection vulnerability in laravel framework, published on 19 Jan 2021. An attacker can exploit it over the internet without logging in, with no action from the victim.
Exploitation: There is no known exploitation of CVE-2021-21263 in the wild and no public exploit code.

Affected packages and fixed versions:
- laravel/framework (Packagist): affected from 6.0.0; fixed in 6.20.11
- laravel/framework (Packagist): affected from 6.0.0; fixed in 6.20.11
- laravel/framework (Packagist): affected from 7.0.0; fixed in 7.30.2
- laravel/framework (Packagist): affected from 7.0.0; fixed in 7.30.2
- laravel/framework (Packagist): affected from 8.0.0; fixed in 8.22.1
- laravel/framework (Packagist): affected from 8.0.0; fixed in 8.22.1
- laravel (Bitnami): affected from 6.0.0; fixed in 6.20.11, 7.30.2, 8.22.1
- illuminate/database (Packagist): affected from 6.0.0; fixed in 6.20.12
- illuminate/database (Packagist): affected from 6.0.0; fixed in 6.20.12
- illuminate/database (Packagist): affected from 7.0.0; fixed in 7.30.3
- illuminate/database (Packagist): affected from 7.0.0; fixed in 7.30.3
- illuminate/database (Packagist): affected from 8.0.0; fixed in 8.22.1

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2021-21263/ (Markdown: https://insights.sbomify.com/CVE-2021-21263/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2021-21263
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2021-21263
- OSV: https://osv.dev/vulnerability/CVE-2021-21263

---
From sbomify Insights: https://insights.sbomify.com/CVE-2021-21263/
Summaries are generated and may contain mistakes; the official description above is the record.
