API testing
PortSwigger Web Security Academy · Apprentice
- #API

Exploiting an API endpoint using documentation
The vulnerability
The API documentation is open to everyone. It lists a DELETE request for users, and the server doesn’t check who sends it.
Fix: Check permissions on every endpoint. Internal documentation shouldn’t be public either.
The lab
To solve the lab, find the exposed API documentation and delete carlos. You can log in to your own account using the following credentials: wiener:peter.
Solution
1. Log In to the Application: Log in to the application using the provided credentials: wiener:peter.
2. Observe API Interaction: On your profile page, update your email address. In Burp Suite’s Proxy -> HTTP history, look at the API request made, likely PATCH /api/user/wiener.
3. Discover API Documentation: In your web browser, visit the /api endpoint. This should present the API documentation, which reveals various API endpoints and their functionalities.

4. Intercept API Documentation Request: In Burp Suite, send the GET /API request (the one that loaded the documentation) to Repeater. This is primarily to have a base request within Repeater.
5. Delete the Target User via API: In Repeater, modify the request. Change the HTTP method to DELETE and the path to /api/user/carlos. Send this request. An HTTP/2 200 OK indicates the user carlos has been deleted, and the lab is solved.
