# GHSA-4mg9-vhxq-vm7j: SQL Server LIMIT / OFFSET SQL Injection in laravel/framework and illuminate/database

> SQL injection vulnerability in Laravel when using SQL Server with user-controlled limit and offset parameters, allowing unauthorized database access.

- **Severity:** Not scored
- **Exploited in the wild:** Not known
- **Login needed:** Not stated
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 29 Apr 2021

## What is GHSA-4mg9-vhxq-vm7j?

GHSA-4mg9-vhxq-vm7j is a SQL injection vulnerability in illuminate/database, published on 29 Apr 2021. It can be exploited over the network, with no action from the victim.

### Official description

### Impact

Those using SQL Server with Laravel and allowing user input to be passed directly to the `limit` and `offset` functions are vulnerable to SQL injection. Other database drivers such as MySQL and Postgres are not affected by this vulnerability.

### Patches

This problem has been patched on Laravel versions 6.20.26, 7.30.5, and 8.40.0.

### Workarounds

You may workaround this vulnerability by ensuring that only integers are passed to the `limit` and `offset` functions, as well as the `skip` and `take` functions.

## Which versions are affected by GHSA-4mg9-vhxq-vm7j?

8 open source packages ship an affected version, including illuminate/database and laravel/framework.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `illuminate/database` | Packagist | All versions | 6.20.26 |
| `illuminate/database` | Packagist | All versions | 6.20.26 |
| `illuminate/database` | Packagist | From 8.0.0 | 8.40.0 |
| `illuminate/database` | Packagist | From 8.0.0 | 8.40.0 |
| `laravel/framework` | Packagist | All versions | 6.20.26 |
| `laravel/framework` | Packagist | All versions | 6.20.26 |
| `laravel/framework` | Packagist | From 8.0.0 | 8.40.0 |
| `laravel/framework` | Packagist | From 8.0.0 | 8.40.0 |

## How do I fix GHSA-4mg9-vhxq-vm7j?

Upgrade illuminate/database to a fixed version for your release line: 6.20.26 or 8.40.0.

## Is GHSA-4mg9-vhxq-vm7j being exploited?

There is no known exploitation of GHSA-4mg9-vhxq-vm7j in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-4mg9-vhxq-vm7j and fix it if it is affected.

What it is: GHSA-4mg9-vhxq-vm7j is a SQL injection vulnerability in illuminate/database, published on 29 Apr 2021. It can be exploited over the network, with no action from the victim.
Exploitation: There is no known exploitation of GHSA-4mg9-vhxq-vm7j in the wild and no public exploit code.

Affected packages and fixed versions:
- illuminate/database (Packagist): affected all versions; fixed in 6.20.26
- illuminate/database (Packagist): affected all versions; fixed in 6.20.26
- illuminate/database (Packagist): affected from 8.0.0; fixed in 8.40.0
- illuminate/database (Packagist): affected from 8.0.0; fixed in 8.40.0
- laravel/framework (Packagist): affected all versions; fixed in 6.20.26
- laravel/framework (Packagist): affected all versions; fixed in 6.20.26
- laravel/framework (Packagist): affected from 8.0.0; fixed in 8.40.0
- laravel/framework (Packagist): affected from 8.0.0; fixed in 8.40.0

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/GHSA-4mg9-vhxq-vm7j/ (Markdown: https://insights.sbomify.com/GHSA-4mg9-vhxq-vm7j/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-4mg9-vhxq-vm7j

---
From sbomify Insights: https://insights.sbomify.com/GHSA-4mg9-vhxq-vm7j/
Summaries are generated and may contain mistakes; the official description above is the record.
