Advisory Database
  • Advisories
  • Dependency Scanning
  1. nuget
  2. ›
  3. Npgsql
  4. ›
  5. CVE-2024-32655

CVE-2024-32655: Npgsql vulnerable to SQL Injection via Protocol Message Size Overflow

May 9, 2024 (updated December 12, 2024)

The WriteBind() method in src/Npgsql/Internal/NpgsqlConnector.FrontendMessages.cs uses int variables to store the message length and the sum of parameter lengths. Both variables overflow when the sum of parameter lengths becomes too large.

This causes Npgsql to write a message size that is too small when constructing a Postgres protocol message to send it over the network to the database. When parsing the message, the database will only read a small number of bytes and treat any following bytes as new messages while they belong to the old message.

Attackers can abuse this to inject arbitrary Postgres protocol messages into the connection, leading to the execution of arbitrary SQL statements on the application’s behalf.

References

  • github.com/advisories/GHSA-x9vc-6hfv-hg8c
  • github.com/npgsql/npgsql
  • github.com/npgsql/npgsql/commit/091655eed0c84e502ab424950c930339d17c1928
  • github.com/npgsql/npgsql/commit/3183efb2bdcca159c8c2e22af57e18ea8f853cf0
  • github.com/npgsql/npgsql/commit/67acbe027e28477ac2199e15cfb554bb2ffaf169
  • github.com/npgsql/npgsql/commit/703d9af8fa48dfe8c0180e36edb8278f34342d7b
  • github.com/npgsql/npgsql/commit/a22a42d8141d7a3528f43c02c095a409507cf1af
  • github.com/npgsql/npgsql/commit/e34e2ba8042e666d9af54a1b255fba4d5b11df56
  • github.com/npgsql/npgsql/commit/f7e7ead0702d776a8f551f5786c4cac2d65c4bc6
  • github.com/npgsql/npgsql/files/14309386/Npgsql.Security.Advisory.pdf
  • github.com/npgsql/npgsql/files/14309397/npgsql-protocol-overflow-poc.zip
  • github.com/npgsql/npgsql/releases/tag/v4.0.14
  • github.com/npgsql/npgsql/releases/tag/v4.1.13
  • github.com/npgsql/npgsql/releases/tag/v5.0.18
  • github.com/npgsql/npgsql/releases/tag/v6.0.11
  • github.com/npgsql/npgsql/releases/tag/v7.0.7
  • github.com/npgsql/npgsql/releases/tag/v8.0.3
  • github.com/npgsql/npgsql/security/advisories/GHSA-x9vc-6hfv-hg8c
  • nvd.nist.gov/vuln/detail/CVE-2024-32655
  • www.youtube.com/watch?v=Tfg1B8u1yvE

Code Behaviors & Features

Detect and mitigate CVE-2024-32655 with GitLab Dependency Scanning

Secure your software supply chain by verifying that all open source dependencies used in your projects contain no disclosed vulnerabilities. Learn more about Dependency Scanning →

Affected versions

All versions before 4.0.14, all versions starting from 4.1.0 before 4.1.13, all versions starting from 5.0.0 before 5.0.18, all versions starting from 6.0.0 before 6.0.11, all versions starting from 7.0.0 before 7.0.7, all versions starting from 8.0.0 before 8.0.3

Fixed versions

  • 8.0.3
  • 4.0.14
  • 4.1.13
  • 5.0.18
  • 6.0.11
  • 7.0.7

Solution

Upgrade to versions 4.0.14, 4.1.13, 5.0.18, 6.0.11, 7.0.7, 8.0.3 or above.

Impact 8.1 HIGH

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

Learn more about CVSS

Weakness

  • CWE-190: Integer Overflow or Wraparound
  • CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')

Source file

nuget/Npgsql/CVE-2024-32655.yml

Spotted a mistake? Edit the file on GitLab.

  • Site Repo
  • About GitLab
  • Terms
  • Privacy Statement
  • Contact

Page generated Wed, 14 May 2025 12:15:22 +0000.