CVE-2024-32655
High · 8.1CVSS
8.1
EPSS
1.7%
Published
May 14, 2024
CISA due date
—
Cloudanix analysis
A flaw in the software that connects .NET programs to PostgreSQL databases lets attackers make the database run any commands they choose by sending specially crafted data.
- Exploitation
- Remote Unauthenticated
- Attacker needs
- None
- Complexity
- High
- Impact
- Full Compromise
- Component
- Library
- Class
- Improper Input Validation
- Remediation
- Upgrade
- Effort
- Medium
- Patch risk
- Low
What it actually does
Integer overflow in WriteBind() uses int variables for message and parameter lengths, writing a truncated size in the Postgres protocol message; the server then misparses subsequent bytes as new messages, enabling injection of arbitrary protocol commands that execute SQL on the application's behalf.
Why it matters to the business
Attackers can execute unauthorized database operations, risking data theft, modification, or deletion, which may cause compliance violations, operational outages, and loss of trust; the library is widely used so many .NET applications remain exposed until upgraded.
How an attack unfolds
An attacker supplies a query with parameter lengths large enough to overflow the int variables inside WriteBind(), causing Npgsql to emit a Postgres protocol message with an understated length; the server reads only the declared bytes and treats the remainder as fresh messages, allowing the attacker to inject arbitrary protocol commands that result in SQL execution under the application's credentials.
How to fix it
Upgrade Npgsql to one of the fixed releases: 4.0.14, 4.1.13, 5.0.18, 6.0.11, 7.0.7, or 8.0.3 (or the equivalent commit e34e2ba8042e666d9af54a1b255fba4d5b11df56 in source builds). Rebuild and redeploy all dependent applications after the upgrade.
How to confirm the fix worked
Inspect the Npgsql assembly or package version against the fixed list; perform functional testing with oversized parameter sets to confirm correct message lengths are emitted; review connection strings and dependency manifests across the environment.
Typical attack path
- Identify an application using a vulnerable Npgsql version to connect to PostgreSQL
- Craft a query containing parameter values whose combined lengths exceed INT_MAX
- Send the query through the application's normal data path
- Trigger the overflow so the emitted bind message carries an incorrect length
- Inject protocol messages that the server interprets as separate commands
- Execute arbitrary SQL statements on the application's behalf
How to detect it
Review PostgreSQL server logs and application connection traces for protocol-level anomalies such as unexpected message boundaries or SQL statements that do not match application source; correlate with client IP and query timing around large parameter submissions.
What your security team should do
- Prioritize upgrade of Npgsql to a fixed version in all applications
- Scan dependency manifests and container images for vulnerable Npgsql versions
- Add Npgsql version checks to CI/CD pipelines and software bill of materials
- Monitor database logs for unexpected statements originating from application connections
The record
Npgsql is the .NET data provider for PostgreSQL. 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. This vulnerability is fixed in 4.0.14, 4.1.13, 5.0.18, 6.0.11, 7.0.7, and 8.0.3.
Affected packages
| Ecosystem | Package | Introduced | Fixed |
|---|---|---|---|
| NuGet | Npgsql | 0 | 4.0.14 |
| NuGet | Npgsql | 4.1.0 | 4.1.13 |
| NuGet | Npgsql | 5.0.0 | 5.0.18 |
| NuGet | Npgsql | 6.0.0 | 6.0.11 |
| NuGet | Npgsql | 7.0.0 | 7.0.7 |
| NuGet | Npgsql | 8.0.0 | 8.0.3 |
| Ubuntu:16.04:LTS | npgsql | 0 | No fix |
| Ubuntu:18.04:LTS | npgsql | 0 | No fix |
| Ubuntu:20.04:LTS | npgsql | 0 | No fix |
| Ubuntu:22.04:LTS | npgsql | 0 | No fix |
| Ubuntu:24.04:LTS | npgsql | 0 | No fix |
| Ubuntu:Pro:16.04:LTS | npgsql | 0 | No fix |
| Ubuntu:Pro:18.04:LTS | npgsql | 0 | No fix |
| Ubuntu:Pro:20.04:LTS | npgsql | 0 | No fix |
| nuget | Npgsql | 4.1.0 | 4.1.13 |
| nuget | Npgsql | 5.0.0 | 5.0.18 |
| nuget | Npgsql | 6.0.0 | 6.0.11 |
| nuget | Npgsql | 7.0.0 | 7.0.7 |
| nuget | Npgsql | 8.0.0 | 8.0.3 |
Related vulnerabilities
- CVE-2026-87936 Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')… CWE-89
- CVE-2026-87938 Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')… CWE-89
- CVE-2026-114664 Frappe Framework before 16.33.0 contains a blind SQL injection vulnerability in the… CWE-89
- CVE-2026-114577 A vulnerability was found in oretnom23 php-travel-agency-system. CWE-89
- CVE-2026-113406 BA-Workflow developed by YS-infoware has a SQL Injection vulnerability. CWE-89
- CVE-2026-113405 BA-Workflow developed by YS-infoware has a SQL Injection vulnerability. CWE-89
- CVE-2026-107081 SQL injection via identifier injection in the tableName and tableFields POST parameters… CWE-89
- CVE-2026-112150 A security flaw has been discovered in vraj404 Criminal-Management-System up to… CWE-89