File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed
test/query-tests/Security/CWE-020/MissingOriginCheck Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -66,6 +66,16 @@ predicate hasOriginCheck(PostMessageHandler handler) {
6666 or
6767 // set.includes(event.source)
6868 exists ( InclusionTest test | sourceOrOrigin ( handler ) .flowsTo ( test .getContainedNode ( ) ) )
69+ or
70+ // "safeOrigin".startsWith(event.origin)
71+ exists ( StringOps:: StartsWith starts |
72+ origin ( DataFlow:: TypeTracker:: end ( ) , handler ) .flowsTo ( starts .getSubstring ( ) )
73+ )
74+ or
75+ // "safeOrigin".endsWith(event.origin)
76+ exists ( StringOps:: EndsWith ends |
77+ origin ( DataFlow:: TypeTracker:: end ( ) , handler ) .flowsTo ( ends .getSubstring ( ) )
78+ )
6979}
7080
7181from PostMessageHandler handler
Original file line number Diff line number Diff line change @@ -61,4 +61,10 @@ function is_valid_origin(origin) {
6161 warn ( "invalid origin: " + origin ) ;
6262 }
6363 return valid ;
64- }
64+ }
65+
66+ window . onmessage = event => { // OK - the check is OK
67+ if ( "https://www.example.com" . startsWith ( event . origin ) ) {
68+ // do something
69+ }
70+ }
You can’t perform that action at this time.
0 commit comments