Skip to content

Commit 1decb60

Browse files
committed
adding comments
1 parent 5b9c157 commit 1decb60

3 files changed

Lines changed: 22 additions & 4 deletions

File tree

core/src/main/kotlin/org/evomaster/core/problem/rest/oracle/RestSecurityOracle.kt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,21 @@ object RestSecurityOracle {
7777
}
7878
}
7979

80+
/**
81+
* Check if there is any protected resource (i.e., one that returns 403 or 401 when accessed without proper authorization),
82+
* but the same resource is also accessible without any authentication.
83+
*/
84+
8085
val a403 = actionsWithResults.filter {
8186
(actionResults.find { r -> r.sourceLocalId == it.getLocalId() } as RestCallResult)
8287
.getStatusCode() == 403
8388
}
8489

90+
val a401 = actionsWithResults.filter {
91+
(actionResults.find { r -> r.sourceLocalId == it.getLocalId() } as RestCallResult)
92+
.getStatusCode() == 401
93+
}
94+
8595
val a200 = actionsWithResults.filter {
8696
(actionResults.find { r -> r.sourceLocalId == it.getLocalId() } as RestCallResult)
8797
.getStatusCode() == 200
@@ -90,7 +100,7 @@ object RestSecurityOracle {
90100
it.auth is NoAuth
91101
}
92102

93-
return a403.isNotEmpty() && a200.isNotEmpty()
103+
return (a403.isNotEmpty() || a401.isNotEmpty()) && a200.isNotEmpty()
94104
}
95105

96106
fun hasExistenceLeakage(

core/src/main/kotlin/org/evomaster/core/problem/rest/service/SecurityRest.kt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,16 @@ class SecurityRest {
604604

605605

606606
/**
607-
* Check if there is a test case with a 403 and another one with a 200 without authentication
607+
* Check if there is a test case with a 403 and another one with a 200 without authentication.
608+
* To check this, a resource must first be created (PUT or POST). While the user who created this
609+
* resource can access it (200), the other user cannot (403). However, if a 200 status code is
610+
* returned when attempting to access the same resource without sending the authorization header,
611+
* it indicates that the authorization has been forgotten.
612+
* Example:
613+
* POST /resources/ AUTH1 -> 201 (location header: /resources/42/)
614+
* GET /resources/42/ AUTH1 -> 200
615+
* GET /resources/42/ AUTH2 -> 403
616+
* GET /resources/42/ AUTH1 -> 200
608617
*/
609618
private fun handleForbiddenAuthentication(){
610619
actionDefinitions.forEach { op ->
@@ -623,7 +632,6 @@ class SecurityRest {
623632
it.individual.copy()
624633
}.forEach { ind ->
625634

626-
//add get request without any auth
627635
val copyLast = ind.seeMainExecutableActions().last().copy() as RestCallAction
628636

629637
if(copyLast.verb != HttpVerb.GET)

wfc/src/main/java/com/webfuzzing/commons/faults/FaultCategory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public enum FaultCategory {
4848
SECURITY_FORBIDDEN_PUT(803, "Forbidden Replacement But Allowed Modifications", "forbidsReplacementButAllowsModifications"),
4949
SECURITY_FORBIDDEN_PATCH(804, "Forbidden Updates But Allowed Modifications", "forbidsUpdatesButAllowsModifications"),
5050
SECURITY_ALLOW_MODIFICATION_BY_ALL(805, "Resource Created By An User Can Be Modified By All Other Users", "createdResourceCanBeModifiedByEveryone"),
51-
SECURITY_FORGOTTEN_AUTHENTICATION(806, "Forgotten Authentication", "forgottenAuthentication")
51+
SECURITY_FORGOTTEN_AUTHENTICATION(806, "A Protected Resource Is Accessible Without Providing Any Authentication", "forgottenAuthentication")
5252

5353
//9xx: undefined
5454
;

0 commit comments

Comments
 (0)