← All articlesWeb security

How to Check REST API Methods and Distinguish 405 from 403 Responses

Restricting HTTP methods for each route is a specific server-side rule: which operations the route accepts and which it rejects. To verify that it works, create a table of routes, allowed methods and required permissions, then compare it with the configuration and actual responses. We will walk through this check using an entirely fictional read-only catalog containing synthetic records we own, without accessing real user data.

Start with a table of routes and methods

A REST API should have an explicit list of allowed HTTP methods. The developer’s practical task is to list the routes and specify the allowed methods and required permissions for each one. The product owner can check whether this table matches the intended operations: viewing the catalog list and an individual record.

For our fictional catalog, we will use the following contract. These are the conditions of this educational example, not a universal set of methods for every REST API. A request using a method outside the list must receive HTTP 405. Compare the table with the actual server configuration, then verify its behavior in your own environment.

  • /catalog — GET is allowed; the catalog:list permission is required.
  • /catalog/{id} — GET is allowed; the catalog:read permission is required.
  • For each route–method pair, record the required permission, server setting, expected response and actual response.

Separate method support from authorization

The method list answers whether a route supports an operation. Authorization answers a different question: whether the caller may use that method for the relevant collection, action and record. Having GET in the table does not mean every user has permission to read the catalog. Authorization must be checked correctly on every request.

The trust boundary here lies between the incoming request and the server’s decision about whether to allow it. Access checks must run on the server, at the gateway or in server-side functions. Methods also need a server-side allowlist against which requests can be checked. If a third-party component configures the restrictions, saving a setting is not enough to establish that it works: it must be verified in the specific environment.

Distinguish the expected rejections: 405 for a method outside the allowlist; 403 when authentication has succeeded but the user lacks permission for the requested resource. These are separate verification criteria.

Prepare the catalog and confirm permitted reads

Run the following scenarios only on a test service you own. Prepare a synthetic record at /catalog/item-demo-17 named ‘Training sample’ and a test user with the catalog:list and catalog:read permissions. Record the expected response contents for the list and the individual record in advance.

First, run a positive control: send GET /catalog and GET /catalog/item-demo-17 as this user. Check that the responses indicate success according to the service contract and that their contents match the prepared data. This example performs reads only.

For each route–GET pair checked, enter the user’s permission, the corresponding server setting and the actual response in the table. This control confirms that the intended reads are available only for the selected routes and user.

Compare an unsupported method with the 405 response

As the same user with read permissions, send POST requests without a body to /catalog and /catalog/item-demo-17. Under the agreed table, neither route supports this method, so HTTP 405 is expected. The requests contain no operation to create or modify a record.

For each route–POST pair, compare three values: the prohibition in the table, the corresponding restriction in the server configuration and the actual 405 response. The user’s read permissions have already been confirmed by the positive control, so a lack of those permissions does not become a separate reason for rejection.

Repeat the comparison for the other routes and methods included in the verification plan. If the configuration or response differs from the contract, record the specific route–method pair, the expected result and the observed discrepancy. One successful request does not confirm that the entire table is correct.

Check authorization rejection separately

For comparison, use the supported GET method and a successfully authenticated test user without the catalog:list and catalog:read permissions. Send GET /catalog and GET /catalog/item-demo-17: HTTP 403 is expected under our example’s contract. Comparing this with the previous test helps show two independent restrictions: the method is supported but the action is forbidden for the user, or the method is absent from the route’s allowlist altogether.

If you find discrepancies, align the server-side method allowlists with the table and ensure that unsupported methods receive 405. Separately, correct the required permission checks on every request. Then repeat the affected scenarios and update the actual results in the table. This example does not specify the order of checks for a request that violates both restrictions at once.

Record the results and the limits of the check

The result should be a verified table of routes, allowed methods and required permissions, linked to the server configuration and actual responses. For both routes, GET with the required permission returned the expected data, unsupported POST received 405, and supported GET without the required permission received 403. These findings apply only to the combinations of routes, methods and permissions tested and do not guarantee the security of the entire API.

Keep the discrepancies found and the retest results alongside the table so it is clear which settings have been confirmed in the specific environment. If you need help assessing your web product, CheckMyApp offers a free audit of your website or the web component of your product.

Sources and documentation

  1. REST Security Cheat Sheet
  2. Authorization Cheat Sheet
CheckMyApp

Check your application’s security.

Enter your web application address and email. Get a free preliminary report and choose the depth of analysis.

Check for free