1
+ < html >
2
+ < head >
3
+ < meta charset ="utf-8 "/>
4
+ < title > TagEscapeResource</ title >
5
+ < meta content ="width=device-width, initial-scale=1, shrink-to-fit=no " name ="viewport ">
6
+ < link href ="/app/assets/node_modules/bootstrap/dist/css/bootstrap.min.css " rel ="stylesheet ">
7
+ </ head >
8
+ < body >
9
+
10
+ < main class ="container " role ="main ">
11
+ < h1 > JavaScript variable XSS</ h1 >
12
+
13
+ < p > This views is vulnerable to a XSS by injection into a JavaScript variable.</ p >
14
+
15
+ < div id ="output ">
16
+ This is where input text goes when XSS does not work
17
+ </ div >
18
+
19
+ < p >
20
+ Input=< code > ${content}</ code >
21
+ </ p >
22
+
23
+ < form >
24
+ < div class ="form-group ">
25
+ <!-- this sink does not disable auto-escaping and should be safe -->
26
+ < input class ="form-control " name =input placeholder ="%22><script>alert(1)</script> " value ="${content} ">
27
+ </ div >
28
+ < input class ="btn btn-primary " type ="submit ">
29
+ </ form >
30
+ </ main >
31
+
32
+ < div class ="container ">
33
+ < div class ="row ">
34
+ < div class ="col ">
35
+ < h2 > Sample XSS vectors</ h2 >
36
+
37
+ < p > We are injecting directly into JavaScript so simple < code > alert(1)</ code > will work
38
+ once we escape the JavaScript variable context.</ p >
39
+
40
+ < pre >
41
+ a"; alert(1);"
42
+ </ pre >
43
+
44
+ < p > More exciting XSS vectors can be found on
45
+ < a href ="http://heideri.ch/jso/ " rel ="external "> HTML5 Security Cheatsheet</ a > </ p >
46
+ </ div >
47
+ </ div >
48
+ </ div >
49
+
50
+ <!-- this sink has Freemarker auto-escaping explicitly disabled and should cause an XSS -->
51
+ < script >
52
+ // Trivial JavaScript to insert input into a div contents
53
+ var test = "${content?no_esc}" ;
54
+ document . getElementById ( "output" ) . innerText = test ;
55
+
56
+ </ script >
57
+
58
+ < footer class ="footer ">
59
+ < div class ="container ">
60
+ < a href ="/app/assets/index.html "> Back to main</ a >
61
+ </ div >
62
+ </ footer >
63
+ </ body >
64
+ </ html >
0 commit comments