Logic Flaw
Sometimes authentication processes contain logic flaws. A logic flaw is when the typical logical path of an application is either bypassed, circumvented or manipulated by a hacker.
Last updated
Sometimes authentication processes contain logic flaws. A logic flaw is when the typical logical path of an application is either bypassed, circumvented or manipulated by a hacker.
Last updated
The below mock code example checks to see whether the start of the path the client is visiting begins with /admin and if so, then further checks are made to see whether the client is, in fact, an admin. If the page doesn't begin with /admin, the page is shown to the client.
Because the above PHP code example uses three equals signs (===), it's looking for an exact match on the string, including the same letter casing. The code presents a logic flaw because an unauthenticated user requesting /adMin will not have their privileges checked and have the page displayed to them, totally bypassing the authentication checks.
I'm going to examine the Reset Password function of the Acme IT Support website (http://10.10.13.84/customers/reset). We see a form asking for the email address associated with the account on which we wish to perform the password reset. If an invalid email is entered, i'll receive the error message "Account not found from supplied email address".
For demonstration purposes, I'll use the email address robert@acmeitsupport.thm which is accepted. We're then presented with the next stage of the form, which asks for the username associated with this login email address. If I enter robert as the username and press the Check Username button, i'll be presented with a confirmation message that a password reset email will be sent to robert@acmeitsupport.thm.
In the second step of the reset email process, the username is submitted in a POST field to the web server, and the email address is sent in the query string request as a GET field.
i'll illustrate this by using the curl tool to manually make the request to the webserver.
We use the -H
flag to add an additional header to the request. In this instance, we are setting the Content-Type
to application/x-www-form-urlencoded
, which lets the web server know we are sending form data so it properly understands our request.
In the application, the user account is retrieved using the query string, but later on, in the application logic, the password reset email is sent using the data found in the PHP variable $_REQUEST
.
The PHP $_REQUEST
variable is an array that contains data received from the query string and POST data. If the same key name is used for both the query string and POST data, the application logic for this variable favours POST data fields rather than the query string, so if we add another parameter to the POST form, we can control where the password reset email gets delivered.
For the next step, i'll need to create an account on the Acme IT support customer section, doing so gives you a unique email address that can be used to create support tickets. The email address is in the format of {username}
@customer.acmeitsupport.thm
Now rerunning Curl Request 2 but with my own @acmeitsupport.thm in the email field i'll have a ticket created on my account which contains a link to log me in as Robert. Using Robert's account, I can view their support tickets and reveal a flag.
As you can see i've changed the email to john@customer.acmeitsupport.thm and i've started to receive the support tickets for robert.