SQL Injection Vulnerability in Laravel Framework
Summary
GHSA-wq8p-mqvg-2p5h: laravel framework SQL Injection via limit and offset functions. Affects laravel/framework across 3 version ranges.
>= 6.0.0, < 6.20.26
>= 7.0.0, < 7.30.5
>= 8.0.0, < 8.40.0
Fixed in 6.20.26, 7.30.5 or 8.40.0, depending on the release line you run. How to fix ↓
Check if this vulnerability affects your application
Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.
No signup required · Results in about 60 seconds
Background
The Laravel framework is a popular PHP framework used for developing web applications. It provides a robust set of tools and features for building secure and scalable applications. However, a vulnerability has been discovered in the framework that affects the SQL Server database driver. When user input is directly passed to the limit and offset functions, it can lead to SQL injection attacks. It's important to note that this vulnerability does not affect other database drivers such as MySQL and Postgres.
Vulnerability Detail
The SQL injection vulnerability in Laravel allows an attacker to manipulate the SQL queries executed by the application. By injecting malicious SQL code, an attacker can bypass authentication, access unauthorized data, modify or delete data, and potentially gain full control over the database. This vulnerability can have severe consequences for the confidentiality, integrity, and availability of the application and its data.
How To Fix
Fixed versions by release line
The minimum fixed version depends on the release line you run.
-
>= 6.0.0, < 6.20.266.20.26composer require laravel/framework:6.20.26 -
>= 7.0.0, < 7.30.57.30.5composer require laravel/framework:7.30.5 -
>= 8.0.0, < 8.40.08.40.0composer require laravel/framework:8.40.0
Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. Scan free →
Workaround
If you are unable to immediately update to the patched versions of Laravel, you can implement a workaround by ensuring that only integers are passed to the limit and offset functions, as well as the skip and take functions. This can be done by validating and sanitizing user input before using it in these functions. Here's an example of how to sanitize user input using Laravel's built-in validation:
$request->validate([
'limit' => 'integer',
'offset' => 'integer',
]);
$limit = (int) $request->input('limit');
$offset = (int) $request->input('offset');
$results = DB::table('table')
->limit($limit)
->offset($offset)
->get();
Conclusion
The SQL injection vulnerability in the Laravel framework can have serious consequences for the security and integrity of your application. It is crucial to update to the patched versions of Laravel or implement the provided workaround to mitigate the risk. If you need further assistance or support in addressing this vulnerability, please contact DevNack.com.
See every vulnerability recorded for laravel/framework →
FAQ
The vulnerability allows attackers to execute arbitrary SQL queries, potentially bypassing authentication, accessing unauthorized data, modifying or deleting data, and gaining control over the database.
The vulnerability affects Laravel versions 6.x, 7.x, and 8.x. However, only those using the SQL Server database driver are vulnerable. MySQL and Postgres database drivers are not affected.
At the time of this advisory, there are no known public exploits specifically targeting this vulnerability. However, it is important to patch or implement the workaround as soon as possible to mitigate the risk.
No, there is no CVE assigned to this vulnerability at the moment.
You can use the Vulert Playground (https://vulert.com/scanner) to check if your application is affected by this vulnerability. Simply upload your composer.lock file to the playground, and it will analyze the dependencies and alert you if any vulnerabilities are found.
References
Related vulnerabilities
Recent vulnerabilities recorded for laravel/framework.