Skip to content

Commit

Permalink
GitBook: [master] one page and 2 assets modified
Browse files Browse the repository at this point in the history
  • Loading branch information
carlospolop authored and gitbook-bot committed Oct 4, 2021
1 parent 7af5e03 commit 283c7c0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
Binary file modified .gitbook/assets/image (617).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .gitbook/assets/image (618).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions pentesting-web/postmessage-vulnerabilities.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ In order to **find event listeners** in the current page you can:

![](../.gitbook/assets/image%20%28616%29.png)

* **Go to** _Elements --> Event Listeners_ in the developer tools of the browser

![](../.gitbook/assets/image%20%28617%29.png)

* Use a **browser extension** like [**https://github.com/benso-io/posta**](https://github.com/benso-io/posta) or [https://github.com/fransr/postMessage-tracker](https://github.com/fransr/postMessage-tracker). This browser extensions will **intercept all the messages** and show them to you.

### addEventListener check origin bypasses
Expand All @@ -89,6 +93,18 @@ result.message; // "'"<b>\"

`File` object is perfect for this exploit as it has a read-only `name` property which is used by our template and will bypass `escapeHtml` function.

### X-Frame-Header bypass

In order to perform these attacks ideally you will be able to **put the victim web page** inside an `iframe`. But some headers like `X-Frame-Header` can **prevent** that **behaviour**.
In those scenarios you can still use a less stealthy attack. You can open a new tab to the vulnerable web application and communicate with it:

```markup
<script>
var w=window.open("<url>")
setTimeout(function(){w.postMessage('text here','*');}, 2000);
</script>
```

### postMessage to Prototype Pollution and/or XSS

In scenarios where the data sent through `postMessage` is executed by JS, you can **iframe** the **page** and **exploit** the **prototype pollution/XSS** sending the exploit via `postMessage`.
Expand Down Expand Up @@ -122,4 +138,5 @@ For **more information**:
## 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)

0 comments on commit 283c7c0

Please sign in to comment.