Course contentsShow
← Security
Lesson 836 of 3,05217. Web Security - Authorization and Access ControlFree lesson

API Authorization Testing

Specific techniques for testing REST, GraphQL, and other API authorization including direct object references and batch operations.

API Authorization Testing

What you'll learn: How to test authorization in REST, GraphQL, and other APIs by verifying that users can only access resources and operations they're permitted to use.

Why APIs Need Special Authorization Testing

APIs often expose data and functionality in ways that bypass traditional web UI protections. Unlike clicking through a web page, API requests can be crafted directly, making it easier to manipulate identifiers, batch multiple operations together, or access endpoints that aren't properly guarded.

REST API Authorization Testing Techniques

Direct Object References: Test whether changing resource IDs in URLs like /api/users/123 or /api/orders/456 lets you access other users' data. Try sequential IDs, GUIDs from other contexts, and identifiers leaked elsewhere.

HTTP Method Testing: Check if authorization differs by method. Perhaps GET /api/documents/5 is protected but DELETE /api/documents/5 isn't, or POST requires different permissions than PATCH.

Query Parameter Manipulation: Test filters and search parameters like /api/users?role=admin or /api/orders?user_id=789 to see if you can view or modify data belonging to others.

GraphQL-Specific Testing

GraphQL's flexibility creates unique risks. Test deeply nested queries that might bypass authorization checks applied only at top levels. Try introspection queries to discover hidden fields or types, then test whether those fields enforce authorization.

Batch Operations: APIs often allow multiple operations in one request. Test whether authorization is checked for each item individually or just once for the batch—can you sneak unauthorized operations into a legitimate batch?

Testing Approach

Create two test accounts with different permission levels. Capture API requests from one user, then replay them with the other user's credentials. Change identifiers, parameters, and payloads systematically to find gaps where authorization isn't enforced.

Key Takeaway: API authorization testing requires systematically manipulating identifiers, HTTP methods, query parameters, nested queries, and batch operations while using credentials from different user contexts to expose missing or inconsistent access controls.