Loading

Unmatched Requests Bypass Resource-Level JWT Validation in API Manager

Publiceringsdatum: Oct 22, 2026
Beskrivning

When configuring JSON Web Token (JWT) Validation policies for specific HTTP methods and URI paths using resource conditions in Anypoint API Manager, requests to unmatched, non-existent, or unconfigured paths are allowed through the gateway instead of being denied by default. Attempting to add a catch-all default-deny policy using the regular expression .* blocks all requests, including legitimate traffic to authorized endpoints.

CAUSE

In Anypoint API Manager, a resource-level policy evaluates only when an incoming request matches its configured HTTP method and URI regular expression. If a request does not match any resource-level policy criteria, it evaluates only against API-wide policies. When a valid token satisfies an API-wide JWT Validation policy, the gateway forwards the request to the runtime.

If a separate default-deny policy is configured with the URI regular expression .*, the gateway enforces this policy on every incoming request. Because all policies matching a request must pass evaluation, the catch-all policy causes valid requests to fail.

Lösning

To restrict API access by resource while preventing unintended access to unconfigured paths, choose one of the following approaches:

Approach 1: Leverage APIkit Validation (Recommended)

Allow the API specification (RAML or OAS) and APIkit router to serve as the default allowlist:

  1. Maintain individual JWT Validation policies scoped to specific methods and resource paths under Advanced Options > Apply this policy to requests that match specific conditions.
  2. Configure the API implementation flow to route requests through the APIkit router.
  3. Ensure the application error handling flow handles the APIKIT:NOT_FOUND error. Unmatched endpoints not defined in the specification are rejected by APIkit with an HTTP 404 response, and unmapped HTTP methods are rejected with an HTTP 405 response.

Approach 2: Configure Dedicated Resource Policies in API Manager

If resource-level filtering must be enforced strictly at the gateway level:

  1. In Anypoint API Manager, navigate to the target API instance and select Policies.
  2. Add a JWT Validation policy for each specific resource and HTTP method:
  • Expand Advanced Options.
  • Select Apply this policy to requests that match specific conditions.
  • Specify the corresponding HTTP Method and URI template regex for each permitted resource (for example, separate policies for Read and Write operations).
  1. Do not apply a blanket deny policy with a .* regex across the entire API, as it evaluates against and blocks legitimate matching paths.

Verify:

Send a request with a valid JWT to an unmapped path (for example, /test/unmapped/path). The APIkit router returns an HTTP 404 status code (APIKIT:NOT_FOUND), while configured paths evaluate their respective JWT claims and return HTTP 200.

 

Knowledge-artikelnummer

005462354

 
Laddar
Salesforce Help | Article