Study the behavior
-
In Burp's browser, trigger a password reset for the
administratoruser. -
In Proxy > HTTP history, notice the
POST /forgot-passwordrequest and the related/static/js/forgotPassword.jsJavaScript file. -
Right-click the
POST /forgot-passwordrequest and select Send to Repeater. -
In the Repeater tab, resend the request to confirm that the response is consistent.
-
Send a variety of requests with a modified username parameter value to determine whether the input is placed in the URL path of a server-side request without escaping:
Submit URL-encoded
administrator#as the value of theusernameparameter.Notice that this returns an
Invalid routeerror message. This suggests that the server may have placed the input in the path of a server-side request, and that the fragment has truncated some trailing data. Observe that the message also refers to an API definition.Change the value of the username parameter from
administrator%23to URL-encodedadministrator?, then send the request.Notice that this also returns an
Invalid routeerror message. This suggests that the input may be placed in a URL path, as the?character indicates the start of the query string and therefore truncates the URL path.Change the value of the
usernameparameter fromadministrator%3Fto./administratorthen send the request.Notice that this returns the original response. This suggests that the request may have accessed the same URL path as the original request. This further indicates that the input may be placed in the URL path.
Change the value of the username parameter from
./administratorto../administrator, then send the request.Notice that this returns an
Invalid routeerror message. This suggests that the request may have accessed an invalid URL path.
Navigate to the API definition
-
Change the value of the username parameter from
../administratorto../%23. Notice theInvalid routeresponse. -
Incrementally add further
../sequences until you reach../../../../%23Notice that this returns aNot foundresponse. This indicates that you've navigated outside the API root. -
At this level, add some common API definition filenames to the URL path. For example, submit the following:
username=../../../../openapi.json%23Notice that this returns an error message, which contains the following API endpoint for finding users:
/api/internal/v1/users/{username}/field/{field}Notice that this endpoint indicates that the URL path includes a parameter called
field.
Exploit the vulnerability
-
Update the value of the
usernameparameter, using the structure of the identified endpoint. Add an invalid value for thefieldparameter:username=administrator/field/foo%23Send the request. Notice that this returns an error message, because the API only supports the email field.
-
Add
emailas the value of thefieldparameter:username=administrator/field/email%23Send the request. Notice that this returns the original response. This may indicate that the server-side application recognizes the injected
fieldparameter and thatemailis a valid field type. -
In Proxy > HTTP history, review the
/static/js/forgotPassword.jsJavaScript file. Identify the password reset endpoint, which refers to thepasswordResetTokenparameter:/forgot-password?passwordResetToken=${resetToken} -
In the Repeater tab, change the value of the
fieldparameter fromemailtopasswordResetToken:username=administrator/field/passwordResetToken%23Send the request. Notice that this returns an error message, because the
passwordResetTokenparameter is not supported by the version of the API that is set by the application. -
Using the
/api/endpoint that you identified earlier, change the version of the API in the value of theusernameparameter:username=../../v1/users/administrator/field/passwordResetToken%23Send the request. Notice that this returns a password reset token. Make a note of this.
-
In Burp's browser, enter the password reset endpoint in the address bar. Add your password reset token as the value of the
reset_tokenparameter. For example:/forgot-password?passwordResetToken=123456789 -
Set a new password.
-
Log in as the
administratorusing your password. -
Go to the Admin panel and delete
carlosto solve the lab.