API Testing
Pratham Verma
Aspiring Security Engineer | Security Analyst Intern At SafeYourWeb | Penetration Testing | VAPT | WebApp Security | Speaker At Google Developer Groups 2k24
APIs (Application Programming Interfaces) enable software systems and applications to communicate and share data. API testing is important as vulnerabilities in APIs may undermine core aspects of a website’s confidentiality, integrity, and availability.
All dynamic websites are composed of APIs, so classic web vulnerabilities like SQL injection could be classed as API testing.
API recon
To start API testing, you first need to find out as much information about the API as possible, you should identify API endpoints. These are locations where an API receives requests about a specific resource on its server.
For example, consider the following GET request: GET /api/books HTTP/1.1 Host: example.com
The API endpoint for this request is /api/books. This results in an interaction with the API to retrieve a list of books from a library.
Once you have identified the endpoints, you need to determine how to interact with them. This enables you to construct valid HTTP requests to test the API. For example, you should find out information about the following:
you can use Burp Scanner to crawl the API. You can also browse applications manually using Burp’s browser.
If you identify an endpoint for a resource, make sure to investigate the base path. For example, if you identify the resource endpoint /api/swagger/v1/users/123, then you should investigate the following paths:
Identifying API endpoints
look for patterns that suggest API endpoints in the URL structure, such as /api/. Also look out for JavaScript files. These can contain references to API endpoints that you haven't triggered directly via the web browser. Burp Scanner automatically extracts some endpoints during crawls, but for a more heavyweight extraction, use the JS Link Finder BApp. You can also manually review JavaScript files in Burp.
Identifying supported HTTP methods
The HTTP method specifies the action to be performed on a resource. For example:
An API endpoint may support different HTTP methods. It’s therefore important to test all potential methods when you’re investigating API endpoints. This may enable you to identify additional endpoint functionality, opening up more attack surface.
For example, the endpoint /api/tasks may support the following methods:
Identifying supported content types
API endpoints often expect data in a specific format. They may therefore behave differently depending on the content type of the data provided in a request. Changing the content type may enable you to:
To change the content type, modify the Content-Type header, then reformat the request body accordingly. You can use the Content type converter Burp App to automatically convert data submitted within requests between XML and JSON.
Using Intruder to find hidden endpoints
Once you have identified some initial API endpoints, you can use Intruder to uncover hidden endpoints. For example, consider a scenario where you have identified the following API endpoint for updating user information:
PUT /api/user/update
To identify hidden endpoints, you could use Burp Intruder to find other resources with the same structure. For example, you could add a payload to the /update position of the path with a list of other common functions, such as delete and add.
When looking for hidden endpoints, use wordlists based on common API naming conventions and industry terms. Make sure you also include terms that are relevant to the application, based on your initial recon.
Preventing vulnerabilities in APIs
When designing APIs, make sure that security is a consideration from the beginning. In particular, make sure that you:
Conclusion
API testing is a critical part of the software development lifecycle, ensuring that your applications communicate correctly and reliably. By implementing comprehensive testing strategies, from functional and performance testing to security testing, you can identify and fix potential issues early, leading to more robust and user-friendly software.
Ready to take your API testing to the next level? Share your favorite API testing tools or tips in the comments below! And don’t forget to follow me for more insights and best practices on software testing and development.
https://www.dhirubhai.net/posts/crosscheck-cloud_softwaretestting-automation-manualtesting-activity-7237043135732736001-Gov9?utm_source=share&utm_medium=member_desktop
Aspiring Machine Learning Engineer | Data Analyst | Solving Problems with Data
7 个月Great Work! Your post is really helpful.
Aspiring Cyber Security Engineer | Java | DSA | ML | Leetcode 4 ? (1800+) | Kaggle 2X Expert
7 个月Great Job! keep going bro
BTech CSE AIML || Pre-Final Year @GU || Member @IEEE GU|| DSA || C++ || Frontend developer||GSSoC'24 Contributor||SIH'24 Finalist||NASA Space challenge
7 个月Great advice!