Skip to content

Commit 3233219

Browse files
authored
Merge pull request #6733 from EnterpriseDB/CVE-2025-2291
CVE-2025-2291 Assessment
2 parents 7062ec1 + 3421c37 commit 3233219

File tree

6 files changed

+210
-19
lines changed

6 files changed

+210
-19
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
---
2+
title: CVE-2025-2291 - PgBouncer "VALID UNTIL yesterday"
3+
navTitle: CVE-2025-2291
4+
affectedProducts: All versions of PGBouncer prior to 1.24.1, TPA prior to 23.38.0, PGAI Cloud Service prior to May 12, 2025
5+
---
6+
7+
First Published: 2025/04/30
8+
9+
Last Updated: 2025/04/30
10+
11+
Important: This is an assessment of the impact of CVE-2025-2291 on EDB products and services. It links to and details the CVE and supplements that information with EDB's own assessment.
12+
13+
## Summary
14+
15+
In PgBouncer, the `auth_query` mechanism does not consider the `VALID UNTIL` attribute set in PostgreSQL for user passwords.
16+
This oversight allows users to authenticate using expired passwords, potentially granting unauthorized access. The flaw was fixed in [PgBouncer 1.24.1](https://www.pgbouncer.org/changelog.html#pgbouncer-124x).
17+
18+
## Vulnerability details
19+
20+
CVE-ID: [CVE-2025-2291](https://nvd.nist.gov/vuln/detail/CVE-2025-2291)
21+
22+
CVSS Base Score: 8.1
23+
24+
CVSS Temporal Score: Undefined
25+
26+
CVSS Environmental Score: Undefined
27+
28+
CVSS Vector: CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H
29+
30+
## Affected products and versions
31+
32+
* Community PgBouncer: All versions prior to 1.24.1
33+
* EDB PgBouncer: All versions prior to 1.24.1
34+
* EDB TPA: All versions prior to 23.38.0
35+
* PGAI Cloud Service: All versions prior to May 12, 2025 release.
36+
37+
## Remediation/fixes
38+
39+
| Product | VRMF | Remediation/First Fix |
40+
|---------------|---------|---------------------------------------|
41+
| Community PgBouncer | 1.24.1 | Upgrade to Community PgBouncer 1.24.1 |
42+
| EDB PgBouncer | 1.24.1 | Upgrade to EDB PgBouncer 1.24.1 |
43+
| EDB TPA | 23.38.0 | Upgrade to TPA 23.38.0 when available |
44+
| PGAI Cloud Service | May 12, 2025 | Resolved by May 12, 2025 Release |
45+
46+
For TPA we recommend applying the following mitigation measures until the upcoming version with a fix is available:
47+
48+
Two solutions are available:
49+
50+
The first and preferred solution is to create a `postgres-config-final` hook that will be run at the end of the existing `tpaexec deploy` command. The hook should be placed in the cluster directory under the `hooks/` folder and should be named `postgres-config-final.yml`, with the following content.
51+
52+
```yaml
53+
---
54+
55+
- name: Mitigate CVE-2025-2291
56+
block:
57+
- name: Edit function pgbouncer_get_auth() and grant execute permissions
58+
postgresql_query:
59+
conninfo: "{{ dsn|dbname(item) }}"
60+
queries:
61+
- text: >
62+
CREATE OR REPLACE FUNCTION pg_catalog.pgbouncer_get_auth(p_usename TEXT)
63+
RETURNS TABLE(username TEXT, password TEXT) AS $$
64+
BEGIN
65+
RETURN QUERY
66+
SELECT usename::TEXT, CASE WHEN valuntil < now() THEN NULL ELSE passwd::TEXT END
67+
FROM pg_catalog.pg_shadow
68+
WHERE usename = p_usename;
69+
END;
70+
$$ LANGUAGE plpgsql SECURITY DEFINER
71+
- text: REVOKE ALL ON FUNCTION pg_catalog.pgbouncer_get_auth(p_usename TEXT) FROM PUBLIC
72+
- text: GRANT EXECUTE ON FUNCTION pg_catalog.pgbouncer_get_auth(p_usename TEXT) TO "{{ pgbouncer_auth_user }}"
73+
changed_when: true
74+
become_user: "{{ postgres_user }}"
75+
become: yes
76+
with_items: "{{ cluster_facts.databases.keys()|list }}"
77+
vars:
78+
dbs: "{{ auth_function_dbs|default({}) }}"
79+
when:
80+
- item not in ['template0', 'bdr_supervisordb']
81+
when: >
82+
postgres_users|json_query("[?username=='%s']" % pgbouncer_auth_user) != []
83+
and task_selector|permits('pgbouncer')
84+
```
85+
86+
Then you should run `tpaexec deploy <cluster_dir>` to apply the changes.
87+
This will modify the underlying function used by auth_query setting in PgBouncer to take password validity into account.
88+
89+
The second solution is to apply the same modification via a custom command:
90+
The custom command file should be created as `mitigate-CVE-2025-2291.yml` in the `commands/` folder inside the TPA cluster directory with the following content:
91+
92+
```yaml
93+
---
94+
95+
- import_playbook: "{{ tpa_dir }}/architectures/lib/init.yml"
96+
tags: always
97+
98+
- name: Perform custom command tasks
99+
hosts: all
100+
tasks:
101+
- name: Mitigate CVE-2025-2291
102+
block:
103+
- name: Edit function pgbouncer_get_auth() and grant execute permissions
104+
postgresql_query:
105+
conninfo: "{{ dsn|dbname(item) }}"
106+
queries:
107+
- text: >
108+
CREATE OR REPLACE FUNCTION pg_catalog.pgbouncer_get_auth(p_usename TEXT)
109+
RETURNS TABLE(username TEXT, password TEXT) AS $$
110+
BEGIN
111+
RETURN QUERY
112+
SELECT usename::TEXT, CASE WHEN valuntil < now() THEN NULL ELSE passwd::TEXT END
113+
FROM pg_catalog.pg_shadow
114+
WHERE usename = p_usename;
115+
END;
116+
$$ LANGUAGE plpgsql SECURITY DEFINER
117+
- text: REVOKE ALL ON FUNCTION pg_catalog.pgbouncer_get_auth(p_usename TEXT) FROM PUBLIC
118+
- text: GRANT EXECUTE ON FUNCTION pg_catalog.pgbouncer_get_auth(p_usename TEXT) TO "{{ pgbouncer_auth_user }}"
119+
changed_when: true
120+
become_user: "{{ postgres_user }}"
121+
become: yes
122+
with_items: "{{ cluster_facts.databases.keys()|list }}"
123+
vars:
124+
dbs: "{{ auth_function_dbs|default({}) }}"
125+
when:
126+
- item not in ['template0', 'bdr_supervisordb']
127+
when: >
128+
"primary" in role
129+
```
130+
131+
The playbook can be run using the command
132+
`tpaexec mitigate-CVE-2025-2291 .`
133+
134+
## References
135+
136+
* [CVSS Calculator v3.1](https://www.first.org/cvss/calculator/3.1)
137+
138+
## Related information
139+
140+
* [EnterpriseDB](https://www.enterprisedb.com/)
141+
* [PgBouncer](https://www.pgbouncer.org/)
142+
* [EDB Blogs link](https://enterprisedb.com/blog/)
143+
144+
## Acknowledgement
145+
146+
Source: [PostgreSQL Security Team](https://www.postgresql.org/support/security/)
147+
148+
## Change history
149+
150+
* 30 April 2025: First published version of the document.
151+
152+
## Disclaimer
153+
154+
This document is provided on an "as is" basis and does not imply any kind of guarantee or warranty, including the warranties of merchantability or fitness for a particular use. Your use of the information on the document is at your own risk. EDB reserves the right to change or update this document at any time. Customers are therefore recommended to always view the latest version of this document.

advocacy_docs/security/assessments/index.mdx

+22
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ iconName: Security
66
hideKBLink: true
77
hideToC: false
88
navigation:
9+
- cve-2025-2291
910
- cve-2025-1094
1011
- cve-2024-7348
1112
- cve-2024-4317
@@ -29,6 +30,27 @@ The CVEs listed in this section are from PostgreSQL and other parties who have r
2930
<table class="table-bordered">
3031

3132

33+
<tr><td>
34+
<details><summary><h3 style="display:inline"> CVE-2025-2291 </h3>
35+
<span>
36+
&nbsp;&nbsp;<a href="cve-2025-2291">Read Assessment</a>
37+
&nbsp;&nbsp;Updated: </span><span>2025/04/30</span>
38+
<h4>PgBouncer "VALID UNTIL yesterday"</h4>
39+
<h5> All versions of PGBouncer prior to 1.24.1, TPA prior to 23.38.0, PGAI Cloud Service prior to May 12, 2025</h5>
40+
</summary>
41+
<hr/>
42+
<em>Summary:</em>&nbsp;
43+
In PgBouncer, the <code>auth_query</code> mechanism does not consider the <code>VALID UNTIL</code> attribute set in PostgreSQL for user passwords.
44+
This oversight allows users to authenticate using expired passwords, potentially granting unauthorized access. The flaw was fixed in [PgBouncer 1.24.1](https://www.pgbouncer.org/changelog.html#pgbouncer-124x).
45+
<br/>
46+
<a href="cve-2025-2291">Read More...</a>
47+
</details></td></tr>
48+
49+
50+
51+
52+
53+
3254
<tr><td>
3355
<details><summary><h3 style="display:inline"> CVE-2025-1094 </h3>
3456
<span>

advocacy_docs/security/index.mdx

+17-16
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,23 @@ An issue was discovered in EnterpriseDB Postgres Advanced Server (EPAS) before 1
118118
<table class="table-bordered">
119119

120120

121+
<tr><td>
122+
<details><summary><h3 style="display:inline"> CVE-2025-2291 </h3>
123+
<span>
124+
&nbsp;&nbsp;<a href="assessments/cve-2025-2291">Read Assessment</a>
125+
&nbsp;&nbsp;Updated: </span><span>2025/04/30</span>
126+
<h4>PgBouncer "VALID UNTIL yesterday"</h4>
127+
<h5> All versions of PGBouncer prior to 1.24.1, TPA prior to 23.38.0, PGAI Cloud Service prior to May 12, 2025</h5>
128+
</summary>
129+
<hr/>
130+
<em>Summary:</em>&nbsp;
131+
In PgBouncer, the <code>auth_query</code> mechanism does not consider the <code>VALID UNTIL</code> attribute set in PostgreSQL for user passwords.
132+
This oversight allows users to authenticate using expired passwords, potentially granting unauthorized access. The flaw was fixed in [PgBouncer 1.24.1](https://www.pgbouncer.org/changelog.html#pgbouncer-124x).
133+
<br/>
134+
<a href="assessments/cve-2025-2291">Read More...</a>
135+
</details></td></tr>
136+
137+
121138
<tr><td>
122139
<details><summary><h3 style="display:inline"> CVE-2025-1094 </h3>
123140
<span>
@@ -181,20 +198,4 @@ pgjdbc, the PostgreSQL JDBC Driver, allows attacker to inject SQL if using Prefe
181198
<a href="assessments/cve-2024-1597">Read More...</a>
182199
</details></td></tr>
183200

184-
185-
<tr><td>
186-
<details><summary><h3 style="display:inline"> CVE-2024-0985 </h3>
187-
<span>
188-
&nbsp;&nbsp;<a href="assessments/cve-2024-0985">Read Assessment</a>
189-
&nbsp;&nbsp;Updated: </span><span>2025/01/31</span>
190-
<h4>PostgreSQL non-owner REFRESH MATERIALIZED VIEW CONCURRENTLY executes arbitrary SQL</h4>
191-
<h5> PostgreSQL, EPAS all versions prior to 15.6.0,14.11.0,13.14.20 and 12.18.23, PGE all versions prior to 15.6.0</h5>
192-
</summary>
193-
<hr/>
194-
<em>Summary:</em>&nbsp;
195-
Late privilege drop in REFRESH MATERIALIZED VIEW CONCURRENTLY in PostgreSQL allows an object creator to execute arbitrary SQL functions as the command issuer. The command intends to run SQL functions as the owner of the materialized view, enabling safe refresh of untrusted materialized views. The victim is a superuser or member of one of the attacker's roles. The attack requires luring the victim into running REFRESH MATERIALIZED VIEW CONCURRENTLY on the attacker's materialized view. As part of exploiting this vulnerability, the attacker creates functions that use CREATE RULE to convert the internally-built temporary table to a view. Versions before PostgreSQL 15.6, 14.11, 13.14, and 12.18 are affected. The only known exploit does not work in PostgreSQL 16 and later. For defense in depth, PostgreSQL 16.2 adds the protections that older branches are using to fix their vulnerability.
196-
<br/>
197-
<a href="assessments/cve-2024-0985">Read More...</a>
198-
</details></td></tr>
199-
200201
</table>

product_docs/docs/pgbouncer/1/pgbouncer_rel_notes/12400_rel_notes.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: "EDB PgBouncer 1.24.0.0 release notes"
33
navTitle: Version 1.24.0.0
44
---
55

6-
Released: 11 Mar 2024
6+
Released: 11 Mar 2025
77

88
EDB PgBouncer 1.24.0.0 includes the following upstream merge:
99

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
title: "EDB PgBouncer 1.24.1.0 release notes"
3+
navTitle: Version 1.24.1.0
4+
---
5+
6+
Released: 30 Apr 2025
7+
8+
EDB PgBouncer 1.24.1.0 includes the following upstream merge:
9+
10+
| Type | Description |
11+
|----------------|---------------------------------------------------------------------------------------------------------------------------------------------------|
12+
| Upstream merge | Merged with community PgBouncer 1.24.1.0. See the community [Release Notes](https://www.pgbouncer.org/changelog.html#pgbouncer-124x) for details. |

product_docs/docs/pgbouncer/1/pgbouncer_rel_notes/index.mdx

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ title: "Release notes"
33
redirects:
44
- ../01_whats_new/
55
navigation:
6+
- 12410_rel_notes
67
- 12400_rel_notes
78
- 12310_rel_notes
89
- 12300_rel_notes
@@ -19,8 +20,9 @@ navigation:
1920

2021
The EDB PgBouncer documentation describes the latest version of EDB PgBouncer 1, including minor releases and patches. The release notes provide information on what was new in each release. For new functionality introduced in a minor or patch release, the content also indicates the release that introduced the feature.
2122

22-
| Version | Release date | Upstream merges |
23-
| ------------------------------ | ------------ | ---------------------------------------------------------------------------- |
23+
| Version | Release date | Upstream merges |
24+
|--------------------------------|--------------|------------------------------------------------------------------------------|
25+
| [1.24.1.0](12410_rel_notes) | 30 Apr 2025 | Upstream [1.24.1.0](https://www.pgbouncer.org/changelog.html#pgbouncer-124x) |
2426
| [1.24.0.0](12400_rel_notes) | 11 Mar 2025 | Upstream [1.24.0.0](https://www.pgbouncer.org/changelog.html#pgbouncer-124x) |
2527
| [1.23.1.0](12310_rel_notes) | 22 Aug 2024 | Upstream [1.23.1.0](https://www.pgbouncer.org/changelog.html#pgbouncer-123x) |
2628
| [1.23.0.0](12300_rel_notes) | 01 Aug 2024 | Upstream [1.23.0.0](https://www.pgbouncer.org/changelog.html#pgbouncer-123x) |

0 commit comments

Comments
 (0)