AI pentesting guides / By tech stack

Stack guide: AWS

AWS API Gateway security testing

AWS API Gateway security testing checks that every route and method has the authoriser you expect, that the authoriser's decision cannot be reused for resources it should not cover, and that the gateway cannot be reached in a way that skips your CDN or firewall.

API Gateway is a managed service, so the bugs are configuration and integration bugs. They are easy to miss in infrastructure-as-code reviews because the relevant setting is often a single property on one method.

Authorisation gaps

  • Methods with authorization type NONE, often added for testing or CORS preflight and widened to ANY.
  • API keys and usage plans used as authentication. AWS's documentation says API keys are for metering and throttling, not access control.
  • JWT authorisers on HTTP APIs that check the issuer but not the audience or scopes, accepting tokens minted for another app.
  • Backend Lambdas that trust a user ID from the request body instead of the authoriser context.

Lambda authoriser caching

A REST API Lambda authoriser can cache its policy for a token for up to an hour. If the function returns a policy that allows only the specific methodArn it was called for, a cached result can wrongly deny other routes; if it returns a wildcard policy to avoid that, the cached allow covers every route, including admin ones. Test by calling a permitted route, then a forbidden one with the same token within the cache window.

Bypasses around the gateway

  • The default execute-api endpoint stays reachable unless disabled, bypassing CloudFront and any WAF attached there.
  • Old stages (dev, v1) left deployed with weaker settings.
  • Mapping templates or proxy integrations that pass headers such as X-Forwarded-For or internal identity headers straight to backends.
  • CORS responses reflecting any origin with credentials allowed.

Integration-level flaws

Behind the gateway sit Lambda functions, HTTP backends or AWS service integrations. The usual API flaws apply there: BOLA on resource IDs, mass assignment into DynamoDB items, and SSRF in functions that fetch URLs, which on AWS can reach credentials if the function's environment is exposed.

With Pentest-Swarm

Testing API Gateway with Pentest-Swarm

Pentest-Swarm tests the API as a client would, over HTTPS. It does not read your AWS account configuration in this mode.

  • Put both your custom domain and the execute-api hostname in scope so the swarm can compare behaviour between them.
  • If you export an OpenAPI definition from API Gateway and serve it, recon picks it up and maps every route.
  • Run the api-security playbook with tokens for two users and two roles to test object- and function-level authorisation.
  • Check AWS's own pentest policy for your services; Armur's managed platform verifies asset ownership before any test runs.

Where it falls short

A black-box test sees responses, not IAM policies or authoriser code, so it can show that a route is open but not why. Review infrastructure as code with tools such as checkov, and IAM with a cloud posture tool; Pentest-Swarm's arsenal includes checkov, prowler and scoutsuite for that separate cloud-side work.

Questions

Can I use API Gateway API keys for authentication?

AWS advises against it. Use IAM, Cognito, JWT or Lambda authorisers for authentication, and API keys for usage plans.

Do I need AWS permission to pentest my API Gateway?

AWS allows customers to test many services, including API Gateway, without prior approval, within its published policy. Check the current policy before testing.

How do I stop people bypassing CloudFront?

Disable the default execute-api endpoint for REST and HTTP APIs that use a custom domain, or require a secret header from CloudFront.