Skip to content

Commit cf3142e

Browse files
committed
Updated qhelp with a third example
1 parent 92f9f32 commit cf3142e

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

javascript/ql/src/experimental/Security/CWE-020/PostMessageNoOriginCheck.qhelp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,11 @@ Always verify the sender's identity of incoming messages.
2121
<p>In the first example, the `MessageEvent.data` is passed to the `eval` function withouth checking the origin. This means that any window can send arbitrary messages that will be executed in the window receiving the message</p>
2222
<sample src="examples/postMessageNoOriginCheck.js" />
2323

24-
<p> In the second example, the `MessageEvent.origin` is checked against a trusted origin.
25-
<sample src="examples/postMessageWithOriginCheck.js" />
24+
<p> In the second example, the `MessageEvent.origin` is verified with an unsecure check. For example, using `event.origin.indexOf('www.example.com') > -1` can be baypassed because the string `www.example.com` could appear anywhere in `event.origin` (i.e. `www.example.com.mydomain.com`)
25+
<sample src="examples/postMessageWithInsufficientCheck.js" />
26+
27+
<p> In the third example, the `MessageEvent.origin` is properly checked against a trusted origin.
28+
<sample src="examples/postMessageWithInsufficientCheck.js" />
2629

2730
</example>
2831

0 commit comments

Comments
 (0)