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 @@ -155,7 +155,7 @@ public ResponseEntity<GenericVulnerabilityResponseBean<Object>> level3(
if (actualToken != null) {
User decodedUser = idorLoginService.decodeToken(actualToken);
int tokenUserId = decodedUser.getUserId();
String role = cookieRole != null ? cookieRole : decodedUser.getRole();
String role = decodedUser.getRole();

if (id == null) {
id = tokenUserId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ void level2_ShouldAllowCookieTampering() {
}

@Test
void level3_ShouldAllowRoleEscalationWhenRoleCookieIsAdmin() {
void level3_ShouldRejectRoleEscalationWhenRoleCookieIsAdmin() {
String fakeToken =
java.util.Base64.getEncoder()
.encodeToString("{\"userId\":2,\"role\":\"USER\"}".getBytes());
Expand All @@ -96,7 +96,8 @@ void level3_ShouldAllowRoleEscalationWhenRoleCookieIsAdmin() {
ResponseEntity<GenericVulnerabilityResponseBean<Object>> response =
idor.level3(fakeToken, "ADMIN", 3);

assertTrue(response.getBody().getIsValid());
assertFalse(response.getBody().getIsValid());
assertEquals("Access Denied - Insufficient privileges", response.getBody().getContent());
}

@Test
Expand Down