GHSA-x9vc-6hfv-hg8c

Suggest an improvement
Source
https://github.com/advisories/GHSA-x9vc-6hfv-hg8c
Import Source
https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2024/05/GHSA-x9vc-6hfv-hg8c/GHSA-x9vc-6hfv-hg8c.json
JSON Data
https://api.osv.dev/v1/vulns/GHSA-x9vc-6hfv-hg8c
Aliases
Published
2024-05-09T15:12:49Z
Modified
2024-12-12T22:37:04.784814Z
Severity
  • 8.1 (High) CVSS_V3 - CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H CVSS Calculator
Summary
Npgsql vulnerable to SQL Injection via Protocol Message Size Overflow
Details

Summary

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.

Impact

Attackers can issue arbitrary SQL statements to the database on behalf of the application. The final impact depends on the application that uses Npgsql, the data it stores in Postgres, etc.

Database specific
{
    "nvd_published_at": "2024-05-14T15:36:51Z",
    "cwe_ids": [
        "CWE-190",
        "CWE-89"
    ],
    "severity": "HIGH",
    "github_reviewed": true,
    "github_reviewed_at": "2024-05-09T15:12:49Z"
}
References

Affected packages

NuGet / Npgsql

Package

Affected ranges

Type
ECOSYSTEM
Events
Introduced
8.0.0
Fixed
8.0.3

Affected versions

8.*

8.0.0
8.0.1
8.0.2

NuGet / Npgsql

Package

Affected ranges

Type
ECOSYSTEM
Events
Introduced
0Unknown introduced version / All previous versions are affected
Fixed
4.0.14

Affected versions

2.*

2.0.11
2.0.12
2.0.12.1
2.0.13-beta1
2.0.14.1
2.0.14.2
2.0.14.3
2.1.0-beta1
2.1.0-rc1
2.1.0
2.1.1
2.1.2
2.1.3
2.2.0-beta1
2.2.0-rc1
2.2.0-rc2
2.2.0
2.2.1
2.2.2
2.2.3
2.2.4
2.2.4.1
2.2.4.2
2.2.4.3
2.2.5
2.2.6
2.2.7

3.*

3.0.0-beta0001
3.0.0-rc0001
3.0.0-rc0002
3.0.0
3.0.1
3.0.2
3.0.3
3.0.4
3.0.5
3.0.6
3.0.7
3.0.8
3.1.0-alpha1
3.1.0-alpha2
3.1.0-alpha3
3.1.0-alpha4
3.1.0-alpha5
3.1.0-alpha6
3.1.0-beta0001
3.1.0
3.1.1
3.1.2
3.1.3
3.1.4
3.1.5
3.1.6
3.1.7
3.1.8
3.1.9
3.1.10
3.2.0-beta1
3.2.0
3.2.1
3.2.2
3.2.3
3.2.4
3.2.4.1
3.2.5
3.2.6
3.2.7

4.*

4.0.0-preview1
4.0.0-preview2
4.0.0-rc1
4.0.0
4.0.1
4.0.2
4.0.3
4.0.4
4.0.5
4.0.6
4.0.7
4.0.8
4.0.9
4.0.10
4.0.11
4.0.12
4.0.13

Database specific

{
    "last_known_affected_version_range": "<= 4.0.13"
}

NuGet / Npgsql

Package

Affected ranges

Type
ECOSYSTEM
Events
Introduced
4.1.0
Fixed
4.1.13

Affected versions

4.*

4.1.0
4.1.1
4.1.2
4.1.3
4.1.3.1
4.1.4
4.1.5
4.1.6
4.1.7
4.1.8
4.1.9
4.1.10
4.1.11
4.1.12

NuGet / Npgsql

Package

Affected ranges

Type
ECOSYSTEM
Events
Introduced
5.0.0
Fixed
5.0.18

Affected versions

5.*

5.0.0
5.0.1
5.0.1.1
5.0.2
5.0.3
5.0.4
5.0.5
5.0.7
5.0.10
5.0.11
5.0.12
5.0.13
5.0.14
5.0.15
5.0.16
5.0.17

NuGet / Npgsql

Package

Affected ranges

Type
ECOSYSTEM
Events
Introduced
6.0.0
Fixed
6.0.11

Affected versions

6.*

6.0.0
6.0.1
6.0.2
6.0.3
6.0.4
6.0.5
6.0.6
6.0.7
6.0.8
6.0.9
6.0.10

NuGet / Npgsql

Package

Affected ranges

Type
ECOSYSTEM
Events
Introduced
7.0.0
Fixed
7.0.7

Affected versions

7.*

7.0.0
7.0.1
7.0.2
7.0.4
7.0.6