Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ private ResponseEntity<?> getURLRedirectionResponseEntity(
htmlTemplate = "LEVEL_1/Http3xxStatusCodeBasedInjection")
public ResponseEntity<?> getVulnerablePayloadLevel1(
@RequestParam(RETURN_TO) String urlToRedirect) {
return this.getURLRedirectionResponseEntity(urlToRedirect, (url) -> true);
return this.getURLRedirectionResponseEntity(urlToRedirect, WHITELISTED_URLS::contains);
}

// Payloads:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,22 @@ void setUp() {
}

@Test
@DisplayName(
"Level 1- test that returnTo query parameter's value is directly added to the Location header")
void test_That_ReturnToQueryParameterValue_IsAddedToLocationHeader_Level1() {
@DisplayName("Level 1- test that external returnTo values are not added to the Location header")
void test_That_ExternalReturnToValue_IsNotAddedToLocationHeader_Level1() {
String redirectUrl = "https://www.malicious.com";
ResponseEntity<?> responseEntity =
http3xxStatusCodeBasedInjection.getVulnerablePayloadLevel1(redirectUrl);
assertThat(
responseEntity
.getHeaders()
.get(LOCATION_HEADER_KEY)
.contains("https://www.malicious.com"))
.isTrue();
assertThat(responseEntity.getHeaders().get(LOCATION_HEADER_KEY)).isNull();
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
}

@Test
@DisplayName("Level 1- test that allowlisted returnTo values still redirect")
void test_That_AllowlistedReturnToValue_IsAddedToLocationHeader_Level1() {
String redirectUrl = "/VulnerableApp/";
ResponseEntity<?> responseEntity =
http3xxStatusCodeBasedInjection.getVulnerablePayloadLevel1(redirectUrl);
assertThat(responseEntity.getHeaders().get(LOCATION_HEADER_KEY)).contains(redirectUrl);
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.FOUND);
}

Expand Down