File tree Expand file tree Collapse file tree 2 files changed +32
-1
lines changed
javascript/ql/test/query-tests/Security
CWE-601/ClientSideUrlRedirect Expand file tree Collapse file tree 2 files changed +32
-1
lines changed Original file line number Diff line number Diff line change @@ -466,3 +466,25 @@ function domMethods() {
466
466
let cell = row . insertCell ( ) ;
467
467
cell . innerHTML = source ; // NOT OK
468
468
}
469
+
470
+ function urlStuff ( ) {
471
+ var url = document . location . search . substr ( 1 ) ;
472
+
473
+ $ ( "<a>" , { href : url } ) . appendTo ( "body" ) ; // NOT OK - but not detected [INCONSISTENCY]
474
+ $ ( "#foo" ) . attr ( "href" , url ) ; // NOT OK - but not detected [INCONSISTENCY]
475
+ $ ( "#foo" ) . attr ( { href : url } ) ; // NOT OK - but not detected [INCONSISTENCY]
476
+ $ ( "<img>" , { src : url } ) . appendTo ( "body" ) ; // NOT OK - but not detected [INCONSISTENCY]
477
+ $ ( "<a>" , { href : win . location . href } ) . appendTo ( "body" ) ; // OK
478
+
479
+ $ ( "<img>" , { src : "http://google.com/" + url } ) . appendTo ( "body" ) ; // OK
480
+
481
+ $ ( "<img>" , { src : [ "http://google.com" , url ] . join ( "/" ) } ) . appendTo ( "body" ) ; // OK
482
+
483
+ if ( url . startsWith ( "https://" ) ) {
484
+ $ ( "<img>" , { src : url } ) . appendTo ( "body" ) ; // OK
485
+ } else {
486
+ $ ( "<img>" , { src : url } ) . appendTo ( "body" ) ; // NOT OK - but not detected [INCONSISTENCY]
487
+ }
488
+
489
+ window . open ( location . hash . substr ( 1 ) ) ; // OK - any JavaScript is executed in another context
490
+ }
Original file line number Diff line number Diff line change @@ -72,4 +72,13 @@ function quz() {
72
72
var payload = history . location . hash . substr ( 1 ) ;
73
73
74
74
history . replace ( payload ) ; // NOT OK
75
- }
75
+ }
76
+
77
+ function bar ( ) {
78
+ var url = document . location . search . substr ( 1 ) ;
79
+
80
+ $ ( "<a>" , { href : url } ) . appendTo ( "body" ) ; // NOT OK - but not detected [INCONSISTENCY]
81
+ $ ( "#foo" ) . attr ( "href" , url ) ; // NOT OK - but not detected [INCONSISTENCY]
82
+ $ ( "#foo" ) . attr ( { href : url } ) ; // NOT OK - but not detected [INCONSISTENCY]
83
+ $ ( "<img>" , { src : url } ) . appendTo ( "body" ) ; // NOT OK - but not detected [INCONSISTENCY]
84
+ }
You can’t perform that action at this time.
0 commit comments