[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M73CBHW8ZCS7R85MA0EZJTBY":3,"skill-same:01M73CBHW8ZCS7R85MA0EZJTBY":90},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":16,"sourceHtmlUrl":17,"categories":18,"keywords":19,"publishedAt":20,"linkOnly":21,"markdownContent":22,"markdownBody":23,"frontMatter":24,"refName":50,"commitSha":51,"skillDirectory":52,"forksCount":53,"repositoryHtmlUrl":54,"repositoryHomepageUrl":55,"ownerHtmlUrl":56,"ownerBlogUrl":57,"ownerDescription":58,"updatedAt":59,"install":60,"resources":73},"01M73CBHW8ZCS7R85MA0EZJTBY","implementing-api-gateway-security-controls",null,"Implements security controls at the API gateway layer including authentication enforcement, rate limiting, request validation, IP allowlisting, TLS termination, and threat protection. The engineer configures API gateways (Kong, AWS API Gateway, Azure APIM, Apigee) to act as a centralized security enforcement point that validates, throttles, and monitors all API traffic before it reaches backend services. Activates for requests involving API gateway security, API management security, gateway authentication, or centralized API protection.","Horonomos-laps\u002FYana-AI","Horonomos-laps","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F355299122?v=4","01M76B3QPXE88ET2SQPDPVATZT"," Horonomos-laps","01M72ZQRJPCYPSSWT4D00VJR2A",13,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Fyanacuti1121\u002FYana-AI\u002Fblob\u002Fmain\u002Fcore\u002Fskills\u002Fimplementing-api-gateway-security-controls\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002Fcore\u002Fskills\u002Fimplementing-api-gateway-security-controls\u002FSKILL.md",[],[],"2026-11-11 15:11:14",false,"---\nname: implementing-api-gateway-security-controls\ndescription: 'Implements security controls at the API gateway layer including authentication\n  enforcement, rate limiting, request validation, IP allowlisting, TLS termination,\n  and threat protection. The engineer configures API gateways (Kong, AWS API Gateway,\n  Azure APIM, Apigee) to act as a centralized security enforcement point that validates,\n  throttles, and monitors all API traffic before it reaches backend services. Activates\n  for requests involving API gateway security, API management security, gateway authentication,\n  or centralized API protection.\n\n  '\ndomain: cybersecurity\nsubdomain: api-security\ntags:\n- api-security\n- api-gateway\n- kong\n- aws-api-gateway\n- rate-limiting\n- waf\nversion: 1.0.0\nauthor: mahipal\nlicense: Apache-2.0\nnist_csf:\n- PR.PS-01\n- ID.RA-01\n- PR.DS-10\n- DE.CM-01\nmitre_attack:\n- T1190\n- T1059.007\n- T1552.001\n- T1078.004\n- T1530\nsource: https:\u002F\u002Fgithub.com\u002Fmukul975\u002FAnthropic-Cybersecurity-Skills\nsource_commit: 04450304b12645cb2b974ab96d28c0664758a88d\nnote: \"Vendored verbatim from an external Apache-2.0 security-skill library, pinned by commit. Exceeds the internal 300-line skill guideline (agent-code-constraints.md) -- kept as-is because this is vendored reference material (forensics\u002Fthreat-intel procedure), not Yana AI-authored content, and trimming would damage technical accuracy.\"\n---\n# Implementing API Gateway Security Controls\n\n## When to Use\n\n- Deploying a centralized authentication and authorization layer for microservice APIs\n- Implementing rate limiting, throttling, and quota management across all API endpoints\n- Configuring request\u002Fresponse validation against OpenAPI specifications at the gateway level\n- Setting up TLS termination, mutual TLS, and certificate management for API traffic\n- Integrating WAF rules with the API gateway to block injection, XSS, and known attack patterns\n\n**Do not use** as the sole security layer. API gateways provide defense in depth but backend services must also validate authorization and input.\n\n## Prerequisites\n\n- API gateway platform selected and deployed (Kong, AWS API Gateway, Azure APIM, or Apigee)\n- OpenAPI\u002FSwagger specifications for all backend APIs\n- TLS certificates for the gateway domain\n- Identity provider (IdP) configured for OAuth2\u002FOIDC (Okta, Auth0, Azure AD)\n- Monitoring and logging infrastructure (CloudWatch, Datadog, ELK)\n- Backend service endpoints registered and reachable from the gateway\n\n## Workflow\n\n### Step 1: Kong Gateway Security Configuration\n\n```yaml\n# kong.yml - Declarative Kong configuration with security plugins\n_format_version: \"3.0\"\n\nservices:\n  - name: user-service\n    url: http:\u002F\u002Fuser-service:8080\n    routes:\n      - name: user-api\n        paths:\n          - \u002Fapi\u002Fv1\u002Fusers\n        methods:\n          - GET\n          - POST\n          - PUT\n          - PATCH\n          - DELETE\n        strip_path: false\n\nplugins:\n  # 1. Authentication: JWT validation\n  - name: jwt\n    config:\n      uri_param_names:\n        - jwt\n      header_names:\n        - Authorization\n      claims_to_verify:\n        - exp\n      maximum_expiration: 3600  # Max 1 hour token TTL\n\n  # 2. Rate Limiting\n  - name: rate-limiting\n    config:\n      minute: 60\n      hour: 1000\n      policy: redis\n      redis_host: redis\n      redis_port: 6379\n      fault_tolerant: true\n      hide_client_headers: false\n      limit_by: credential  # Per-user, not per-IP\n\n  # 3. Request Size Limiting\n  - name: request-size-limiting\n    config:\n      allowed_payload_size: 1  # 1 MB max\n      size_unit: megabytes\n\n  # 4. IP Restriction (admin endpoints)\n  - name: ip-restriction\n    service: admin-service\n    config:\n      allow:\n        - 10.0.0.0\u002F8\n        - 172.16.0.0\u002F12\n\n  # 5. Bot Detection\n  - name: bot-detection\n    config:\n      deny:\n        - \"sqlmap\"\n        - \"nikto\"\n        - \"nmap\"\n        - \"masscan\"\n\n  # 6. CORS Configuration\n  - name: cors\n    config:\n      origins:\n        - \"https:\u002F\u002Fapp.example.com\"\n      methods:\n        - GET\n        - POST\n        - PUT\n        - PATCH\n        - DELETE\n      headers:\n        - Authorization\n        - Content-Type\n      credentials: true\n      max_age: 3600\n\n  # 7. Response Transformer - Remove sensitive headers\n  - name: response-transformer\n    config:\n      remove:\n        headers:\n          - X-Powered-By\n          - Server\n      add:\n        headers:\n          - \"X-Content-Type-Options: nosniff\"\n          - \"X-Frame-Options: DENY\"\n          - \"Strict-Transport-Security: max-age=31536000; includeSubDomains\"\n          - \"Content-Security-Policy: default-src 'none'\"\n```\n\n### Step 2: AWS API Gateway Security Configuration\n\n```python\nimport boto3\nimport json\n\napigw = boto3.client('apigatewayv2')\n\n# Create API with mutual TLS\napi_response = apigw.create_api(\n    Name='secure-api',\n    ProtocolType='HTTP',\n    DisableExecuteApiEndpoint=True,  # Force custom domain\n)\napi_id = api_response['ApiId']\n\n# Configure authorizer (JWT with Cognito)\nauthorizer = apigw.create_authorizer(\n    ApiId=api_id,\n    AuthorizerType='JWT',\n    IdentitySource='$request.header.Authorization',\n    Name='cognito-jwt-authorizer',\n    JwtConfiguration={\n        'Audience': ['your-app-client-id'],\n        'Issuer': 'https:\u002F\u002Fcognito-idp.us-east-1.amazonaws.com\u002Fus-east-1_xxxxx'\n    }\n)\n\n# Create route with authorizer\napigw.create_route(\n    ApiId=api_id,\n    RouteKey='GET \u002Fapi\u002Fv1\u002Fusers',\n    AuthorizerId=authorizer['AuthorizerId'],\n    AuthorizationType='JWT',\n)\n\n# Configure throttling\napigw.create_stage(\n    ApiId=api_id,\n    StageName='prod',\n    DefaultRouteSettings={\n        'ThrottlingBurstLimit': 100,\n        'ThrottlingRateLimit': 50.0,  # 50 requests per second\n    },\n    AccessLogSettings={\n        'DestinationArn': 'arn:aws:logs:us-east-1:123456789:log-group:api-access-logs',\n        'Format': json.dumps({\n            'requestId': '$context.requestId',\n            'ip': '$context.identity.sourceIp',\n            'caller': '$context.identity.caller',\n            'user': '$context.identity.user',\n            'requestTime': '$context.requestTime',\n            'httpMethod': '$context.httpMethod',\n            'resourcePath': '$context.resourcePath',\n            'status': '$context.status',\n            'protocol': '$context.protocol',\n            'responseLength': '$context.responseLength'\n        })\n    }\n)\n\n# WAF association\nwaf = boto3.client('wafv2')\nweb_acl = waf.create_web_acl(\n    Name='api-security-acl',\n    Scope='REGIONAL',\n    DefaultAction={'Allow': {}},\n    Rules=[\n        {\n            'Name': 'AWS-AWSManagedRulesSQLiRuleSet',\n            'Priority': 1,\n            'Statement': {\n                'ManagedRuleGroupStatement': {\n                    'VendorName': 'AWS',\n                    'Name': 'AWSManagedRulesSQLiRuleSet'\n                }\n            },\n            'OverrideAction': {'None': {}},\n            'VisibilityConfig': {\n                'SampledRequestsEnabled': True,\n                'CloudWatchMetricsEnabled': True,\n                'MetricName': 'SQLiRuleSet'\n            }\n        },\n        {\n            'Name': 'RateLimit',\n            'Priority': 2,\n            'Statement': {\n                'RateBasedStatement': {\n                    'Limit': 2000,\n                    'AggregateKeyType': 'IP'\n                }\n            },\n            'Action': {'Block': {}},\n            'VisibilityConfig': {\n                'SampledRequestsEnabled': True,\n                'CloudWatchMetricsEnabled': True,\n                'MetricName': 'RateLimitRule'\n            }\n        },\n    ],\n    VisibilityConfig={\n        'SampledRequestsEnabled': True,\n        'CloudWatchMetricsEnabled': True,\n        'MetricName': 'ApiSecurityACL'\n    }\n)\n```\n\n### Step 3: Request Validation with OpenAPI Schema\n\n```yaml\n# Kong OAS Validation Plugin configuration\nplugins:\n  - name: oas-validation\n    config:\n      api_spec: |\n        openapi: \"3.0.3\"\n        info:\n          title: Secure API\n          version: \"1.0\"\n        paths:\n          \u002Fapi\u002Fv1\u002Fusers:\n            post:\n              requestBody:\n                required: true\n                content:\n                  application\u002Fjson:\n                    schema:\n                      type: object\n                      required: [name, email]\n                      properties:\n                        name:\n                          type: string\n                          maxLength: 100\n                          pattern: \"^[a-zA-Z ]+$\"\n                        email:\n                          type: string\n                          format: email\n                          maxLength: 255\n                      additionalProperties: false  # Block mass assignment\n              responses:\n                '201':\n                  description: User created\n      validate_request_body: true\n      validate_request_header_params: true\n      validate_request_query_params: true\n      validate_request_uri_params: true\n      verbose_response: false  # Do not expose schema details in errors\n```\n\n### Step 4: Mutual TLS Configuration\n\n```bash\n# Generate CA and client certificates for mTLS\n# 1. Create CA\nopenssl genrsa -out ca.key 4096\nopenssl req -new -x509 -key ca.key -out ca.crt -days 365 \\\n    -subj \"\u002FCN=API Gateway CA\u002FO=Example Corp\"\n\n# 2. Create client certificate\nopenssl genrsa -out client.key 2048\nopenssl req -new -key client.key -out client.csr \\\n    -subj \"\u002FCN=api-client\u002FO=Example Corp\"\nopenssl x509 -req -in client.csr -CA ca.crt -CAkey ca.key \\\n    -CAcreateserial -out client.crt -days 365\n\n# Kong mTLS configuration\n# Upload CA certificate to Kong\ncurl -X POST http:\u002F\u002Fkong-admin:8001\u002Fca_certificates \\\n    -F \"cert=@ca.crt\"\n\n# Enable mTLS plugin\ncurl -X POST http:\u002F\u002Fkong-admin:8001\u002Fservices\u002Fuser-service\u002Fplugins \\\n    --data \"name=mtls-auth\" \\\n    --data \"config.ca_certificates[]=$(cat ca_cert_id)\" \\\n    --data \"config.revocation_check_mode=SKIP\" \\\n    --data \"config.authenticated_group_by=CN\"\n```\n\n### Step 5: Logging and Monitoring Configuration\n\n```python\n# CloudWatch monitoring for API security events\nimport boto3\n\ncloudwatch = boto3.client('cloudwatch')\nlogs = boto3.client('logs')\n\n# Create metric filters for security events\nsecurity_filters = [\n    {\n        'name': 'UnauthorizedAccess',\n        'pattern': '{ $.status = 401 || $.status = 403 }',\n        'metric': 'UnauthorizedAccessCount'\n    },\n    {\n        'name': 'RateLimitHits',\n        'pattern': '{ $.status = 429 }',\n        'metric': 'RateLimitHitCount'\n    },\n    {\n        'name': 'ServerErrors',\n        'pattern': '{ $.status >= 500 }',\n        'metric': 'ServerErrorCount'\n    },\n    {\n        'name': 'LargeResponses',\n        'pattern': '{ $.responseLength > 1000000 }',\n        'metric': 'LargeResponseCount'\n    },\n]\n\nfor sf in security_filters:\n    logs.put_metric_filter(\n        logGroupName='api-access-logs',\n        filterName=sf['name'],\n        filterPattern=sf['pattern'],\n        metricTransformations=[{\n            'metricName': sf['metric'],\n            'metricNamespace': 'APISecurityMetrics',\n            'metricValue': '1',\n            'defaultValue': 0\n        }]\n    )\n\n# Create alarm for unusual 401\u002F403 spike\ncloudwatch.put_metric_alarm(\n    AlarmName='API-UnauthorizedAccessSpike',\n    MetricName='UnauthorizedAccessCount',\n    Namespace='APISecurityMetrics',\n    Statistic='Sum',\n    Period=300,  # 5 minutes\n    EvaluationPeriods=1,\n    Threshold=100,\n    ComparisonOperator='GreaterThanThreshold',\n    AlarmActions=['arn:aws:sns:us-east-1:123456789:security-alerts'],\n    AlarmDescription='More than 100 unauthorized access attempts in 5 minutes'\n)\n```\n\n## Key Concepts\n\n| Term | Definition |\n|------|------------|\n| **API Gateway** | Centralized entry point for all API traffic that enforces authentication, authorization, rate limiting, and request validation before routing to backend services |\n| **Rate Limiting** | Controlling the number of API requests per client within a time window to prevent abuse and ensure fair resource allocation |\n| **Request Validation** | Verifying that incoming API requests conform to the expected schema (data types, required fields, value ranges) before forwarding to backend services |\n| **Mutual TLS (mTLS)** | Two-way TLS authentication where both the client and server present certificates, providing strong identity verification for API-to-API communication |\n| **WAF Integration** | Web Application Firewall rules applied at the API gateway to block common attack patterns (SQLi, XSS, path traversal) |\n| **OAuth2\u002FOIDC** | Token-based authentication protocols where the gateway validates JWT tokens against an identity provider before allowing access |\n\n## Tools & Systems\n\n- **Kong Gateway**: Open-source API gateway with extensive plugin ecosystem for security, rate limiting, and authentication\n- **AWS API Gateway**: Managed API gateway service with built-in throttling, WAF integration, and Lambda authorizers\n- **Azure API Management**: Enterprise API gateway with policy-based security, developer portal, and Azure AD integration\n- **Apigee (Google Cloud)**: API management platform with threat protection, quota management, and API analytics\n- **Envoy Proxy**: High-performance proxy used as API gateway in service mesh architectures with extensive filter chain\n\n## Common Scenarios\n\n### Scenario: Securing a Microservice API with Kong Gateway\n\n**Context**: A company is migrating from a monolithic API to microservices. Each microservice has its own REST API. The security team needs to implement centralized authentication, rate limiting, and request validation without modifying each service.\n\n**Approach**:\n1. Deploy Kong Gateway as the single entry point, routing traffic to 8 backend microservices\n2. Configure JWT validation plugin to verify tokens against the company's Keycloak IdP\n3. Apply rate limiting: 60 requests\u002Fminute for regular users, 300\u002Fminute for premium users, identified by JWT claims\n4. Enable OAS validation plugin to reject requests that do not match the OpenAPI spec (blocks mass assignment and injection)\n5. Configure mTLS for service-to-service communication behind the gateway\n6. Set up response transformer to remove Server and X-Powered-By headers and add security headers\n7. Integrate with AWS WAF for SQL injection and XSS protection rules\n8. Configure access logging to CloudWatch with security metric filters and alerting\n\n**Pitfalls**:\n- Relying solely on the gateway for authorization when backend services also need to verify permissions\n- Not configuring rate limiting per authenticated user (per-IP only allows attackers to bypass with IP rotation)\n- Using verbose error responses from the gateway that reveal internal service architecture\n- Not testing the gateway configuration with security tools after deployment\n- Missing mutual TLS between the gateway and backend services, allowing direct backend access\n\n## Output Format\n\n```\n## API Gateway Security Configuration Report\n\n**Gateway**: Kong 3.5 (Kubernetes deployment)\n**Backend Services**: 8 microservices\n**Date**: 2024-12-15\n\n### Security Controls Implemented\n\n| Control | Plugin\u002FFeature | Configuration |\n|---------|---------------|---------------|\n| Authentication | JWT Plugin | Cognito IdP, 1-hour max TTL |\n| Rate Limiting | Rate Limiting Plugin | 60 req\u002Fmin (user), Redis-backed |\n| Request Validation | OAS Validation | Strict mode, no additional properties |\n| TLS | Kong TLS | TLS 1.3 only, HSTS enabled |\n| mTLS | mTLS Auth Plugin | Client cert required for admin APIs |\n| WAF | AWS WAF | SQLi, XSS, rate-based rules |\n| Headers | Response Transformer | Server header removed, security headers added |\n| Logging | HTTP Log Plugin | CloudWatch, security metric filters |\n\n### Verification Results\n\n- JWT validation: Expired\u002Finvalid tokens correctly rejected (tested 50 payloads)\n- Rate limiting: Enforced at 60 req\u002Fmin, 429 returned with Retry-After header\n- Request validation: Malformed requests rejected with 400 (tested 30 invalid payloads)\n- mTLS: Requests without client certificate rejected with 401\n- WAF: SQL injection payloads blocked (tested top 100 SQLi patterns)\n```\n","# Implementing API Gateway Security Controls\n\n## When to Use\n\n- Deploying a centralized authentication and authorization layer for microservice APIs\n- Implementing rate limiting, throttling, and quota management across all API endpoints\n- Configuring request\u002Fresponse validation against OpenAPI specifications at the gateway level\n- Setting up TLS termination, mutual TLS, and certificate management for API traffic\n- Integrating WAF rules with the API gateway to block injection, XSS, and known attack patterns\n\n**Do not use** as the sole security layer. API gateways provide defense in depth but backend services must also validate authorization and input.\n\n## Prerequisites\n\n- API gateway platform selected and deployed (Kong, AWS API Gateway, Azure APIM, or Apigee)\n- OpenAPI\u002FSwagger specifications for all backend APIs\n- TLS certificates for the gateway domain\n- Identity provider (IdP) configured for OAuth2\u002FOIDC (Okta, Auth0, Azure AD)\n- Monitoring and logging infrastructure (CloudWatch, Datadog, ELK)\n- Backend service endpoints registered and reachable from the gateway\n\n## Workflow\n\n### Step 1: Kong Gateway Security Configuration\n\n```yaml\n# kong.yml - Declarative Kong configuration with security plugins\n_format_version: \"3.0\"\n\nservices:\n  - name: user-service\n    url: http:\u002F\u002Fuser-service:8080\n    routes:\n      - name: user-api\n        paths:\n          - \u002Fapi\u002Fv1\u002Fusers\n        methods:\n          - GET\n          - POST\n          - PUT\n          - PATCH\n          - DELETE\n        strip_path: false\n\nplugins:\n  # 1. Authentication: JWT validation\n  - name: jwt\n    config:\n      uri_param_names:\n        - jwt\n      header_names:\n        - Authorization\n      claims_to_verify:\n        - exp\n      maximum_expiration: 3600  # Max 1 hour token TTL\n\n  # 2. Rate Limiting\n  - name: rate-limiting\n    config:\n      minute: 60\n      hour: 1000\n      policy: redis\n      redis_host: redis\n      redis_port: 6379\n      fault_tolerant: true\n      hide_client_headers: false\n      limit_by: credential  # Per-user, not per-IP\n\n  # 3. Request Size Limiting\n  - name: request-size-limiting\n    config:\n      allowed_payload_size: 1  # 1 MB max\n      size_unit: megabytes\n\n  # 4. IP Restriction (admin endpoints)\n  - name: ip-restriction\n    service: admin-service\n    config:\n      allow:\n        - 10.0.0.0\u002F8\n        - 172.16.0.0\u002F12\n\n  # 5. Bot Detection\n  - name: bot-detection\n    config:\n      deny:\n        - \"sqlmap\"\n        - \"nikto\"\n        - \"nmap\"\n        - \"masscan\"\n\n  # 6. CORS Configuration\n  - name: cors\n    config:\n      origins:\n        - \"https:\u002F\u002Fapp.example.com\"\n      methods:\n        - GET\n        - POST\n        - PUT\n        - PATCH\n        - DELETE\n      headers:\n        - Authorization\n        - Content-Type\n      credentials: true\n      max_age: 3600\n\n  # 7. Response Transformer - Remove sensitive headers\n  - name: response-transformer\n    config:\n      remove:\n        headers:\n          - X-Powered-By\n          - Server\n      add:\n        headers:\n          - \"X-Content-Type-Options: nosniff\"\n          - \"X-Frame-Options: DENY\"\n          - \"Strict-Transport-Security: max-age=31536000; includeSubDomains\"\n          - \"Content-Security-Policy: default-src 'none'\"\n```\n\n### Step 2: AWS API Gateway Security Configuration\n\n```python\nimport boto3\nimport json\n\napigw = boto3.client('apigatewayv2')\n\n# Create API with mutual TLS\napi_response = apigw.create_api(\n    Name='secure-api',\n    ProtocolType='HTTP',\n    DisableExecuteApiEndpoint=True,  # Force custom domain\n)\napi_id = api_response['ApiId']\n\n# Configure authorizer (JWT with Cognito)\nauthorizer = apigw.create_authorizer(\n    ApiId=api_id,\n    AuthorizerType='JWT',\n    IdentitySource='$request.header.Authorization',\n    Name='cognito-jwt-authorizer',\n    JwtConfiguration={\n        'Audience': ['your-app-client-id'],\n        'Issuer': 'https:\u002F\u002Fcognito-idp.us-east-1.amazonaws.com\u002Fus-east-1_xxxxx'\n    }\n)\n\n# Create route with authorizer\napigw.create_route(\n    ApiId=api_id,\n    RouteKey='GET \u002Fapi\u002Fv1\u002Fusers',\n    AuthorizerId=authorizer['AuthorizerId'],\n    AuthorizationType='JWT',\n)\n\n# Configure throttling\napigw.create_stage(\n    ApiId=api_id,\n    StageName='prod',\n    DefaultRouteSettings={\n        'ThrottlingBurstLimit': 100,\n        'ThrottlingRateLimit': 50.0,  # 50 requests per second\n    },\n    AccessLogSettings={\n        'DestinationArn': 'arn:aws:logs:us-east-1:123456789:log-group:api-access-logs',\n        'Format': json.dumps({\n            'requestId': '$context.requestId',\n            'ip': '$context.identity.sourceIp',\n            'caller': '$context.identity.caller',\n            'user': '$context.identity.user',\n            'requestTime': '$context.requestTime',\n            'httpMethod': '$context.httpMethod',\n            'resourcePath': '$context.resourcePath',\n            'status': '$context.status',\n            'protocol': '$context.protocol',\n            'responseLength': '$context.responseLength'\n        })\n    }\n)\n\n# WAF association\nwaf = boto3.client('wafv2')\nweb_acl = waf.create_web_acl(\n    Name='api-security-acl',\n    Scope='REGIONAL',\n    DefaultAction={'Allow': {}},\n    Rules=[\n        {\n            'Name': 'AWS-AWSManagedRulesSQLiRuleSet',\n            'Priority': 1,\n            'Statement': {\n                'ManagedRuleGroupStatement': {\n                    'VendorName': 'AWS',\n                    'Name': 'AWSManagedRulesSQLiRuleSet'\n                }\n            },\n            'OverrideAction': {'None': {}},\n            'VisibilityConfig': {\n                'SampledRequestsEnabled': True,\n                'CloudWatchMetricsEnabled': True,\n                'MetricName': 'SQLiRuleSet'\n            }\n        },\n        {\n            'Name': 'RateLimit',\n            'Priority': 2,\n            'Statement': {\n                'RateBasedStatement': {\n                    'Limit': 2000,\n                    'AggregateKeyType': 'IP'\n                }\n            },\n            'Action': {'Block': {}},\n            'VisibilityConfig': {\n                'SampledRequestsEnabled': True,\n                'CloudWatchMetricsEnabled': True,\n                'MetricName': 'RateLimitRule'\n            }\n        },\n    ],\n    VisibilityConfig={\n        'SampledRequestsEnabled': True,\n        'CloudWatchMetricsEnabled': True,\n        'MetricName': 'ApiSecurityACL'\n    }\n)\n```\n\n### Step 3: Request Validation with OpenAPI Schema\n\n```yaml\n# Kong OAS Validation Plugin configuration\nplugins:\n  - name: oas-validation\n    config:\n      api_spec: |\n        openapi: \"3.0.3\"\n        info:\n          title: Secure API\n          version: \"1.0\"\n        paths:\n          \u002Fapi\u002Fv1\u002Fusers:\n            post:\n              requestBody:\n                required: true\n                content:\n                  application\u002Fjson:\n                    schema:\n                      type: object\n                      required: [name, email]\n                      properties:\n                        name:\n                          type: string\n                          maxLength: 100\n                          pattern: \"^[a-zA-Z ]+$\"\n                        email:\n                          type: string\n                          format: email\n                          maxLength: 255\n                      additionalProperties: false  # Block mass assignment\n              responses:\n                '201':\n                  description: User created\n      validate_request_body: true\n      validate_request_header_params: true\n      validate_request_query_params: true\n      validate_request_uri_params: true\n      verbose_response: false  # Do not expose schema details in errors\n```\n\n### Step 4: Mutual TLS Configuration\n\n```bash\n# Generate CA and client certificates for mTLS\n# 1. Create CA\nopenssl genrsa -out ca.key 4096\nopenssl req -new -x509 -key ca.key -out ca.crt -days 365 \\\n    -subj \"\u002FCN=API Gateway CA\u002FO=Example Corp\"\n\n# 2. Create client certificate\nopenssl genrsa -out client.key 2048\nopenssl req -new -key client.key -out client.csr \\\n    -subj \"\u002FCN=api-client\u002FO=Example Corp\"\nopenssl x509 -req -in client.csr -CA ca.crt -CAkey ca.key \\\n    -CAcreateserial -out client.crt -days 365\n\n# Kong mTLS configuration\n# Upload CA certificate to Kong\ncurl -X POST http:\u002F\u002Fkong-admin:8001\u002Fca_certificates \\\n    -F \"cert=@ca.crt\"\n\n# Enable mTLS plugin\ncurl -X POST http:\u002F\u002Fkong-admin:8001\u002Fservices\u002Fuser-service\u002Fplugins \\\n    --data \"name=mtls-auth\" \\\n    --data \"config.ca_certificates[]=$(cat ca_cert_id)\" \\\n    --data \"config.revocation_check_mode=SKIP\" \\\n    --data \"config.authenticated_group_by=CN\"\n```\n\n### Step 5: Logging and Monitoring Configuration\n\n```python\n# CloudWatch monitoring for API security events\nimport boto3\n\ncloudwatch = boto3.client('cloudwatch')\nlogs = boto3.client('logs')\n\n# Create metric filters for security events\nsecurity_filters = [\n    {\n        'name': 'UnauthorizedAccess',\n        'pattern': '{ $.status = 401 || $.status = 403 }',\n        'metric': 'UnauthorizedAccessCount'\n    },\n    {\n        'name': 'RateLimitHits',\n        'pattern': '{ $.status = 429 }',\n        'metric': 'RateLimitHitCount'\n    },\n    {\n        'name': 'ServerErrors',\n        'pattern': '{ $.status >= 500 }',\n        'metric': 'ServerErrorCount'\n    },\n    {\n        'name': 'LargeResponses',\n        'pattern': '{ $.responseLength > 1000000 }',\n        'metric': 'LargeResponseCount'\n    },\n]\n\nfor sf in security_filters:\n    logs.put_metric_filter(\n        logGroupName='api-access-logs',\n        filterName=sf['name'],\n        filterPattern=sf['pattern'],\n        metricTransformations=[{\n            'metricName': sf['metric'],\n            'metricNamespace': 'APISecurityMetrics',\n            'metricValue': '1',\n            'defaultValue': 0\n        }]\n    )\n\n# Create alarm for unusual 401\u002F403 spike\ncloudwatch.put_metric_alarm(\n    AlarmName='API-UnauthorizedAccessSpike',\n    MetricName='UnauthorizedAccessCount',\n    Namespace='APISecurityMetrics',\n    Statistic='Sum',\n    Period=300,  # 5 minutes\n    EvaluationPeriods=1,\n    Threshold=100,\n    ComparisonOperator='GreaterThanThreshold',\n    AlarmActions=['arn:aws:sns:us-east-1:123456789:security-alerts'],\n    AlarmDescription='More than 100 unauthorized access attempts in 5 minutes'\n)\n```\n\n## Key Concepts\n\n| Term | Definition |\n|------|------------|\n| **API Gateway** | Centralized entry point for all API traffic that enforces authentication, authorization, rate limiting, and request validation before routing to backend services |\n| **Rate Limiting** | Controlling the number of API requests per client within a time window to prevent abuse and ensure fair resource allocation |\n| **Request Validation** | Verifying that incoming API requests conform to the expected schema (data types, required fields, value ranges) before forwarding to backend services |\n| **Mutual TLS (mTLS)** | Two-way TLS authentication where both the client and server present certificates, providing strong identity verification for API-to-API communication |\n| **WAF Integration** | Web Application Firewall rules applied at the API gateway to block common attack patterns (SQLi, XSS, path traversal) |\n| **OAuth2\u002FOIDC** | Token-based authentication protocols where the gateway validates JWT tokens against an identity provider before allowing access |\n\n## Tools & Systems\n\n- **Kong Gateway**: Open-source API gateway with extensive plugin ecosystem for security, rate limiting, and authentication\n- **AWS API Gateway**: Managed API gateway service with built-in throttling, WAF integration, and Lambda authorizers\n- **Azure API Management**: Enterprise API gateway with policy-based security, developer portal, and Azure AD integration\n- **Apigee (Google Cloud)**: API management platform with threat protection, quota management, and API analytics\n- **Envoy Proxy**: High-performance proxy used as API gateway in service mesh architectures with extensive filter chain\n\n## Common Scenarios\n\n### Scenario: Securing a Microservice API with Kong Gateway\n\n**Context**: A company is migrating from a monolithic API to microservices. Each microservice has its own REST API. The security team needs to implement centralized authentication, rate limiting, and request validation without modifying each service.\n\n**Approach**:\n1. Deploy Kong Gateway as the single entry point, routing traffic to 8 backend microservices\n2. Configure JWT validation plugin to verify tokens against the company's Keycloak IdP\n3. Apply rate limiting: 60 requests\u002Fminute for regular users, 300\u002Fminute for premium users, identified by JWT claims\n4. Enable OAS validation plugin to reject requests that do not match the OpenAPI spec (blocks mass assignment and injection)\n5. Configure mTLS for service-to-service communication behind the gateway\n6. Set up response transformer to remove Server and X-Powered-By headers and add security headers\n7. Integrate with AWS WAF for SQL injection and XSS protection rules\n8. Configure access logging to CloudWatch with security metric filters and alerting\n\n**Pitfalls**:\n- Relying solely on the gateway for authorization when backend services also need to verify permissions\n- Not configuring rate limiting per authenticated user (per-IP only allows attackers to bypass with IP rotation)\n- Using verbose error responses from the gateway that reveal internal service architecture\n- Not testing the gateway configuration with security tools after deployment\n- Missing mutual TLS between the gateway and backend services, allowing direct backend access\n\n## Output Format\n\n```\n## API Gateway Security Configuration Report\n\n**Gateway**: Kong 3.5 (Kubernetes deployment)\n**Backend Services**: 8 microservices\n**Date**: 2024-12-15\n\n### Security Controls Implemented\n\n| Control | Plugin\u002FFeature | Configuration |\n|---------|---------------|---------------|\n| Authentication | JWT Plugin | Cognito IdP, 1-hour max TTL |\n| Rate Limiting | Rate Limiting Plugin | 60 req\u002Fmin (user), Redis-backed |\n| Request Validation | OAS Validation | Strict mode, no additional properties |\n| TLS | Kong TLS | TLS 1.3 only, HSTS enabled |\n| mTLS | mTLS Auth Plugin | Client cert required for admin APIs |\n| WAF | AWS WAF | SQLi, XSS, rate-based rules |\n| Headers | Response Transformer | Server header removed, security headers added |\n| Logging | HTTP Log Plugin | CloudWatch, security metric filters |\n\n### Verification Results\n\n- JWT validation: Expired\u002Finvalid tokens correctly rejected (tested 50 payloads)\n- Rate limiting: Enforced at 60 req\u002Fmin, 429 returned with Retry-After header\n- Request validation: Malformed requests rejected with 400 (tested 30 invalid payloads)\n- mTLS: Requests without client certificate rejected with 401\n- WAF: SQL injection payloads blocked (tested top 100 SQLi patterns)\n```\n",{"name":5,"note":25,"tags":26,"author":33,"domain":34,"source":35,"license":15,"version":36,"nist_csf":37,"subdomain":27,"description":42,"mitre_attack":43,"source_commit":49},"Vendored verbatim from an external Apache-2.0 security-skill library, pinned by commit. Exceeds the internal 300-line skill guideline (agent-code-constraints.md) -- kept as-is because this is vendored reference material (forensics\u002Fthreat-intel procedure), not Yana AI-authored content, and trimming would damage technical accuracy.",[27,28,29,30,31,32],"api-security","api-gateway","kong","aws-api-gateway","rate-limiting","waf","mahipal","cybersecurity","https:\u002F\u002Fgithub.com\u002Fmukul975\u002FAnthropic-Cybersecurity-Skills","1.0.0",[38,39,40,41],"PR.PS-01","ID.RA-01","PR.DS-10","DE.CM-01","Implements security controls at the API gateway layer including authentication enforcement, rate limiting, request validation, IP allowlisting, TLS termination, and threat protection. The engineer configures API gateways (Kong, AWS API Gateway, Azure APIM, Apigee) to act as a centralized security enforcement point that validates, throttles, and monitors all API traffic before it reaches backend services. Activates for requests involving API gateway security, API management security, gateway authentication, or centralized API protection.\n",[44,45,46,47,48],"T1190","T1059.007","T1552.001","T1078.004","T1530","04450304b12645cb2b974ab96d28c0664758a88d","main","481dcd7dd2e288b9d627a2bd017db70e64e6c6fa","core\u002Fskills\u002Fimplementing-api-gateway-security-controls",2,"https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI","https:\u002F\u002Fyana.vutam.link\u002F","https:\u002F\u002Fgithub.com\u002FHoronomos-laps","https:\u002F\u002Fyana.vutam.link","An open-source governed runtime & execution environment for multi-agent AI systems.","2026-11-14 13:24:09",{"source":8,"skillName":5,"commands":61,"prompt":71,"zipAvailable":72},[62,65,68],{"tool":63,"command":64},"npx","npx skills add Horonomos-laps\u002FYana-AI --skill implementing-api-gateway-security-controls",{"tool":66,"command":67},"bunx","bunx skills add Horonomos-laps\u002FYana-AI --skill implementing-api-gateway-security-controls",{"tool":69,"command":70},"pnpm","pnpm dlx skills add Horonomos-laps\u002FYana-AI --skill implementing-api-gateway-security-controls","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002Fcore\u002Fskills\u002Fimplementing-api-gateway-security-controls\u002FSKILL.md",true,[74,78,84],{"path":75,"resourceType":75,"resourceTypeDesc":76,"sizeBytes":77,"sourceHtmlUrl":16},"LICENSE","许可证",11255,{"path":79,"resourceType":80,"resourceTypeDesc":81,"sizeBytes":82,"sourceHtmlUrl":83},"references\u002Fapi-reference.md","REFERENCE","参考文档",1638,"https:\u002F\u002Fgithub.com\u002Fyanacuti1121\u002FYana-AI\u002Fblob\u002Fmain\u002Fcore\u002Fskills\u002Fimplementing-api-gateway-security-controls\u002Freferences\u002Fapi-reference.md",{"path":85,"resourceType":86,"resourceTypeDesc":87,"sizeBytes":88,"sourceHtmlUrl":89},"scripts\u002Fagent.py","SCRIPT","脚本",6527,"https:\u002F\u002Fgithub.com\u002Fyanacuti1121\u002FYana-AI\u002Fblob\u002Fmain\u002Fcore\u002Fskills\u002Fimplementing-api-gateway-security-controls\u002Fscripts\u002Fagent.py",[91,99,106,114,122,130],{"skillNo":92,"name":93,"nameZh":6,"description":94,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":95,"licenseFileUrl":6,"sourceHtmlUrl":96,"categories":97,"keywords":98,"publishedAt":20},"01M735GKET5YVYKAY62W2P5YXB","openai--sentry--sentry","Use when the user asks to inspect Sentry issues or events, summarize recent production errors, or pull basic Sentry health data via the Sentry API; perform read-only queries with the bundled script and require `SENTRY_AUTH_TOKEN`.","MIT","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fopenai--sentry--sentry\u002FSKILL.md",[],[],{"skillNo":100,"name":101,"nameZh":6,"description":102,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":103,"categories":104,"keywords":105,"publishedAt":20},"01M73DCAP83T17HY7SMGK7MGFE","ito-basket-compare","Compare Itô prediction-market baskets against a user's knowledge base, portfolio notes, financial context, watchlist, or research thesis. Use for read-only basket comparison and gap analysis without investment advice or live trading.","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002Fcore\u002Fskills\u002Fito-basket-compare\u002FSKILL.md",[],[],{"skillNo":107,"name":108,"nameZh":6,"description":109,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":110,"sourceHtmlUrl":111,"categories":112,"keywords":113,"publishedAt":20},"01M734CYEMZFDR3KH6SW0JP8TD","implementing-network-traffic-baselining","Build network traffic baselines from NetFlow\u002FIPFIX data using Python pandas for statistical analysis, z-score anomaly detection, and hourly\u002Fdaily traffic pattern profiling","https:\u002F\u002Fgithub.com\u002Fyanacuti1121\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fimplementing-network-traffic-baselining\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fimplementing-network-traffic-baselining\u002FSKILL.md",[],[],{"skillNo":115,"name":116,"nameZh":6,"description":117,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":118,"sourceHtmlUrl":119,"categories":120,"keywords":121,"publishedAt":20},"01M73ASZ6NJRJM44Z2P84NGQ3Q","detecting-evasion-techniques-in-endpoint-logs","Detects defense evasion techniques used by adversaries in endpoint logs including log tampering, timestomping, process injection, and security tool disabling. Use when investigating suspicious endpoint behavior, building detection rules for evasion tactics, or conducting threat hunting for stealthy adversary activity. Activates for requests involving evasion detection, defense evasion analysis, log tampering detection, or MITRE ATT&CK TA0005.","https:\u002F\u002Fgithub.com\u002Fyanacuti1121\u002FYana-AI\u002Fblob\u002Fmain\u002Fcore\u002Fskills\u002Fdetecting-evasion-techniques-in-endpoint-logs\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002Fcore\u002Fskills\u002Fdetecting-evasion-techniques-in-endpoint-logs\u002FSKILL.md",[],[],{"skillNo":123,"name":124,"nameZh":6,"description":125,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":126,"sourceHtmlUrl":127,"categories":128,"keywords":129,"publishedAt":20},"01M734AFNXD06Z78QRK0VKGT7Q","implementing-microsegmentation-with-guardicore","Implementing microsegmentation using Akamai Guardicore Segmentation to map application dependencies, create granular network policies, visualize east-west traffic flows, and enforce least-privilege communication between workloads across data centers and cloud.","https:\u002F\u002Fgithub.com\u002Fyanacuti1121\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fimplementing-microsegmentation-with-guardicore\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fimplementing-microsegmentation-with-guardicore\u002FSKILL.md",[],[],{"skillNo":131,"name":132,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":133,"categories":134,"keywords":135,"publishedAt":20},"01M736TK27QMCXK0DVCH25SJN5","ramdisk-tmpfs-patterns","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Framdisk-tmpfs-patterns\u002FSKILL.md",[],[]]