api-gateway-authorizer-security
Skill51 starsChanged 3 months agoApache-2.0View on GitHub
Secure Amazon API Gateway routes when a scanner reports missing authorization, choose Cognito/OIDC JWT or other business authorizers first, and use an always-allow Lambda authorizer only as an explicitly documented fallback for public routes.
In this repository16 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- agentcore-browser-web-scrapingSkill
- agentcore-mcp-oauth-facadeSkill
- agentic-responsible-ai-assessmentSkill
- aws-agentic-aiSkill
- aws-cdk-developmentSkill
- aws-cost-operationsSkill
- aws-mcp-setupSkill
- cost-estimatorSkill
- create-install-scriptsSkill
- end-to-end-testingSkill
- gitlab-docs-publishingSkill
- quip-to-gitlab-wikiSkill
- security-scanSkill
- strands-context-managerSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
28 rules. About 0 are common, 26 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈26
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 18
If the route requires Cognito, OIDC JWT, IAM, or custom business authorization, use that real authorizer only.
- Distinctive: line 19
If the route is intentionally public and organizational scanning policy requires an authorizer, an always-allow Lambda authorizer may be …
- Distinctive: line 20
Never replace, wrap, or supplement a real business authorizer with the fallback authorizer.
- Distinctive: line 26
Use this skill when:
- Distinctive: line 44
Do not infer protection from an authorizer attachment alone.
- Distinctive: line 56
Treat an authorizer as non-authenticating when any path can grant access without validating caller-controlled credentials.
- Distinctive: line 70
No Cognito, OIDC JWT, IAM, or custom business authorizer is required
- Distinctive: line 98
Prefer configuring the route as explicitly unauthenticated with a narrow, documented scanner exception
- Distinctive: line 99
If policy still requires an authorizer, attach the dedicated always-allow fallback authorizer only to these public routes
- Distinctive: line 101
Keep responses and backend permissions minimal
- Distinctive: line 102
Add appropriate throttling, request-size/schema validation, access logging, alarms, and edge protections
- Very specific: line 103
Add protocol-specific checks in the integration, such as OAuth state/PKCE validation or webhook signature verification
- Very specific: line 106
Never use fallback selection such as businessAuthorizer ??
- Distinctive: line 112
Run the repository's normal validation plus the security scanner that raised the finding:
- Distinctive: line 122
Every protected route has the intended authorization type and authorizer reference
- Distinctive: line 123
Every public route is narrow and intentionally configured
- Distinctive: line 124
Every pass-through authorizer attachment is limited to an explicitly catalogued public route
- Distinctive: line 125
No route with Cognito, OIDC JWT, IAM, or custom business authorization also uses the fallback
- Distinctive: line 142
Never treat the fallback authorizer as authentication or authorization
- Distinctive: line 143
Never attach the fallback to a route that requires or already has a business authorizer
- Distinctive: line 144
Never silently fall back when a required Cognito, OIDC JWT, IAM, or custom authorizer is missing
- Distinctive: line 145
Use the fallback only for explicitly catalogued public routes when scanner exceptions are unavailable
- Distinctive: line 146
Never describe API keys, CORS, obscurity, or throttling as authentication
- Distinctive: line 147
Never apply stack-wide or rule-wide suppression for a route-specific exception
- Distinctive: line 148
Never suppress a protected route's missing authentication
- Distinctive: line 149
Never log credentials or complete authorization events
- Distinctive: line 150
Never weaken a working authorizer to preserve compatibility without explicit approval
- Distinctive: line 151
Verify current AWS and scanner behavior before relying on service-specific capabilities
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
API Gateway Authorizer Security
Review and remediate API Gateway authorization findings without adding security theater merely to make a scanner pass.
Authorizer Precedence Rule
Apply exactly one effective authorizer policy to each route:
- If the route requires Cognito, OIDC JWT, IAM, or custom business authorization, use that real authorizer only.
- If the route is intentionally public and organizational scanning policy requires an authorizer, an always-allow Lambda authorizer may be used only as the documented fallback.
- Never replace, wrap, or supplement a real business authorizer with the fallback authorizer.
The fallback authorizer is a scanner-compatibility control, not authentication. Its name, documentation, route inventory, and review output must state that it grants public access.
When to Apply
Use this skill when:
- A scanner flags an API Gateway route with no authorizer
cdk-nagreportsAwsSolutions-APIG4or a similar authorization finding- A dedicated fallback Lambda authorizer is needed for intentionally public routes
- Public health, sign-in, OAuth callback, or webhook routes need a defensible exception
- API Gateway authorization is being designed or reviewed
Workflow
1. Inventory Effective Route Authorization
Inspect both infrastructure source and the synthesized CloudFormation template. For every route or method, record:
| Route | Method | Exposure | Configured authorizer | Actual security check | Classification |
/example | GET | Public internet | JWT, IAM, Lambda, or none | What is validated | Protected or intentionally public |
Do not infer protection from an authorizer attachment alone. Read the authorizer handler and its configuration.
Useful searches:
rg -n "addRoutes|addMethod|authorizer|authorizationType|isAuthorized|Effect.*Allow" .
npx cdk synth
rg -n "AuthorizationType|AuthorizerId|AuthorizerUri|IdentitySource" cdk.out2. Identify and Classify Pass-Through Authorizers
Treat an authorizer as non-authenticating when any path can grant access without validating caller-controlled credentials. Common indicators include:
- Returning
isAuthorized: truefor every request - Returning an Allow policy before token, signature, claim, or identity validation
- Catching validation errors and allowing the request
- Empty or irrelevant identity sources combined with no request validation
- Accepting unsigned JWTs or decoding claims without verifying the signature
- Validating only that a header exists
- Using an API key or CORS as authentication
- Logging full authorization headers, tokens, or request events
Report these routes as unauthenticated even if the synthesized template references an authorizer. A pass-through authorizer is acceptable only when all of the following are true:
- The route is explicitly classified as intentionally public
- No Cognito, OIDC JWT, IAM, or custom business authorizer is required
- The scanner or organizational policy does not accept an explicit public-route exception
- The fallback is attached only to the named public routes
- Compensating controls and the reason for the fallback are documented
3. Classify Each Route
Choose exactly one classification:
- Protected — accesses user, tenant, administrative, or business data; mutates state; triggers paid or privileged operations.
- Intentionally public — must be callable without an established identity, such as a minimal liveness endpoint, an OAuth callback, or a third-party webhook ingress.
- Unclear — do not suppress the finding; ask for the route's trust boundary, caller, and data classification.
Assume a route is protected unless its public requirement is explicit and documented.
4. Remediate the Root Cause
For protected routes, prefer managed mechanisms in this order when they fit the caller:
- IAM authorization with SigV4 for AWS workloads
- API Gateway JWT or Cognito authorizers for standards-based user or service tokens
- A real Lambda authorizer only for authentication logic unsupported by managed authorizers
- Private API or resource-policy restrictions when network identity is part of the trust boundary
A real Lambda authorizer must deny by default, validate cryptographic credentials and required claims, scope access to the intended route, avoid secret logging, and handle caching without reusing authorization across unrelated routes or tenants.
For intentionally public routes:
- Prefer configuring the route as explicitly unauthenticated with a narrow, documented scanner exception
- If policy still requires an authorizer, attach the dedicated always-allow fallback authorizer only to these public routes
- Narrow the route to required methods and paths; avoid public catch-all proxies
- Keep responses and backend permissions minimal
- Add appropriate throttling, request-size/schema validation, access logging, alarms, and edge protections
- Add protocol-specific checks in the integration, such as OAuth
state/PKCE validation or webhook signature verification - Suppress only the exact scanner finding on the exact route, with a concrete reason and compensating controls
Never use fallback selection such as businessAuthorizer ?? fallbackAuthorizer for protected routes. A missing business authorizer must fail deployment or validation rather than silently making the route public.
See remediation-patterns.md for CDK examples and route-specific controls.
5. Validate
Run the repository's normal validation plus the security scanner that raised the finding:
npm run build
npm test
npx cdk synthThen verify in the synthesized template that:
- Every protected route has the intended authorization type and authorizer reference
- Every public route is narrow and intentionally configured
- Every pass-through authorizer attachment is limited to an explicitly catalogued public route
- No route with Cognito, OIDC JWT, IAM, or custom business authorization also uses the fallback
- Suppressions target only documented public routes
- Scanner output contains no unexplained authorization finding
Required Review Output
Provide:
- A route authorization inventory
- Pass-through authorizer findings with file and line references
- The protected/public decision for each affected route
- Implemented or recommended remediation
- Validation commands and results
- Any fallback authorizer or narrowly scoped suppression and its justification
Enforcement Rules
- Never treat the fallback authorizer as authentication or authorization
- Never attach the fallback to a route that requires or already has a business authorizer
- Never silently fall back when a required Cognito, OIDC JWT, IAM, or custom authorizer is missing
- Use the fallback only for explicitly catalogued public routes when scanner exceptions are unavailable
- Never describe API keys, CORS, obscurity, or throttling as authentication
- Never apply stack-wide or rule-wide suppression for a route-specific exception
- Never suppress a protected route's missing authentication
- Never log credentials or complete authorization events
- Never weaken a working authorizer to preserve compatibility without explicit approval
- Verify current AWS and scanner behavior before relying on service-specific capabilities
References
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

