Critical SQL Injection Vulnerability in PHP Packages: CVE-2022-31631

php5 Updated 02 Oct 2025

Summary

05/01/2023
N/A
No i
Critical
9.1

UBUNTU-CVE-2022-31631: In PHP versions 8.0.* before 8.0.27, 8.1.* before 8.1.15, 8.2.* before 8.2.2 when using PDO::quote() function to quote user-supplied data for SQLite, supplying an overly long string may cause the driver to incorrectly qu... Affects php5 versions 5.5.3+dfsg-1ubuntu2 – 5.5.9+dfsg-1ubuntu4.9. No fix is published. How to fix ↓

Free scan

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.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored Devnack Your last release was probably never penetration tested Manual testing by engineers who build software, not an auditor's checklist. Trusted by teams at Swift and Google Talk to Devnack

Background

PHP is a widely-used open-source scripting language designed for web development but also used as a general-purpose programming language. It is known for its ease of integration with HTML and databases, making it a popular choice for building dynamic web applications. The vulnerability in question affects multiple versions of PHP packages, specifically those utilizing the PDO::quote() function for SQLite. This vulnerability allows for the potential exploitation of SQL injection attacks, which can compromise the integrity and security of applications relying on these packages.

Vulnerability Detail

In PHP versions 8.0.* before 8.0.27, 8.1.* before 8.1.15, and 8.2.* before 8.2.2, a flaw exists in the PDO::quote() function. When this function is used to quote user-supplied data for SQLite, an overly long string can lead to incorrect quoting of the data. This misquoting can result in SQL injection vulnerabilities, allowing attackers to manipulate SQL queries and potentially gain unauthorized access to sensitive data or execute arbitrary SQL commands.

How To Fix

No fixed version is published for this vulnerability.

Tip — Not sure whether your app is affected? Vulert can check the versions your app actually runs. Scan free →

Workaround

As a temporary workaround, developers can validate and sanitize user input before passing it to the PDO::quote() function. This can be done by limiting the length of the input string or using prepared statements with bound parameters, which can help mitigate the risk of SQL injection. Example code for using prepared statements:

$pdo = new PDO('sqlite:my_database.db');
$stmt = $pdo->prepare('SELECT * FROM users WHERE username = :username');
$stmt->bindParam(':username', $username);
$stmt->execute();

Conclusion

CVE-2022-31631 is a critical vulnerability affecting multiple PHP packages, allowing for SQL injection through improper data handling. It is crucial to update to the patched versions of PHP to secure applications against potential attacks. Additionally, implementing best practices for input validation can provide further protection.

See every vulnerability recorded for php5 →

Share this vulnerability

FAQ

CVE-2022-31631 is a critical vulnerability in PHP that allows for SQL injection through improper handling of user-supplied data in the PDO::quote() function.

The vulnerability affects PHP versions 8.0.* before 8.0.27, 8.1.* before 8.1.15, and 8.2.* before 8.2.2.

You can use Vulert, which monitors open-source vulnerabilities in your software. Simply upload your manifest file like package-lock.json to check for vulnerabilities.

Exploitation of this vulnerability can lead to unauthorized access to sensitive data, data manipulation, and execution of arbitrary SQL commands, compromising application security.

Yes, you can implement input validation and use prepared statements with bound parameters to reduce the risk of SQL injection attacks.

Related vulnerabilities

Recent vulnerabilities recorded for php5.

How To Fix

No fixed version is published for this vulnerability.

Tip — Not sure whether your app is affected? Vulert can check the versions your app actually runs. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback