mirror of
https://github.com/carlospolop/hacktricks
synced 2024-11-15 01:17:36 +00:00
GitBook: [#3029] No subject
This commit is contained in:
parent
501bf1ba56
commit
c50fb5e38d
1 changed files with 8 additions and 9 deletions
|
@ -22,10 +22,10 @@ window.postMessage('{"__proto__":{"isAdmin":True}}', 'https://company.com')
|
|||
```
|
||||
|
||||
Note that **targetOrigin** can be a '\*' or an URL like _https://company.com._\
|
||||
__In the **second scenario**, the **message can only be sent to that domain** (even if the origin of the window object is different). \
|
||||
\_\_In the **second scenario**, the **message can only be sent to that domain** (even if the origin of the window object is different).\
|
||||
If the **wildcard** is used, **messages could be sent to any domain**, and will be sent to the origin of the Window object.
|
||||
|
||||
### Attacking iframe & wilcard in **targetOrigin** 
|
||||
### Attacking iframe & wilcard in **targetOrigin**
|
||||
|
||||
As explained in [**this report**](https://blog.geekycat.in/google-vrp-hijacking-your-screenshots/) if you find a page that can be **iframed** (no `X-Frame-Header` protection) and that is **sending sensitive** message via **postMessage** using a **wildcard** (\*), you can **modify** the **origin** of the **iframe** and **leak** the **sensitive** message to a domain controlled by you.\
|
||||
Note that if the page can be iframed but the **targetOrigin** is **set to a URL and not to a wildcard**, this **trick won't work**.
|
||||
|
@ -79,11 +79,9 @@ In order to **find event listeners** in the current page you can:
|
|||
|
||||
### addEventListener check origin bypasses
|
||||
|
||||
* If **`indexOf()`** is used to **check** the **origin** of the PostMessage event, remember that it can be easily bypassed like in the following example: `("https://app-sj17.marketo.com").indexOf("https://app-sj17.ma")`\
|
||||
|
||||
* If **`indexOf()`** is used to **check** the **origin** of the PostMessage event, remember that it can be easily bypassed like in the following example: `("https://app-sj17.marketo.com").indexOf("https://app-sj17.ma")`\\
|
||||
* If **`search()`** is used to **validate** the **origin** could be insecure. According to the docs of `String.prototype.search()`, the method **takes a regular repression** object instead of a string. If anything other than regexp is passed, it will get implicitly converted into a regexp.\
|
||||
In regular expression, **a dot (.) is treated as a wildcard**. An attacker can take advantage of it and **use** a **special domain** instead of the official one to bypass the validation, like in: `"https://www.safedomain.com".search("www.s.fedomain.com")`.\
|
||||
|
||||
In regular expression, **a dot (.) is treated as a wildcard**. An attacker can take advantage of it and **use** a **special domain** instead of the official one to bypass the validation, like in: `"https://www.safedomain.com".search("www.s.fedomain.com")`.\\
|
||||
* If **`escapeHtml`** function is used, the function does not create a `new` escaped object, instead it **overwrites properties** of the existing object. This means that if we are able to create an object with a controlled property that does not respond to `hasOwnProperty` it will not be escaped.
|
||||
|
||||
```javascript
|
||||
|
@ -137,11 +135,12 @@ Example of an exploit to abuse **Prototype Pollution and then XSS** through a `p
|
|||
|
||||
For **more information**:
|
||||
|
||||
* Link to page about [**prototype pollution**](deserialization/nodejs-proto-prototype-pollution/)****
|
||||
* Link to page about [**XSS**](xss-cross-site-scripting/)****
|
||||
* Link to page about [**client side prototype pollution to XSS**](deserialization/nodejs-proto-prototype-pollution/#client-side-prototype-pollution-to-xss)****
|
||||
* Link to page about [**prototype pollution**](deserialization/nodejs-proto-prototype-pollution/)
|
||||
* Link to page about [**XSS**](xss-cross-site-scripting/)
|
||||
* Link to page about [**client side prototype pollution to XSS**](deserialization/nodejs-proto-prototype-pollution/#client-side-prototype-pollution-to-xss)
|
||||
|
||||
## References
|
||||
|
||||
* [https://jlajara.gitlab.io/web/2020/07/17/Dom\_XSS\_PostMessage\_2.html](https://jlajara.gitlab.io/web/2020/07/17/Dom\_XSS\_PostMessage\_2.html)
|
||||
* [https://dev.to/karanbamal/how-to-spot-and-exploit-postmessage-vulnerablities-36cd](https://dev.to/karanbamal/how-to-spot-and-exploit-postmessage-vulnerablities-36cd)
|
||||
* To practice: [https://github.com/yavolo/eventlistener-xss-recon](https://github.com/yavolo/eventlistener-xss-recon)
|
||||
|
|
Loading…
Reference in a new issue