CVE-2025-61385: Pg8000 SQL Injection Vulnerability

HIGH
Advisory Identifier: GHSA-wq2g-r956-j8cc
CWE-89
Published
Advisory Summary

CVE-2025-61385 is a HIGH sql injection vulnerability (CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')) affecting Pg8000 libraries in the PyPI ecosystem. The issue involves pg8000 sql injection vulnerability via a specially crafted python list input. Remediation is available by upgrading affected packages to version 1.31.5.

CVE-2025-61385 at a Glance

CVE Identifier CVE-2025-61385
GHSA Identifier GHSA-wq2g-r956-j8cc
Severity HIGH
CVSS v3.1 Base Score N/A
CWE Classification CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
Affected Product Pg8000
Package Ecosystem PyPI
Published Date
Last Updated

How to Fix CVE-2025-61385

To remediate this vulnerability, upgrade all affected Pg8000 dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

pg8000 fixed: 1.31.5
pip install pg8000>=1.31.5
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

pip show pg8000

How to Check if You Are Affected

To determine whether your Python environment is affected by CVE-2025-61385, inspect your installed packages using pip:

pip show pg8000

Analyze the terminal output to locate any version of Pg8000 in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.31.5), your application is affected.

Note: The pip show pg8000 command checks currently installed packages in your active Python environment.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection'), where the product constructs all or part of an sql command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended sql command when it is sent to a downstream component. without sufficient removal or quoting of sql syntax in user-controllable inputs, the generated sql query can cause those inputs to be interpreted as sql instead of ordinary user data. In Pg8000, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

SQL injection vulnerability in tlocke pg8000 1.31.4 allows remote attackers to execute arbitrary SQL commands via a specially crafted Python list input to function pg8000.native.literal.

CVE-2025-61385 Affected Pg8000 Versions

1 component(s)
Fixed Versions:
1.31.5
Product / Package Ecosystem Affected Versions Fixed Version
pg8000
PyPI
< 1.31.5
1.31.5

References

Frequently Asked Questions

What is CVE-2025-61385?
CVE-2025-61385 is a security vulnerability in Pg8000 involving pg8000 SQL injection vulnerability via a specially crafted Python list input under CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection').
Which Pg8000 versions are affected?
Affected versions include releases prior to 1.31.5 across affected packages: pg8000.
What version fixes CVE-2025-61385?
Upgrading to 1.31.5 (or the latest patched release for your respective branch) resolves the vulnerability.
Is pg8000 affected?
Yes, pg8000 is affected in releases prior to 1.31.5. Upgrade your dependency to 1.31.5 or later.
What CWE is associated with CVE-2025-61385?
CVE-2025-61385 is classified under CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') (The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component. Without sufficient removal or quoting of SQL syntax in user-controllable inputs, the generated SQL query can cause those inputs to be interpreted as SQL instead of ordinary user data.).
How can I check PyPI dependencies for CVE-2025-61385?
Run the dependency tree command: 'pip show pg8000'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-wq2g-r956-j8cc",
  "modified" : "2025-10-27T23:17:04Z",
  "published" : "2025-10-27T18:31:13Z",
  "aliases" : [ "CVE-2025-61385" ],
  "summary" : "pg8000 SQL injection vulnerability via a specially crafted Python list input",
  "details" : "SQL injection vulnerability in tlocke pg8000 1.31.4 allows remote attackers to execute arbitrary SQL commands via a specially crafted Python list input to function pg8000.native.literal.",
  "severity" : [ {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N/E:U"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "pg8000"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.31.5"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 1.31.4"
    }
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2025-61385"
  }, {
    "type" : "PACKAGE",
    "url" : "https://codeberg.org/tlocke/pg8000"
  }, {
    "type" : "WEB",
    "url" : "https://codeberg.org/tlocke/pg8000/commit/8663c746b02286c32f19c385f0e2e5da9e4fa140"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/bmcyver/vulnerability-research/tree/main/CVE-2025-61385"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-89" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2025-10-27T23:17:04Z",
    "nvd_published_at" : "2025-10-27T18:15:43Z"
  }
}