Skip to content

Commit ad707f5

Browse files
author
Lyes
committed
3 New XSS Stored Secure Level Added
1 parent 21904c5 commit ad707f5

File tree

4 files changed

+69
-7
lines changed

4 files changed

+69
-7
lines changed

.classpath

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<classpath>
3-
<classpathentry kind="src" output="bin/main" path="src/main/java">
3+
<classpathentry kind="src" output="bin/test" path="src/test/java">
44
<attributes>
5-
<attribute name="gradle_scope" value="main"/>
6-
<attribute name="gradle_used_by_scope" value="main,test"/>
5+
<attribute name="gradle_scope" value="test"/>
6+
<attribute name="gradle_used_by_scope" value="test"/>
7+
<attribute name="test" value="true"/>
78
</attributes>
89
</classpathentry>
910
<classpathentry kind="src" output="bin/main" path="src/main/resources">
@@ -12,11 +13,10 @@
1213
<attribute name="gradle_used_by_scope" value="main,test"/>
1314
</attributes>
1415
</classpathentry>
15-
<classpathentry kind="src" output="bin/test" path="src/test/java">
16+
<classpathentry kind="src" output="bin/main" path="src/main/java">
1617
<attributes>
17-
<attribute name="gradle_scope" value="test"/>
18-
<attribute name="gradle_used_by_scope" value="test"/>
19-
<attribute name="test" value="true"/>
18+
<attribute name="gradle_scope" value="main"/>
19+
<attribute name="gradle_used_by_scope" value="main,test"/>
2020
</attributes>
2121
</classpathentry>
2222
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8/"/>

.project

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,15 @@
2020
<nature>org.eclipse.jdt.core.javanature</nature>
2121
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
2222
</natures>
23+
<filteredResources>
24+
<filter>
25+
<id>1738769978762</id>
26+
<name></name>
27+
<type>30</type>
28+
<matcher>
29+
<id>org.eclipse.core.resources.regexFilterMatcher</id>
30+
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
31+
</matcher>
32+
</filter>
33+
</filteredResources>
2334
</projectDescription>

.settings/org.eclipse.jdt.core.prefs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
eclipse.preferences.version=1
2+
org.eclipse.jdt.core.classpath.outputOverlappingAnotherSource=ignore
23
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
34
org.eclipse.jdt.core.compiler.compliance=1.8
45
org.eclipse.jdt.core.compiler.source=1.8

src/main/java/org/sasanlabs/service/vulnerability/xss/persistent/PersistentXSSInHTMLTagVulnerability.java

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,4 +218,54 @@ public ResponseEntity<String> getVulnerablePayloadLevel7(
218218
post -> StringEscapeUtils.escapeHtml4(post)),
219219
HttpStatus.OK);
220220
}
221+
//escape html and delete all the script and img tags
222+
@VulnerableAppRequestMapping(
223+
value = LevelConstants.LEVEL_8,
224+
htmlTemplate = "LEVEL_1/PersistentXSS",
225+
variant = Variant.SECURE)
226+
public ResponseEntity<String> getSecurePayloadLevel8(
227+
@RequestParam Map<String, String> queryParams) {
228+
return new ResponseEntity<>(
229+
this.getCommentsPayload(
230+
queryParams,
231+
LevelConstants.LEVEL_8,
232+
post -> StringEscapeUtils.escapeHtml4(
233+
post.replaceAll("(?i)<script.*?>.*?</script>", "")
234+
.replaceAll("(?i)<img.*?>", ""))),
235+
HttpStatus.OK);
236+
}
237+
//delete all the html tags
238+
@VulnerableAppRequestMapping(
239+
value = LevelConstants.LEVEL_9,
240+
htmlTemplate = "LEVEL_1/PersistentXSS",
241+
variant = Variant.SECURE)
242+
public ResponseEntity<String> getSecurePayloadLevel9(
243+
@RequestParam Map<String, String> queryParams) {
244+
Function<String, String> function =
245+
(post) -> {
246+
String sanitizedPost = post.replaceAll("<.*?>", ""); // Delete all the html balises
247+
return StringEscapeUtils.escapeHtml4(sanitizedPost);
248+
};
249+
return new ResponseEntity<>(
250+
this.getCommentsPayload(queryParams, LevelConstants.LEVEL_9, function),
251+
HttpStatus.OK);
252+
}
253+
//delete all the js calls
254+
@VulnerableAppRequestMapping(
255+
value = LevelConstants.LEVEL_10,
256+
htmlTemplate = "LEVEL_1/PersistentXSS",
257+
variant = Variant.SECURE)
258+
public ResponseEntity<String> getSecurePayloadLevel10(
259+
@RequestParam Map<String, String> queryParams) {
260+
Function<String, String> function =
261+
(post) -> {
262+
String sanitizedPost = StringEscapeUtils.escapeHtml4(post);
263+
sanitizedPost = sanitizedPost.replaceAll("(?i)javascript:", ""); // Delete all the js calls
264+
return StringEscapeUtils.escapeHtml4(sanitizedPost);
265+
};
266+
return new ResponseEntity<>(
267+
this.getCommentsPayload(queryParams, LevelConstants.LEVEL_10, function),
268+
HttpStatus.OK);
269+
}
270+
221271
}

0 commit comments

Comments
 (0)