Skip to main content
10 min read Advanced API

What is API Testing?

API penetration testing is the process of identifying security weaknesses in an API by simulating attacks. The goal is to check for common vulnerabilities such as authentication problems, payment bypass, authorization flaws, data leaks, or misconfigurations, so developers can fix them and keep data safe.

Stay updated with the latest official OWASP API Security guidance here: https://owasp.org/www-project-api-security/

REST API vs SOAP API

AspectREST APISOAP
ProtocolREST uses HTTP/HTTPS, focusing on simple, stateless communication.SOAP works over multiple protocols like HTTP, SMTP, and TCP, offering more versatility.
Data FormatSupports JSON, XML, and other formats, making it lightweight and flexible.Uses XML exclusively, resulting in larger and more verbose messages.
PerformanceFaster due to its simplicity and minimal overhead.Slower because of XML parsing and strict standards.
SecurityRelies on HTTPS, OAuth, and other external mechanisms for security.Has built-in WS-Security for encryption and authentication.
Use CaseBest for lightweight apps, mobile, and web services.Preferred for enterprise apps requiring strict security and complex transactions.

Synchronous and Asynchronous APIs

AspectSynchronous APIAsynchronous API
ExecutionTasks are executed sequentially; the client waits for a response before proceeding.Tasks are executed independently; the client doesn't wait and can continue other operations.
CommunicationBlocking – the client is blocked until the server responds.Non-blocking – the client continues without waiting for the server's response.
PerformanceSlower for long-running tasks as it waits for responses.Faster and more efficient for handling concurrent tasks.
Use CaseSuitable for immediate-response tasks (e.g., login authentication).Ideal for background or long-running tasks (e.g., sending emails, data processing).

OAuth 2.0

Authentication MethodWhy it's SecureUse Case
OAuth 2.0 with Bearer TokensOAuth 2.0 allows for delegated access to resources, meaning users don’t need to share their credentials directly with third-party applications. Bearer tokens are used for authentication, and OAuth can be combined with additional security measures such as PKCE (Proof Key for Code Exchange) for mobile apps.Typically used in modern web applications, APIs, and services where access delegation and permissions are needed (e.g., social media login, third-party service access).

Common Types of API

AspectRESTful APISOAP APIGraphQL APIWebsocket API
ProtocolHTTP/HTTPSHTTP/HTTPSHTTP/HTTPSWebSocket
Message FormatJSON, XMLXMLJSONCustom binary or text-based
Request MethodsGET, POST, PUT, DELETE, etc.POSTPOSTCustom
Endpoint StructureMultiple endpoints for different resourcesSingle endpointSingle endpointSingle endpoint
Query FlexibilityFixed structure for endpoints and data retrievalFixed structure defined by WSDLFlexible query structure for data retrievalReal-time bidirectional communication
Data FetchingPartial data fetching via endpointsPredefined request/response structureFlexible data fetching with custom queriesReal-time data updates
AuthenticationVarious methods (API keys, OAuth, JWT, etc.)Various methods (WS-Security, Basic Auth, etc.)Various methods (API keys, OAuth, JWT, etc.)Custom authentication schemes
Security ProtocolsHTTPS, TLSHTTPS, TLSHTTPS, TLSSSL/TLS
Common VulnerabilitiesInjection attacks (SQLi, XSS, etc.), Broken Authentication, Insecure Direct Object References, etc.XML External Entity (XXE) injection, SOAPAction header injection, etc.Injection attacks, Introspection leaks, Query depth attacks, etc.Message tampering, DoS attacks, Authorization bypass, etc.
Testing ConsiderationsInput validation, Authentication, Authorization, Error handling, Rate limiting, etc.WSDL file disclosures, Message validation, Encryption, etc.Query depth, Introspection, Authorization controls, etc.Message flooding, Message validation, Encryption, etc.

REST API Pentesting Resources

An application programming interface (API) is a way for two or more computer programs or components to communicate with each other.

Tools and Wordlist

ToolsURLWord ListURL
Burp Suite ProDownloadAssetnoteWordlist
PostmanDownloadSecListsGitHub
KiterunnerGitHub
DirbKali Tools
GobusterKali Tools

API Pentesting Resources

CreditURL
Medium Articlehttps://medium.com/geekculture/rest-api-testing-github-postman-62ba105e550e
Hacktricks Bookhttps://book.hacktricks.xyz/network-services-pentesting/pentesting-web/web-api-pentesting
Vaadata Bloghttps://www.vaadata.com/blog/api-penetration-testing-objective-methodology-black-box-grey-box-and-white-box-tests/

GitHub Repositories for API Pentesting

CreditURL
arainhohttps://github.com/arainho/awesome-api-security
m14r41https://github.com/m14r41/PentestingEverything/tree/main/API%20Pentesting

API Security Checklists

CreditURL
Shieldfyhttps://github.com/shieldfy/API-Security-Checklist
APISec.ai Bloghttps://www.apisec.ai/blog/api-security-checklist
Astra Bloghttps://www.getastra.com/blog/api-security/api-security-checklist/
Salt Security Bloghttps://salt.security/blog/api-security-checklist
Indusface Bloghttps://www.indusface.com/blog/api-penetration-testing-checklist/

API Course Free

CreditURL
APISec Universityhttps://www.apisecuniversity.com/courses/api-penetration-testing

Vulnerable APIs

CreditURL
OWASPhttps://github.com/OWASP/crAPI
erev0shttps://github.com/erev0s/VAmPI
roottuskhttps://github.com/roottusk/vapi

Common API Vulnerability and Payment related Test

#Test CasePurposeExample
1Authentication TestingCheck if login/token mechanisms are secure- Weak/default passwords (admin:admin)
- Predictable JWT (userId=1)
- Login bypass via missing/invalid token
2Authorization Testing / IDOREnsure users cannot access other users’ resources- /user/1/profile/user/2/profile returns another user’s info
- /order/100/order/101 shows someone else’s order
3Broken Object Level Authorization (BOLA)Prevent access to objects without proper checks- Modifying orderId or invoiceId in API requests
- Accessing /files/secret.docx by changing file ID
4Excessive Data ExposureVerify API only returns necessary info- /profile returns password hash, SSN, date of birth, or full address
- /orders returns other customers’ email addresses
5Rate Limiting / ThrottlingCheck if API prevents brute force / DoS- Send 1000 login requests in 1 minute
- Flood /reset-password endpoint to check throttling
6Injection TestingIdentify SQL/NoSQL/Command Injection- SQL: username=admin' OR 1=1 --
- MongoDB: {"$gt": ""}
- Command: ; rm -rf / (test sandbox safely)
7Business Logic TestingEnsure app workflow cannot be bypassed or abused- Modify amount in order request
- Skip verification or approval steps
- Redeem same coupon multiple times
8Payment & Checkout TestingEnsure payments and transactions are secure- Change amount or currency in request
- Modify discount or apply multiple times
- Checkout as another user (userId tampering)
- Replay payment requests to simulate double-spending
9Sensitive Data ExposureCheck if PII, secrets, or keys are leaked- API returns API keys, JWT secrets, email, phone numbers
- Passwords or tokens stored in plaintext
10Security MisconfigurationsDetect weak API settings and headers- HTTP instead of HTTPS
- Overly permissive CORS (*)
- Debug info, server version leaks
11Logging & Error HandlingVerify no sensitive info is exposed in errors- Stack traces returned in JSON
- Database errors revealing table/column names
12Session Management TestingValidate token/session security- Session tokens never expire
- Reusable tokens after logout
- JWT with alg: none
13Parameter TamperingTest input modification impacts- Change userId in request
- Alter discount or price values
- Modify role=admin in JSON payload
14Third-party Integration TestingEnsure external APIs cannot be abused- Manipulate callbacks from payment gateways
- Intercept and modify 3rd-party webhook data
15Cryptography / Data Protection TestingCheck proper encryption & token handling- Weak or no TLS (HTTP instead of HTTPS)
- Predictable or unencrypted tokens
- Reversible encryption of sensitive fields

Information Gathering

  • Identify the API's purpose, business logic, and functionality.
  • Enumerate API endpoints and methods (GET, POST, PUT, DELETE, etc.).
  • Gather information about API versioning and changes.
  • Discover hidden or undocumented endpoints using fuzzing and brute force.
  • Obtain API documentation, if available, and review it for insights.

Authentication Testing

  • Test API authentication mechanisms, such as API keys, OAuth, JWT, or basic authentication.
  • Verify if authentication tokens or credentials are securely stored on the client side.
  • Test for missing or weak authentication, including default credentials.
  • Assess multi-factor authentication (MFA) if used.

Authorization Testing

  • Test role-based access control (RBAC) and authorization mechanisms.
  • Check if users can access resources they shouldn't have permissions for.
  • Test for horizontal privilege escalation by manipulating user roles.
  • Verify proper enforcement of access controls, such as admin vs. regular user.

Input Validation

  • Test for input validation and output encoding to prevent injection attacks.
  • Check for SQL injection, Cross-Site Scripting (XSS), and other injection vulnerabilities.
  • Verify if API endpoints properly validate and sanitize user inputs.
  • Assess file upload endpoints for malicious file uploads.

Data Exposure

  • Test for sensitive data exposure through API responses.
  • Verify if the API enforces proper data encryption in transit (HTTPS).
  • Check for information disclosure in error messages.
  • Ensure that data, especially personally identifiable information (PII), is redacted.

Rate Limiting and Resource Exhaustion

  • Test rate limiting and resource exhaustion controls.
  • Check if the API is vulnerable to brute force attacks or denial-of-service (DoS) attacks.
  • Test for API rate limiting bypass techniques.
  • Verify if anti-automation mechanisms are in place.

JWT and OAuth Testing

  • Test JSON Web Tokens (JWT) security, including signature validation.
  • Check for OAuth vulnerabilities, such as authorization code, implicit grant, and client credentials issues.
  • Verify if OAuth tokens are securely managed, rotated, and revoked.
  • Assess OAuth token scope and permissions.

API Rate Limiting

  • Test API rate limiting policies for different user roles.
  • Verify if rate limiting is consistently applied across API endpoints.
  • Check for bypasses or weaknesses in rate limiting controls.
  • Test for API rate limiting abuse and scenarios.

Error Handling

  • Test how the API handles errors and exceptions.
  • Check if error messages reveal sensitive information or internal details.
  • Verify that proper HTTP status codes are returned for different error scenarios.
  • Assess if error messages are consistent and not overly verbose.

Webhooks and Callbacks

  • Test webhooks and callback mechanisms.
  • Check for security vulnerabilities in callback URLs, such as SSRF or unauthorized callbacks.
  • Verify if callbacks are properly authenticated and validated.
  • Test for replay attacks or callback abuse.

image