# postMessage XSS in Tesla Payment page

Tesla payment page's onmessage listener accepted cross-origin postMessages without origin/source checks, letting any site inject a javascript: URL into an auto-submitting form for DOM XSS.

- Payout: $500
- Severity: medium
- Program: Tesla
- Found by: TheTime
- Disclosed: 2022-02-22
- Write-up quality: 6/10
- Original: https://bugcrowd.com/disclosures/aac249ea-fe92-4b43-98e9-dda021c0ff4d/postmessage-xss-in-tesla-payment-page
- Library page: https://bugbountylibrary.com/r/bc%3A0af3ca65-8e06-4323-ac91-82665ad805f4
- Tags: area:web domain:web impact:ato impact:pii-leak kind:bounty platform:bugcrowd sev:medium tech:rest technique:js-analysis technique:source-review vuln:xss

**Target:** Tesla model3 design/payment page (www.tesla.com/ro_ro/model3/design#payment)
**Root cause:** The page registers an onmessage listener that accepts messages from any origin without validating message.origin or message.source, and uses the message's url field unvalidated as the action of an auto-submitting form.
**Steps:**
1. Open https://www.tesla.com/ro_ro/model3/design#payment
2. From an attacker-controlled page, obtain a reference to the Tesla window/iframe
3. Send `postMessage` with payload `{"instanceId":0,"data":"aaaa","method":"GET","url":"javascript:alert(`XSS in the context of: ` + origin)","type":"redirect"}`
4. Listener builds an auto-submitting form with action set to the javascript: URL, executing script in www.tesla.com context
**How found:** Researcher inspecting the payment page noticed an onmessage listener accepting cross-domain messages; observed the received url field was used to construct an auto-submitting form, hypothesized a javascript: action would execute.
**Exploitation:** Attacker hosts a page that frames or opens the Tesla payment page and postMessages the crafted payload; the victim visiting the attacker page triggers DOM XSS in Tesla's origin, enabling session/account/payment data theft or page rewrite for phishing.
**Insight:** Grep client bundles for addEventListener('message') on payment/checkout flows; trace the message fields into sinks like form.action, location, or innerHTML — a javascript: URL in form.action is an easy DOM XSS when origin/source checks are absent.

## Proof of concept (copied exactly from the original report)

**postMessage payload with javascript: URL**

```
var payload = {
 "instanceId": 0,
 "data":"aaaa",
 "method":"GET",
 "url":"javascript:alert(`XSS in the context of: ` + origin)",
 "type": "redirect"
}
```

