PHPApplication

CVE-2022-31631

CRITICAL · 9.1 CVSS v3.1 Published 2025-02-12
Fix available
A fix is available. Upgrade to 8.0.27 / 8.1.15 or later.
See remediation →
100/100
Remediation priority · Urgent
Remotely reachable No privileges Zero-click

Official description Straight from the sourceThe vendor's or NVD's own wording, published unedited. Authoritative, but often terse — it says what broke, rarely what to do.

NVD · unedited
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 quote the data, which may further lead to SQL injection vulnerabilities.

Technical summary Written by usOur analysis, written from the advisory, the CVSS vector and the affected-version data. It adds context the advisory leaves out, and never invents facts that are not in the source.

dbcve analysis · high confidence

In PHP versions 8.0.x before 8.0.27, 8.1.x before 8.1.15, and 8.2.x before 8.2.2, the PDO::quote() function incorrectly handles overly long strings when quoting user-supplied data for SQLite databases, potentially leading to SQL injection vulnerabilities.

MitigationUpgrade PHP to version 8.0.27, 8.1.15, or 8.2.2 or later. As a temporary mitigation, replace PDO::quote() calls with parameterized queries/prepared statements.

Verify against the referenced sources before acting — the references below are authoritative for this CVE, this summary is not.

Affected products & versions What the vendor confirmedThe version ranges the vendor confirmed as vulnerable. If your version sits inside a range here, treat yourself as exposed until you have upgraded.

NVD · CPE data
PHPApplication
Affected:>= 8.0.0, < 8.0.27>= 8.1.0, < 8.1.15>= 8.2.0, < 8.2.2

CVSS breakdown How the score is builtThe industry scoring standard. It rates how the flaw is reached, what it takes to exploit, and what an attacker gains — the score is derived from those, not the other way round.

From the vector
Attack vector
Network
Complexity
Low
Privileges
None
User interaction
None
Scope
Unchanged
Confidentiality
High
Integrity
High
Availability
None

CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N

Am I affected? How to checkSteps we derive from the advisory and the affected-version data, so you can decide whether this CVE reaches your setup. They are a guide, not a scan — your own configuration is the authority.

dbcve checks

Work through these to decide whether this CVE applies to you.

  1. Check installed PHP version
    Run `php -v` on the command line or view phpinfo() output to determine the exact PHP version
    Affected if Version is 8.0.x before 8.0.27, 8.1.x before 8.1.15, or 8.2.x before 8.2.2
  2. Verify PDO SQLite extension is loaded
    Run `php -m` and look for PDO and pdo_sqlite modules, or check phpinfo() for PDO drivers section
    Affected if PDO driver for SQLite is present and loaded
  3. Identify SQLite database connections
    Search configuration files and application code for SQLite DSN strings containing 'sqlite:' or file paths to .db/.sqlite files used with PDO
    Affected if Application uses PDO to connect to SQLite databases
  4. Check for PDO::quote() usage with SQLite
    Search application source code for calls to PDO::quote() method, particularly in files that handle SQLite database operations
    Affected if Code calls PDO::quote() to escape user input when interacting with SQLite databases

You are affected if your PHP version is in the vulnerable range (8.0.x < 8.0.27, 8.1.x < 8.1.15, or 8.2.x < 8.2.2) AND your application uses PDO::quote() to escape user input for SQLite databases.

Generated from the published advisory. Verify against your own configuration.

Check your environment

Paste your version and any relevant configuration and it will be compared against the affected criteria above. Do not include secrets or credentials.

AI-assisted, checked against the advisory. Informational, not a guarantee.

Remediation Closing itWhat it takes to close this. Where a vendor fix exists we point at it; where none exists we say so plainly, and can build one. Effort estimates are scoped from the advisory, not from your codebase.

dbcve · scoped
Upgrade available Upgrade to 8.0.27 / 8.1.15 / 8.2.2 or later
Fixed in 8.0.278.1.158.2.2
Interim mitigation

Upgrade PHP to version 8.0.27, 8.1.15, or 8.2.2 or later. As a temporary mitigation, replace PDO::quote() calls with parameterized queries/prepared statements.

Recommended fix High confidence

PHP 8.0.27 (or latest 8.0.x), 8.1.15 (or latest 8.1.x), or 8.2.2 (or latest 8.2.x) depending on your current branch

  1. Check current PHP version by running 'php -v' on the server
  2. Identify which PHP 8.x branch is currently in use (8.0.x, 8.1.x, or 8.2.x)
  3. Update PHP to the minimum fixed version for your branch: 8.0.27, 8.1.15, or 8.2.2 respectively (or latest stable in the branch)
  4. For Ubuntu/Debian: run 'sudo apt update && sudo apt install php*' or specific version with 'sudo apt install php8.x'
  5. For RHEL/CentOS: run 'sudo yum update php' or 'sudo dnf update php'
  6. For Docker: update the PHP base image tag in your Dockerfile (e.g., change 'php:8.1' to 'php:8.1.15' or 'php:8.1.20')
  7. Verify the upgrade was successful by running 'php -v'
  8. Test application functionality, specifically any code using PDO::quote() with SQLite databases
Caveat Minor PHP upgrades typically have minimal breaking changes but review PHP 8.0/8.1/8.2 changelogs for any deprecation warnings or behavioral changes relevant to your application before deploying to production

Generated from the published advisory — verify against the referenced sources before acting.

Fix this in PHP Scoped from the published advisory
  • Consultation4.0 h
  • Implementation8.0 h
  • Testing6.0 h
  • Review / QA3.0 h
21.0 hours of engineering $3,680
Get the upgrade done

An estimate, not a bill — we confirm scope with you before any work starts. Need it this week? Rush from $5,888.

Scan for this in your stack

Free · runs locally
dbcve dependency scanner

Check whether your project pulls in CVE-2022-31631 — or any other known-vulnerable package — straight from your lock files. Free and open source; it runs locally and uploads nothing.

References Go to the primary sourcePrimary sources — vendor advisories, patches and trackers. Where our summary and a reference disagree, the reference wins.

Primary sources

Practitioner notes

Contributed

Peer-ranked notes from engineers who’ve handled CVE-2022-31631 in production — separate from our analysis above.

No notes yet

Be the first to add a field note for this CVE — a mitigation you’ve verified, a version caveat, or a link to a working fix. Sign in above to contribute.

What this is

A place for practitioners to share what actually worked: a mitigation you’ve tested, a configuration change, a version- or environment-specific caveat, or a link to a verified patch. The most useful notes rise to the top as peers upvote them, so the signal stays high.

What belongs here
  • Verified mitigations, workarounds, and config changes
  • Version or environment caveats, and links to real fixes
  • No weaponised exploit code, or anything meant to cause harm
  • No spam, self-promotion, credentials, or personal data