API testing
API enables software systems and applications to communicate and share data.
API vulnerabilities can undermine confidentiality, integrity, and availability.
All dynamic websites are composed of APIs.
Testing APIs that aren't fully used by the website front-end is a gem (RESTful and JSON APIs).
Test for server-side parameter pollution — this can affect internal APIs.
API recon
Identify API endpoints (the location where an API receives requests about a specific resource on its server).
Example:
GET /api/books HTTP/1.1
Host: example.comThe API endpoint of this request is /api/books. This interacts with the API to retrieve a list of books from the library.
Once you identify an endpoint, determine how to interact with it and construct valid HTTP requests to test the API.
Find out:
Input data the API processes (required and optional parameters).
Types of requests the API accepts (supported HTTP methods and media formats).
Rate limits and authentication mechanisms.
API documentation
APIs are usually documented to help developers use and integrate with them.
Human-readable documentation: for developers.
Machine-readable documentation: structured formats like JSON or XML for automation (integration, validation).
API documentation is often publicly available — start recon by reviewing documentation.
Discovering API documentation
Using the browser or automated crawlers you may find API documentation (sometimes hidden).
Use the browser manually or use Burp Scanner to crawl the app.
Look for endpoints that refer to API documentation:
/api/swagger/index.htmlopenapi.json
If you identify a resource endpoint, investigate the base path (example: resource /api/swagger/v1/users/123 → check /api/swagger/v1, /api/swagger, /api).
You can also discover common documentation paths using intruder.
Lab: Exploiting an API endpoint using documentation
Using machine-readable documentation
Use automated tools to analyse machine-readable API documentation.
Burp Scanner can crawl and audit OpenAPI docs.
Check JSON or YAML documentation.
Parse OpenAPI using tools like OpenParser, BaAp.
Use Postman or SoapUI to test documented endpoints.
Identifying API endpoints
Gather information by browsing applications that use the API (worth doing even if you have docs).
Use Burp Scanner to crawl the app.
Investigate interesting attack surfaces via browser.
Look for patterns that suggest API endpoints during crawls.
Use JS Link Finder BApp or manually review JavaScript files in Burp.
Interacting with API endpoints
Use Burp Repeater to interact with endpoints and confirm hidden endpoints.
Test changes to HTTP method and media type.
Review error messages and other responses to construct valid requests.
Identifying supported HTTP methods
HTTP methods specify the action on a resource:
GET — retrieve data.
PATCH — apply partial changes.
OPTIONS — retrieve supported methods for a resource.
Examples:
GET /api/tasks— list tasks.POST /api/tasks— create a task.DELETE /api/tasks/1— delete task 1.
Use built-in HTTP verb lists in Burp Intruder to cycle through methods.
Note: When testing different HTTP methods, target low-priority objects to avoid unintended consequences.
Identifying supported content types
Endpoints often expect specific formats. Behavior may vary with Content-Type.
Changing Content-Type may:
Trigger errors that disclose useful information.
Bypass flawed defenses.
Exploit differences in processing logic (e.g., secure for JSON but vulnerable for XML).
Modify the
Content-Typeheader and reformat requests.Use Content Type Converter BApp to convert between XML and JSON.
Lab: Finding and exploiting an unused API endpoint
Using Intruder to find hidden endpoints
Once you have initial endpoints, use Intruder to uncover hidden endpoints. Example:
Found
PUT /api/user/update. Add a payload position to/updateand use wordlists likedelete,add.Use wordlists based on common API naming conventions.
Finding hidden parameters
During recon, you may find undocumented parameters. Try using them to change app behavior. Burp tools:
Burp Intruder — use wordlists of common parameter names to add/replace parameters.
Param Miner BApp — can guess many parameter names automatically, relevant to the app.
Content discovery — discover content not linked from visible pages.
Mass assignment vulnerabilities (auto-binding)
Frameworks can bind request parameters to internal object fields, creating unintended parameters.
This can result in the application supporting parameters that were never intended to be processed.
Identifying hidden parameters
Examine objects returned by the API.
Example: PATCH request to update username/email:
GET /api/users/123 returns:
This indicates id and isAdmin may be bound to the internal user object.
Testing mass assignment vulnerabilities
Modify the PATCH request by adding isAdmin:
Send with invalid value:
If behavior differs, the parameter may affect logic. Try setting isAdmin to true:
If no validation, wiener could be granted admin privileges—browse the app as wiener to check.
Lab: Exploiting a mass assignment vulnerability
Server-side parameter pollution (SSPP)
Some APIs are internal and not directly internet-accessible.
SSPP occurs when user input is embedded in a server-side request to an internal API without adequate encoding.
Also called HTTP parameter pollution. It can be used to bypass WAFs.
An attacker may manipulate or inject parameters to:
Override parameters.
Modify application behavior.
Access unauthorized data.
Test all user input for parameter pollution:
Query parameters.
Form fields.
Headers.
URL path parameters.
Testing for SSPP in the query string
Place characters like
#,&,=in input and observe the app response.
Example:
Frontend request:
Server-side internal API request:
Truncating query strings
URL-encode
#to attempt truncation: Modified query:
Frontend will try to access:
Review response to see if server-side query was truncated (e.g., absence of publicProfile=true).
Injecting invalid parameters
URL-encode
&to add a second parameter:
Server-side:
If response changes, injection may have succeeded.
Injecting valid parameters
Add a valid parameter known to the server:
Server-side:
Check how the added parameter is parsed.
Overriding existing parameters
Inject a second parameter with same name:
Server-side:
Behavior varies by server technology:
PHP: last parameter wins.
ASP.NET: combines both — may error.
Node.js/Express: first parameter wins.
If override succeeds, you can try exploits like name=administrator.
Lab: Exploiting SSPP in a query string
Reconnaissance Plan
Trigger password reset for
administratorwith Burp running.Check Proxy > HTTP history for
POST /forgot-passwordand referenced JS/static/js/forgotPassword.js.Send to Repeater and confirm consistency.
Change
usernametoadministratox— responseInvalid username.Add
&x=yencoded:username=administrator%26x=y— responseParameter is not supported(internal API may have received injected parameter).Attempt truncation with
#:username=administrator%23— responseField not specified(server-side query may includefield).Add
&field=x#:username=administrator%26field=x%23— responseInvalid field(server recognizes injected field).Brute-force
fieldvalues.
Attack
Send
POST /forgot-passwordto Intruder.Position payload in
fieldvalue:username=administrator%26field=§x§%23.Use payload list
server-side variable names.Start attack and review 200 responses containing username and email.
Change
fieldtoemail:username=administrator%26field=email%23— returns original response (valid).In JS
/static/js/forgotPassword.js, password reset endpoint usesreset_token:/forgot-password?reset_token=${resetToken}.In Repeater, change
fieldtoreset_token:username=administrator%26field=reset_token%23— returns a password reset token.
Testing SSPP in REST paths
REST APIs may put parameters in the URL path (
/api/users/123).Example where frontend does
GET /edit_Profile.php?name=peterand server-side doesGET /api/private/users/peter.Try adding traversal sequences: URL-encode
peter/../adminaspeter%2f..%2fadmin→ server-side may normalise toapi/private/users/admin.
Lab: Exploiting SSPP in a REST URL
Reconnaissance Plan
Trigger password reset for
administratorwith Burp.In Proxy > HTTP history note
POST /forgot-passwordand/static/js/forgotPassword.js.Send POST to Repeater, test modified
usernamevalues to determine if input is placed in the path:administrator%23→Invalid route(input likely in path).administrator%3F→Invalid route../administrator→ original response (same path).../administrator→Invalid route(invalid path).
Attack
Change
usernameto../%23→Invalid route.Add more
../sequences until../../../../%23→Not found(navigated outside API root).Add common API filenames:
username=../../../../openapi.json%23→ returns error leaking endpoints, e.g./api/internal/v1/users/{username}/field/{field}(indicatesfieldparameter in URL).
Exploit & Enumerate
Update
usernametoadministrator/field/foo%23→ invalid field error (API supports onlyemail).Try
username=administrator/field/email%23→ original response.Inspect
/static/js/forgotPassword.jsfor password reset parampasswordResetToken.In Repeater, set
username=administrator/field/passwordResetToken%23— may error if unsupported by current API version.Use the discovered
/api/endpoint and change version:username=../../v1/users/administrator/field/passwordResetToken%23→ returns password reset token.In browser, visit
/forgot-password?passwordResetToken=123456789, set password, login as admin, go to Admin panel and deletecarlos.
Testing SSPP in structured data formats
Inject unexpected structured data into user inputs and check responses.
Example:
Frontend:
POST /myaccount name=peterServer-side translates to:
If you can make frontend send:
and server-side concatenates without adequate encoding, server may process:
This could grant administrator access.
Another example with JSON:
Browser sends:
Server-side:
If you can make the browser send:
and input is decoded and merged into server-side JSON without encoding, access level could be changed.
Testing with automated tools
Use automated tools to speed up SSPP detection:
Burp Scanner.
Backslash Powered Scanner BApp to identify server-side injection.
Preventing vulnerabilities in APIs
Secure documentation if not intended to be public.
Keep documentation up to date.
Maintain full visibility of API attack surface.
Apply an allowlist of permitted HTTP methods.
Validate content types for requests/responses.
Use generic error messages to avoid leaking information.
Apply protective measures across all API versions.
Use allowlist to define characters that don't need encoding.
Encode user input before including in server-side requests.
Validate that all input adheres to expected formats and structures.
Last updated