Skip to content

Commit

Permalink
fix: Stored Cross-Site Scripting Lesson
Browse files Browse the repository at this point in the history
  • Loading branch information
aolle committed Aug 25, 2023
1 parent 8749137 commit 368c046
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ public Category getDefaultCategory() {

@Override
public String getTitle() {
return "xss.title";
return "4.xss.title";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@

import org.owasp.webgoat.container.lessons.Category;
import org.owasp.webgoat.container.lessons.Lesson;
import org.springframework.stereotype.Component;

@Component
public class CrossSiteScriptingStored extends Lesson {
@Override
public Category getDefaultCategory() {
Expand All @@ -33,6 +35,6 @@ public Category getDefaultCategory() {

@Override
public String getTitle() {
return "xss-stored.title";
return "5.xss-stored.title";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
@RestController
public class StoredCrossSiteScriptingVerifier extends AssignmentEndpoint {

// TODO This assignment seems not to be in use in the UI
@PostMapping("/CrossSiteScriptingStored/stored-xss-follow-up")
@ResponseBody
public AttackResult completed(@RequestParam String successMessage) {
Expand All @@ -47,8 +46,3 @@ public AttackResult completed(@RequestParam String successMessage) {
}
}
}

// something like ...
// http://localhost:8080/WebGoat/start.mvc#test/testParam=foobar&_someVar=234902384lotslsfjdOf9889080GarbageHere%3Cscript%3Ewebgoat.customjs.phoneHome();%3C%2Fscript%3E
// or
// http://localhost:8080/WebGoat/start.mvc#test/testParam=foobar&_someVar=234902384lotslsfjdOf9889080GarbageHere<script>webgoat.customjs.phoneHome();<%2Fscript>
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ public class StoredXssComments extends AssignmentEndpoint {
"Can you post a comment, calling webgoat.customjs.phoneHome() ?"));
}

// TODO This assignment seems not to be in use in the UI
@GetMapping(
path = "/CrossSiteScriptingStored/stored-xss",
produces = MediaType.APPLICATION_JSON_VALUE,
Expand All @@ -89,7 +88,6 @@ public Collection<Comment> retrieveComments() {
return allComments;
}

// TODO This assignment seems not to be in use in the UI
@PostMapping("/CrossSiteScriptingStored/stored-xss")
@ResponseBody
public AttackResult createNewComment(@RequestBody String commentStr) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ <h6 class="text-muted time">24 days ago</h6>

<form class="attack-form" accept-charset="UNKNOWN"
method="POST" name="DOMFollowUp"
action="/WebGoat/CrossSiteScripting/stored-xss-follow-up">
action="/WebGoat/CrossSiteScriptingStored/stored-xss-follow-up">
<input name="successMessage" value="" type="TEXT" />
<input name="submitMessage" value="Submit" type="SUBMIT"/>
</form>
Expand Down
5 changes: 3 additions & 2 deletions src/main/resources/lessons/xss/i18n/WebGoatLabels.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# XSS success, failure messages and hints
xss.title=Cross Site Scripting
xss-stored.title=Cross Site Scripting (stored)
4.xss.title=Cross Site Scripting
5.xss-stored.title=Cross Site Scripting (stored)
xss-mitigation.title=Cross Site Scripting (mitigation)

xss-reflected-5a-success-alert=Congratulations, but alerts are not very impressive are they? Let's continue to the next assignment.
xss-reflected-5a-success-console=Congratulations, but console logs are not very impressive are they? Let's continue to the next assignment.
xss-reflected-5a-failed-wrong-field=Seems like you tried to compromise our shop with an reflected XSS attack.<br/> We do our... "best"... to prevent such attacks. Try again!
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/lessons/xss/js/stored-xss.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ $(document).ready(function () {
var commentInput = $("#commentInput").val();
$.ajax({
type: 'POST',
url: 'CrossSiteScripting/stored-xss',
url: '/WebGoat/CrossSiteScriptingStored/stored-xss',
data: JSON.stringify({text: commentInput}),
contentType: "application/json",
dataType: 'json'
Expand Down Expand Up @@ -32,7 +32,7 @@ $(document).ready(function () {

function getChallenges() {
$("#list").empty();
$.get('CrossSiteScripting/stored-xss', function (result, status) {
$.get('/WebGoat/CrossSiteScriptingStored/stored-xss', function (result, status) {
for (var i = 0; i < result.length; i++) {
var comment = html.replace('USER', result[i].user);
comment = comment.replace('DATETIME', result[i].dateTime);
Expand Down

0 comments on commit 368c046

Please sign in to comment.