[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M73762WSVF89CZDPNN3NVMK9":3,"skill-same:01M73762WSVF89CZDPNN3NVMK9":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},"01M73762WSVF89CZDPNN3NVMK9","securing-serverless-functions",null,"This skill covers security hardening for serverless compute platforms including AWS Lambda, Azure Functions, and Google Cloud Functions. It addresses least privilege IAM roles, dependency vulnerability scanning, secrets management integration, input validation, function URL authentication, and runtime monitoring to protect against injection attacks, credential theft, and supply chain compromises.","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\u002F.claude\u002Fskills\u002Fsecuring-serverless-functions\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fsecuring-serverless-functions\u002FSKILL.md",[],[],"2026-11-11 15:11:14",false,"---\nname: securing-serverless-functions\ndescription: 'This skill covers security hardening for serverless compute platforms\n  including AWS Lambda, Azure Functions, and Google Cloud Functions. It addresses\n  least privilege IAM roles, dependency vulnerability scanning, secrets management\n  integration, input validation, function URL authentication, and runtime monitoring\n  to protect against injection attacks, credential theft, and supply chain compromises.\n\n  '\ndomain: cybersecurity\nsubdomain: cloud-security\ntags:\n- serverless-security\n- aws-lambda\n- azure-functions\n- function-hardening\n- supply-chain\nversion: 1.0.0\nauthor: mahipal\nlicense: Apache-2.0\nnist_csf:\n- PR.IR-01\n- ID.AM-08\n- GV.SC-06\n- DE.CM-01\nmitre_attack:\n- T1078.004\n- T1530\n- T1537\n- T1580\n- T1003\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\n# Securing Serverless Functions\n\n## When to Use\n\n- When deploying Lambda functions or Azure Functions with access to sensitive data or cloud APIs\n- When auditing existing serverless workloads for overly permissive IAM roles\n- When integrating serverless functions into a DevSecOps pipeline with automated security scanning\n- When hardcoded secrets or vulnerable dependencies are discovered in function code\n- When establishing runtime monitoring for serverless workloads to detect injection or credential theft\n\n**Do not use** for container-based compute security (see securing-kubernetes-on-cloud), for API Gateway configuration (see implementing-cloud-waf-rules), or for serverless architecture design decisions.\n\n## Prerequisites\n\n- AWS Lambda, Azure Functions, or GCP Cloud Functions with deployment access\n- CI\u002FCD pipeline with dependency scanning tools (npm audit, Snyk, Dependabot)\n- AWS Secrets Manager, Azure Key Vault, or HashiCorp Vault for secrets management\n- CloudWatch, Application Insights, or Cloud Logging for function monitoring\n\n## Workflow\n\n### Step 1: Enforce Least Privilege IAM Roles\n\nAssign each Lambda function a dedicated IAM role with permissions scoped to only the specific resources it accesses. Never share IAM roles across functions.\n\n```bash\n# Create a least-privilege role for a specific Lambda function\naws iam create-role \\\n  --role-name order-processor-lambda-role \\\n  --assume-role-policy-document '{\n    \"Version\": \"2012-10-17\",\n    \"Statement\": [{\n      \"Effect\": \"Allow\",\n      \"Principal\": {\"Service\": \"lambda.amazonaws.com\"},\n      \"Action\": \"sts:AssumeRole\"\n    }]\n  }'\n\n# Attach a scoped policy (not AmazonDynamoDBFullAccess)\naws iam put-role-policy \\\n  --role-name order-processor-lambda-role \\\n  --policy-name order-processor-policy \\\n  --policy-document '{\n    \"Version\": \"2012-10-17\",\n    \"Statement\": [\n      {\n        \"Effect\": \"Allow\",\n        \"Action\": [\"dynamodb:PutItem\", \"dynamodb:GetItem\"],\n        \"Resource\": \"arn:aws:dynamodb:us-east-1:123456789012:table\u002FOrders\"\n      },\n      {\n        \"Effect\": \"Allow\",\n        \"Action\": [\"logs:CreateLogGroup\", \"logs:CreateLogStream\", \"logs:PutLogEvents\"],\n        \"Resource\": \"arn:aws:logs:us-east-1:123456789012:log-group:\u002Faws\u002Flambda\u002Forder-processor:*\"\n      },\n      {\n        \"Effect\": \"Allow\",\n        \"Action\": [\"secretsmanager:GetSecretValue\"],\n        \"Resource\": \"arn:aws:secretsmanager:us-east-1:123456789012:secret:order-api-key-*\"\n      }\n    ]\n  }'\n```\n\n### Step 2: Eliminate Hardcoded Secrets\n\nReplace plaintext credentials in environment variables with references to secrets management services. Use Lambda extensions or SDK calls to retrieve secrets at runtime.\n\n```python\n# INSECURE: Hardcoded credentials in environment variable\n# DB_PASSWORD = os.environ['DB_PASSWORD']  # Stored as plaintext in Lambda config\n\n# SECURE: Retrieve from AWS Secrets Manager with caching\nimport boto3\nfrom botocore.exceptions import ClientError\nimport json\n\n_secret_cache = {}\n\ndef get_secret(secret_name):\n    if secret_name in _secret_cache:\n        return _secret_cache[secret_name]\n\n    client = boto3.client('secretsmanager')\n    response = client.get_secret_value(SecretId=secret_name)\n    secret = json.loads(response['SecretString'])\n    _secret_cache[secret_name] = secret\n    return secret\n\ndef lambda_handler(event, context):\n    db_creds = get_secret('production\u002Fdatabase\u002Fcredentials')\n    db_host = db_creds['host']\n    db_password = db_creds['password']\n    # Use credentials securely\n```\n\n```bash\n# Enable encryption at rest for Lambda environment variables\naws lambda update-function-configuration \\\n  --function-name order-processor \\\n  --kms-key-arn arn:aws:kms:us-east-1:123456789012:key\u002Fkey-id\n```\n\n### Step 3: Scan Dependencies for Vulnerabilities\n\nIntegrate automated dependency scanning into the CI\u002FCD pipeline to catch vulnerable packages before deployment.\n\n```bash\n# npm audit for Node.js Lambda functions\ncd lambda-function\u002F\nnpm audit --audit-level=high\nnpm audit fix\n\n# Snyk scanning in CI\u002FCD pipeline\nsnyk test --severity-threshold=high\nsnyk monitor --project-name=order-processor-lambda\n\n# pip-audit for Python Lambda functions\npip-audit -r requirements.txt --desc on --fix\n\n# Scan Lambda deployment package with Trivy\ntrivy fs --severity HIGH,CRITICAL .\u002Flambda-package\u002F\n```\n\n```yaml\n# GitHub Actions CI\u002FCD security scanning\nname: Lambda Security Scan\non: [push, pull_request]\njobs:\n  security:\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions\u002Fcheckout@v4\n      - name: Install dependencies\n        run: npm ci\n      - name: Run npm audit\n        run: npm audit --audit-level=high\n      - name: Snyk vulnerability scan\n        uses: snyk\u002Factions\u002Fnode@master\n        env:\n          SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}\n      - name: Scan with Semgrep for code vulnerabilities\n        uses: returntocorp\u002Fsemgrep-action@v1\n        with:\n          config: p\u002Fowasp-top-ten\n```\n\n### Step 4: Implement Input Validation\n\nValidate and sanitize all event input data to prevent injection attacks including SQL injection, command injection, and NoSQL injection through Lambda event sources.\n\n```python\nimport re\nimport json\nfrom jsonschema import validate, ValidationError\n\n# Define expected input schema\nORDER_SCHEMA = {\n    \"type\": \"object\",\n    \"properties\": {\n        \"orderId\": {\"type\": \"string\", \"pattern\": \"^[a-zA-Z0-9-]{1,36}$\"},\n        \"customerId\": {\"type\": \"string\", \"pattern\": \"^[a-zA-Z0-9]{1,20}$\"},\n        \"amount\": {\"type\": \"number\", \"minimum\": 0.01, \"maximum\": 999999.99},\n        \"currency\": {\"type\": \"string\", \"enum\": [\"USD\", \"EUR\", \"GBP\"]}\n    },\n    \"required\": [\"orderId\", \"customerId\", \"amount\", \"currency\"],\n    \"additionalProperties\": False\n}\n\ndef lambda_handler(event, context):\n    # Validate API Gateway event body\n    try:\n        body = json.loads(event.get('body', '{}'))\n        validate(instance=body, schema=ORDER_SCHEMA)\n    except (json.JSONDecodeError, ValidationError) as e:\n        return {\n            'statusCode': 400,\n            'body': json.dumps({'error': 'Invalid input', 'details': str(e)})\n        }\n\n    # Safe to proceed with validated input\n    order_id = body['orderId']\n    # Use parameterized queries for database operations\n```\n\n### Step 5: Configure Function URL and API Gateway Authentication\n\nSecure function invocation endpoints with proper authentication. Never expose Lambda function URLs without IAM or Cognito authentication.\n\n```bash\n# Secure Lambda function URL with IAM auth (not NONE)\naws lambda create-function-url-config \\\n  --function-name order-processor \\\n  --auth-type AWS_IAM \\\n  --cors '{\n    \"AllowOrigins\": [\"https:\u002F\u002Fapp.company.com\"],\n    \"AllowMethods\": [\"POST\"],\n    \"AllowHeaders\": [\"Content-Type\", \"Authorization\"],\n    \"MaxAge\": 3600\n  }'\n\n# API Gateway with Cognito authorizer\naws apigateway create-authorizer \\\n  --rest-api-id abc123 \\\n  --name CognitoAuth \\\n  --type COGNITO_USER_POOLS \\\n  --provider-arns \"arn:aws:cognito-idp:us-east-1:123456789012:userpool\u002Fus-east-1_EXAMPLE\"\n```\n\n### Step 6: Enable Runtime Monitoring and Logging\n\nConfigure GuardDuty Lambda Network Activity Monitoring and CloudWatch structured logging to detect anomalous function behavior.\n\n```bash\n# Enable GuardDuty Lambda protection\naws guardduty update-detector \\\n  --detector-id \u003Cdetector-id> \\\n  --features '[{\"Name\": \"LAMBDA_NETWORK_ACTIVITY_LOGS\", \"Status\": \"ENABLED\"}]'\n\n# Configure Lambda to use structured logging\naws lambda update-function-configuration \\\n  --function-name order-processor \\\n  --logging-config '{\"LogFormat\": \"JSON\", \"ApplicationLogLevel\": \"INFO\", \"SystemLogLevel\": \"WARN\"}'\n```\n\n## Key Concepts\n\n| Term | Definition |\n|------|------------|\n| Cold Start | Initial function invocation that includes container provisioning, increasing latency and creating a window where cached secrets may not be available |\n| Event Injection | Attack where malicious input is embedded in Lambda event data from API Gateway, S3, SQS, or other event sources to exploit the function |\n| Execution Role | IAM role assumed by Lambda during execution, defining all cloud API permissions the function can use |\n| Function URL | Direct HTTPS endpoint for Lambda functions that can be configured with IAM or no authentication (NONE is insecure) |\n| Layer | Lambda deployment package containing shared code or dependencies that should be scanned for vulnerabilities independently |\n| Reserved Concurrency | Maximum number of concurrent executions for a function, useful for preventing resource exhaustion attacks |\n| Provisioned Concurrency | Pre-initialized function instances that reduce cold start latency and ensure secrets are cached |\n\n## Tools & Systems\n\n- **AWS Lambda Power Tuning**: Open-source tool for optimizing Lambda memory and timeout settings to balance security with performance\n- **Snyk**: SCA tool scanning Lambda dependencies for known vulnerabilities with automatic fix suggestions\n- **Semgrep**: SAST tool with serverless-specific rules detecting injection vulnerabilities, hardcoded secrets, and insecure configurations\n- **GuardDuty Lambda Protection**: AWS service monitoring Lambda network activity for connections to malicious endpoints\n- **AWS X-Ray**: Distributed tracing service for detecting suspicious external connections and latency anomalies in Lambda invocations\n\n## Common Scenarios\n\n### Scenario: SQL Injection via API Gateway to Lambda to RDS\n\n**Context**: A Lambda function receives user input from API Gateway and constructs SQL queries by string concatenation against an RDS PostgreSQL database. An attacker injects SQL payloads through the API.\n\n**Approach**:\n1. Audit the Lambda function code for string concatenation in SQL queries\n2. Replace all string-formatted queries with parameterized queries using the database driver\n3. Implement input validation using JSON Schema before any database operation\n4. Add a WAF rule on API Gateway to block common SQL injection patterns\n5. Deploy Semgrep in the CI\u002FCD pipeline with the `python.django.security.injection.sql` rule set\n6. Enable GuardDuty Lambda protection to detect anomalous database connection patterns\n\n**Pitfalls**: Relying solely on WAF rules without fixing the underlying code vulnerability allows attackers to bypass with encoding tricks. Using ORM methods incorrectly (raw queries) still allows injection.\n\n## Output Format\n\n```\nServerless Security Assessment Report\n=======================================\nAccount: 123456789012\nFunctions Assessed: 47\nAssessment Date: 2025-02-23\n\nCRITICAL FINDINGS:\n  [SLS-001] order-processor: SQL injection via string concatenation\n    Language: Python 3.12 | Runtime: Lambda\n    Vulnerable Code: f\"SELECT * FROM orders WHERE id = '{order_id}'\"\n    Remediation: Use parameterized queries with psycopg2\n\n  [SLS-002] payment-handler: Hardcoded Stripe API key in environment variable\n    Key: sk_live_XXXX... (unencrypted)\n    Remediation: Migrate to AWS Secrets Manager with KMS encryption\n\nHIGH FINDINGS:\n  [SLS-003] 12 functions share the same IAM execution role with s3:*\n  [SLS-004] 8 functions have function URLs with AuthType: NONE\n  [SLS-005] 23 functions have dependencies with known HIGH CVEs\n\nDEPENDENCY VULNERABILITIES:\n  axios@0.21.1:         CVE-2023-45857 (HIGH) - 5 functions affected\n  jsonwebtoken@8.5.1:   CVE-2022-23529 (CRITICAL) - 3 functions affected\n  lodash@4.17.15:       CVE-2021-23337 (HIGH) - 11 functions affected\n\nSUMMARY:\n  Critical: 2 | High: 5 | Medium: 12 | Low: 8\n  Functions with Least Privilege: 14\u002F47 (30%)\n  Functions with Secrets Manager: 19\u002F47 (40%)\n  Functions with Input Validation: 22\u002F47 (47%)\n```\n","# Securing Serverless Functions\n\n## When to Use\n\n- When deploying Lambda functions or Azure Functions with access to sensitive data or cloud APIs\n- When auditing existing serverless workloads for overly permissive IAM roles\n- When integrating serverless functions into a DevSecOps pipeline with automated security scanning\n- When hardcoded secrets or vulnerable dependencies are discovered in function code\n- When establishing runtime monitoring for serverless workloads to detect injection or credential theft\n\n**Do not use** for container-based compute security (see securing-kubernetes-on-cloud), for API Gateway configuration (see implementing-cloud-waf-rules), or for serverless architecture design decisions.\n\n## Prerequisites\n\n- AWS Lambda, Azure Functions, or GCP Cloud Functions with deployment access\n- CI\u002FCD pipeline with dependency scanning tools (npm audit, Snyk, Dependabot)\n- AWS Secrets Manager, Azure Key Vault, or HashiCorp Vault for secrets management\n- CloudWatch, Application Insights, or Cloud Logging for function monitoring\n\n## Workflow\n\n### Step 1: Enforce Least Privilege IAM Roles\n\nAssign each Lambda function a dedicated IAM role with permissions scoped to only the specific resources it accesses. Never share IAM roles across functions.\n\n```bash\n# Create a least-privilege role for a specific Lambda function\naws iam create-role \\\n  --role-name order-processor-lambda-role \\\n  --assume-role-policy-document '{\n    \"Version\": \"2012-10-17\",\n    \"Statement\": [{\n      \"Effect\": \"Allow\",\n      \"Principal\": {\"Service\": \"lambda.amazonaws.com\"},\n      \"Action\": \"sts:AssumeRole\"\n    }]\n  }'\n\n# Attach a scoped policy (not AmazonDynamoDBFullAccess)\naws iam put-role-policy \\\n  --role-name order-processor-lambda-role \\\n  --policy-name order-processor-policy \\\n  --policy-document '{\n    \"Version\": \"2012-10-17\",\n    \"Statement\": [\n      {\n        \"Effect\": \"Allow\",\n        \"Action\": [\"dynamodb:PutItem\", \"dynamodb:GetItem\"],\n        \"Resource\": \"arn:aws:dynamodb:us-east-1:123456789012:table\u002FOrders\"\n      },\n      {\n        \"Effect\": \"Allow\",\n        \"Action\": [\"logs:CreateLogGroup\", \"logs:CreateLogStream\", \"logs:PutLogEvents\"],\n        \"Resource\": \"arn:aws:logs:us-east-1:123456789012:log-group:\u002Faws\u002Flambda\u002Forder-processor:*\"\n      },\n      {\n        \"Effect\": \"Allow\",\n        \"Action\": [\"secretsmanager:GetSecretValue\"],\n        \"Resource\": \"arn:aws:secretsmanager:us-east-1:123456789012:secret:order-api-key-*\"\n      }\n    ]\n  }'\n```\n\n### Step 2: Eliminate Hardcoded Secrets\n\nReplace plaintext credentials in environment variables with references to secrets management services. Use Lambda extensions or SDK calls to retrieve secrets at runtime.\n\n```python\n# INSECURE: Hardcoded credentials in environment variable\n# DB_PASSWORD = os.environ['DB_PASSWORD']  # Stored as plaintext in Lambda config\n\n# SECURE: Retrieve from AWS Secrets Manager with caching\nimport boto3\nfrom botocore.exceptions import ClientError\nimport json\n\n_secret_cache = {}\n\ndef get_secret(secret_name):\n    if secret_name in _secret_cache:\n        return _secret_cache[secret_name]\n\n    client = boto3.client('secretsmanager')\n    response = client.get_secret_value(SecretId=secret_name)\n    secret = json.loads(response['SecretString'])\n    _secret_cache[secret_name] = secret\n    return secret\n\ndef lambda_handler(event, context):\n    db_creds = get_secret('production\u002Fdatabase\u002Fcredentials')\n    db_host = db_creds['host']\n    db_password = db_creds['password']\n    # Use credentials securely\n```\n\n```bash\n# Enable encryption at rest for Lambda environment variables\naws lambda update-function-configuration \\\n  --function-name order-processor \\\n  --kms-key-arn arn:aws:kms:us-east-1:123456789012:key\u002Fkey-id\n```\n\n### Step 3: Scan Dependencies for Vulnerabilities\n\nIntegrate automated dependency scanning into the CI\u002FCD pipeline to catch vulnerable packages before deployment.\n\n```bash\n# npm audit for Node.js Lambda functions\ncd lambda-function\u002F\nnpm audit --audit-level=high\nnpm audit fix\n\n# Snyk scanning in CI\u002FCD pipeline\nsnyk test --severity-threshold=high\nsnyk monitor --project-name=order-processor-lambda\n\n# pip-audit for Python Lambda functions\npip-audit -r requirements.txt --desc on --fix\n\n# Scan Lambda deployment package with Trivy\ntrivy fs --severity HIGH,CRITICAL .\u002Flambda-package\u002F\n```\n\n```yaml\n# GitHub Actions CI\u002FCD security scanning\nname: Lambda Security Scan\non: [push, pull_request]\njobs:\n  security:\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions\u002Fcheckout@v4\n      - name: Install dependencies\n        run: npm ci\n      - name: Run npm audit\n        run: npm audit --audit-level=high\n      - name: Snyk vulnerability scan\n        uses: snyk\u002Factions\u002Fnode@master\n        env:\n          SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}\n      - name: Scan with Semgrep for code vulnerabilities\n        uses: returntocorp\u002Fsemgrep-action@v1\n        with:\n          config: p\u002Fowasp-top-ten\n```\n\n### Step 4: Implement Input Validation\n\nValidate and sanitize all event input data to prevent injection attacks including SQL injection, command injection, and NoSQL injection through Lambda event sources.\n\n```python\nimport re\nimport json\nfrom jsonschema import validate, ValidationError\n\n# Define expected input schema\nORDER_SCHEMA = {\n    \"type\": \"object\",\n    \"properties\": {\n        \"orderId\": {\"type\": \"string\", \"pattern\": \"^[a-zA-Z0-9-]{1,36}$\"},\n        \"customerId\": {\"type\": \"string\", \"pattern\": \"^[a-zA-Z0-9]{1,20}$\"},\n        \"amount\": {\"type\": \"number\", \"minimum\": 0.01, \"maximum\": 999999.99},\n        \"currency\": {\"type\": \"string\", \"enum\": [\"USD\", \"EUR\", \"GBP\"]}\n    },\n    \"required\": [\"orderId\", \"customerId\", \"amount\", \"currency\"],\n    \"additionalProperties\": False\n}\n\ndef lambda_handler(event, context):\n    # Validate API Gateway event body\n    try:\n        body = json.loads(event.get('body', '{}'))\n        validate(instance=body, schema=ORDER_SCHEMA)\n    except (json.JSONDecodeError, ValidationError) as e:\n        return {\n            'statusCode': 400,\n            'body': json.dumps({'error': 'Invalid input', 'details': str(e)})\n        }\n\n    # Safe to proceed with validated input\n    order_id = body['orderId']\n    # Use parameterized queries for database operations\n```\n\n### Step 5: Configure Function URL and API Gateway Authentication\n\nSecure function invocation endpoints with proper authentication. Never expose Lambda function URLs without IAM or Cognito authentication.\n\n```bash\n# Secure Lambda function URL with IAM auth (not NONE)\naws lambda create-function-url-config \\\n  --function-name order-processor \\\n  --auth-type AWS_IAM \\\n  --cors '{\n    \"AllowOrigins\": [\"https:\u002F\u002Fapp.company.com\"],\n    \"AllowMethods\": [\"POST\"],\n    \"AllowHeaders\": [\"Content-Type\", \"Authorization\"],\n    \"MaxAge\": 3600\n  }'\n\n# API Gateway with Cognito authorizer\naws apigateway create-authorizer \\\n  --rest-api-id abc123 \\\n  --name CognitoAuth \\\n  --type COGNITO_USER_POOLS \\\n  --provider-arns \"arn:aws:cognito-idp:us-east-1:123456789012:userpool\u002Fus-east-1_EXAMPLE\"\n```\n\n### Step 6: Enable Runtime Monitoring and Logging\n\nConfigure GuardDuty Lambda Network Activity Monitoring and CloudWatch structured logging to detect anomalous function behavior.\n\n```bash\n# Enable GuardDuty Lambda protection\naws guardduty update-detector \\\n  --detector-id \u003Cdetector-id> \\\n  --features '[{\"Name\": \"LAMBDA_NETWORK_ACTIVITY_LOGS\", \"Status\": \"ENABLED\"}]'\n\n# Configure Lambda to use structured logging\naws lambda update-function-configuration \\\n  --function-name order-processor \\\n  --logging-config '{\"LogFormat\": \"JSON\", \"ApplicationLogLevel\": \"INFO\", \"SystemLogLevel\": \"WARN\"}'\n```\n\n## Key Concepts\n\n| Term | Definition |\n|------|------------|\n| Cold Start | Initial function invocation that includes container provisioning, increasing latency and creating a window where cached secrets may not be available |\n| Event Injection | Attack where malicious input is embedded in Lambda event data from API Gateway, S3, SQS, or other event sources to exploit the function |\n| Execution Role | IAM role assumed by Lambda during execution, defining all cloud API permissions the function can use |\n| Function URL | Direct HTTPS endpoint for Lambda functions that can be configured with IAM or no authentication (NONE is insecure) |\n| Layer | Lambda deployment package containing shared code or dependencies that should be scanned for vulnerabilities independently |\n| Reserved Concurrency | Maximum number of concurrent executions for a function, useful for preventing resource exhaustion attacks |\n| Provisioned Concurrency | Pre-initialized function instances that reduce cold start latency and ensure secrets are cached |\n\n## Tools & Systems\n\n- **AWS Lambda Power Tuning**: Open-source tool for optimizing Lambda memory and timeout settings to balance security with performance\n- **Snyk**: SCA tool scanning Lambda dependencies for known vulnerabilities with automatic fix suggestions\n- **Semgrep**: SAST tool with serverless-specific rules detecting injection vulnerabilities, hardcoded secrets, and insecure configurations\n- **GuardDuty Lambda Protection**: AWS service monitoring Lambda network activity for connections to malicious endpoints\n- **AWS X-Ray**: Distributed tracing service for detecting suspicious external connections and latency anomalies in Lambda invocations\n\n## Common Scenarios\n\n### Scenario: SQL Injection via API Gateway to Lambda to RDS\n\n**Context**: A Lambda function receives user input from API Gateway and constructs SQL queries by string concatenation against an RDS PostgreSQL database. An attacker injects SQL payloads through the API.\n\n**Approach**:\n1. Audit the Lambda function code for string concatenation in SQL queries\n2. Replace all string-formatted queries with parameterized queries using the database driver\n3. Implement input validation using JSON Schema before any database operation\n4. Add a WAF rule on API Gateway to block common SQL injection patterns\n5. Deploy Semgrep in the CI\u002FCD pipeline with the `python.django.security.injection.sql` rule set\n6. Enable GuardDuty Lambda protection to detect anomalous database connection patterns\n\n**Pitfalls**: Relying solely on WAF rules without fixing the underlying code vulnerability allows attackers to bypass with encoding tricks. Using ORM methods incorrectly (raw queries) still allows injection.\n\n## Output Format\n\n```\nServerless Security Assessment Report\n=======================================\nAccount: 123456789012\nFunctions Assessed: 47\nAssessment Date: 2025-02-23\n\nCRITICAL FINDINGS:\n  [SLS-001] order-processor: SQL injection via string concatenation\n    Language: Python 3.12 | Runtime: Lambda\n    Vulnerable Code: f\"SELECT * FROM orders WHERE id = '{order_id}'\"\n    Remediation: Use parameterized queries with psycopg2\n\n  [SLS-002] payment-handler: Hardcoded Stripe API key in environment variable\n    Key: sk_live_XXXX... (unencrypted)\n    Remediation: Migrate to AWS Secrets Manager with KMS encryption\n\nHIGH FINDINGS:\n  [SLS-003] 12 functions share the same IAM execution role with s3:*\n  [SLS-004] 8 functions have function URLs with AuthType: NONE\n  [SLS-005] 23 functions have dependencies with known HIGH CVEs\n\nDEPENDENCY VULNERABILITIES:\n  axios@0.21.1:         CVE-2023-45857 (HIGH) - 5 functions affected\n  jsonwebtoken@8.5.1:   CVE-2022-23529 (CRITICAL) - 3 functions affected\n  lodash@4.17.15:       CVE-2021-23337 (HIGH) - 11 functions affected\n\nSUMMARY:\n  Critical: 2 | High: 5 | Medium: 12 | Low: 8\n  Functions with Least Privilege: 14\u002F47 (30%)\n  Functions with Secrets Manager: 19\u002F47 (40%)\n  Functions with Input Validation: 22\u002F47 (47%)\n```\n",{"name":5,"note":25,"tags":26,"author":32,"domain":33,"source":34,"license":15,"version":35,"nist_csf":36,"subdomain":41,"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],"serverless-security","aws-lambda","azure-functions","function-hardening","supply-chain","mahipal","cybersecurity","https:\u002F\u002Fgithub.com\u002Fmukul975\u002FAnthropic-Cybersecurity-Skills","1.0.0",[37,38,39,40],"PR.IR-01","ID.AM-08","GV.SC-06","DE.CM-01","cloud-security","This skill covers security hardening for serverless compute platforms including AWS Lambda, Azure Functions, and Google Cloud Functions. It addresses least privilege IAM roles, dependency vulnerability scanning, secrets management integration, input validation, function URL authentication, and runtime monitoring to protect against injection attacks, credential theft, and supply chain compromises.\n",[44,45,46,47,48],"T1078.004","T1530","T1537","T1580","T1003","04450304b12645cb2b974ab96d28c0664758a88d","main","481dcd7dd2e288b9d627a2bd017db70e64e6c6fa",".claude\u002Fskills\u002Fsecuring-serverless-functions",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 securing-serverless-functions",{"tool":66,"command":67},"bunx","bunx skills add Horonomos-laps\u002FYana-AI --skill securing-serverless-functions",{"tool":69,"command":70},"pnpm","pnpm dlx skills add Horonomos-laps\u002FYana-AI --skill securing-serverless-functions","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fsecuring-serverless-functions\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","参考文档",2116,"https:\u002F\u002Fgithub.com\u002Fyanacuti1121\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fsecuring-serverless-functions\u002Freferences\u002Fapi-reference.md",{"path":85,"resourceType":86,"resourceTypeDesc":87,"sizeBytes":88,"sourceHtmlUrl":89},"scripts\u002Fagent.py","SCRIPT","脚本",7302,"https:\u002F\u002Fgithub.com\u002Fyanacuti1121\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fsecuring-serverless-functions\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",[],[]]