Vulnerabilities in pkg:pypi/pg-query

PACKAGE
Advisory Identifier: GHSA-vm3q-58wm-2r2x
Advisory Summary

CVE-2018-18482 is a HIGH (CVSS 6.5) libpg_query memory leak vulnerability (CWE-772: Missing Release of Resource after Effective Lifetime) affecting Pg query libraries in the PyPI ecosystem. The issue involves libpg_query memory leak. Remediation is available by upgrading affected packages to version 0.28.

1 Known Advisory Record(s)
Package Vulnerability Intelligence

pkg:pypi/pg-query

1 Known Advisory Record(s)

Vulnerability advisories affecting package pkg:pypi/pg-query. Select an advisory below to view technical details or fixes.

Advisory ID CVE / NVD Severity Summary
GHSA-vm3q-58wm-2r2x CVE-2018-18482 HIGH libpg_query memory leak

CVE-2018-18482 at a Glance

CVE Identifier CVE-2018-18482
GHSA Identifier GHSA-vm3q-58wm-2r2x
Severity HIGH
CVSS v3.1 Base Score 6.5
CWE Classification CWE-772: Missing Release of Resource after Effective Lifetime
Affected Product Pg query
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 6.5

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.0/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:H).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction Required (UI:R)
Scope Unchanged (S:U)
Confidentiality None (C:N)
Integrity None (I:N)
Availability High (A:H)

How to Fix CVE-2018-18482

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

pg-query fixed: 0.28
pip install pg-query>=0.28
pglast fixed: 0.28
pip install pglast>=0.28
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 pg-query

How to Check if You Are Affected

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

pip show pg-query

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

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

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-772: Missing Release of Resource after Effective Lifetime, where the product does not release a resource after its effective lifetime has ended, i.e., after the resource is no longer needed. In Pg query, 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

An issue was discovered in libpg_query 10-1.0.2. There is a memory leak in pg_query_raw_parse in pg_query_parse.c, which might lead to a denial of service.

CVE-2018-18482 Affected Pg query Versions

2 component(s)
Fixed Versions:
0.28
Product / Package Ecosystem Affected Versions Fixed Version
pg-query
PyPI
< 0.28
0.28
pglast
PyPI
< 0.28
0.28

References

Frequently Asked Questions

What is CVE-2018-18482?
CVE-2018-18482 is a security vulnerability in Pg query involving libpg_query memory leak under CWE-772: Missing Release of Resource after Effective Lifetime.
Which Pg query versions are affected?
Affected versions include releases prior to 0.28 across affected packages: pg-query, pglast.
What version fixes CVE-2018-18482?
Upgrading to 0.28 (or the latest patched release for your respective branch) resolves the vulnerability.
Is pg-query affected?
Yes, pg-query is affected in releases prior to 0.28. Upgrade your dependency to 0.28 or later.
Is pglast affected?
Yes, pglast is affected in releases prior to 0.28. Upgrade your dependency to 0.28 or later.
What is the CVSS score of CVE-2018-18482?
CVE-2018-18482 has a CVSS v3.1 base score of 6.5 (HIGH) with vector string CVSS:3.0/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:H.
What CWE is associated with CVE-2018-18482?
CVE-2018-18482 is classified under CWE-772: Missing Release of Resource after Effective Lifetime (The product does not release a resource after its effective lifetime has ended, i.e., after the resource is no longer needed.).
How can I check PyPI dependencies for CVE-2018-18482?
Run the dependency tree command: 'pip show pg-query'. 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-vm3q-58wm-2r2x",
  "modified" : "2024-11-26T18:14:48Z",
  "published" : "2022-05-13T01:50:42Z",
  "aliases" : [ "CVE-2018-18482" ],
  "summary" : "libpg_query memory leak",
  "details" : "An issue was discovered in libpg_query 10-1.0.2. There is a memory leak in pg_query_raw_parse in pg_query_parse.c, which might lead to a denial of service.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.0/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:H"
  }, {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:P/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "pg-query"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.28"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "pglast"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.28"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2018-18482"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/lfittl/libpg_query/issues/49"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/lelit/pglast"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/pypa/advisory-database/tree/main/vulns/pg-query/PYSEC-2018-154.yaml"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-772" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-11-22T20:22:50Z",
    "nvd_published_at" : "2018-10-18T18:29:00Z"
  }
}