[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7B9CEPQJSQHYVV7W86Z34NQ":3,"skill-same:01M7B9CEPQJSQHYVV7W86Z34NQ":82},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":15,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":46,"commitSha":47,"skillDirectory":48,"forksCount":13,"repositoryHtmlUrl":49,"repositoryHomepageUrl":6,"ownerHtmlUrl":50,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":51,"install":52,"resources":65},"01M7B9CEPQJSQHYVV7W86Z34NQ","securing-serverless-functions",null,"Hardens serverless compute platforms (AWS Lambda, Azure Functions, Google Cloud Functions): least-privilege IAM roles, dependency vulnerability scanning, secrets management integration, input validation, function URL authentication, and runtime monitoring. Use when deploying serverless functions with sensitive access, auditing for overly permissive roles, or adding functions to a DevSecOps pipeline.","vikasvardhanv\u002Fjerry_skills","vikasvardhanv","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F99010657?v=4","01M7B2B0VN78W7529RQX5BR6DZ","01M7B2B0WDNTXJHRK3QNPNWRP6",0,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Fvikasvardhanv\u002Fjerry_skills\u002Fblob\u002Fmain\u002Fskills\u002Fcurated_premium_skills\u002FAnthropic-Cybersecurity-Skills\u002Fskills\u002Fsecuring-serverless-functions\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fvikasvardhanv\u002Fjerry_skills\u002Fblob\u002Fmain\u002Fskills\u002Fcurated_premium_skills\u002FAnthropic-Cybersecurity-Skills\u002Fskills\u002Fsecuring-serverless-functions\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: securing-serverless-functions\ndescription: 'Hardens serverless compute platforms (AWS Lambda, Azure Functions, Google\n  Cloud Functions): least-privilege IAM roles, dependency vulnerability scanning,\n  secrets management integration, input validation, function URL authentication, and\n  runtime monitoring. Use when deploying serverless functions with sensitive access,\n  auditing for overly permissive roles, or adding functions to a DevSecOps pipeline.\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\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,"tags":24,"author":30,"domain":31,"license":14,"version":32,"nist_csf":33,"subdomain":38,"description":39,"mitre_attack":40},[25,26,27,28,29],"serverless-security","aws-lambda","azure-functions","function-hardening","supply-chain","mahipal","cybersecurity","1.0.0",[34,35,36,37],"PR.IR-01","ID.AM-08","GV.SC-06","DE.CM-01","cloud-security","Hardens serverless compute platforms (AWS Lambda, Azure Functions, Google Cloud Functions): least-privilege IAM roles, dependency vulnerability scanning, secrets management integration, input validation, function URL authentication, and runtime monitoring. Use when deploying serverless functions with sensitive access, auditing for overly permissive roles, or adding functions to a DevSecOps pipeline.\n",[41,42,43,44,45],"T1078.004","T1530","T1537","T1580","T1003","main","1eb986d0b0ecc180291597e08eb5a58288843536","skills\u002Fcurated_premium_skills\u002FAnthropic-Cybersecurity-Skills\u002Fskills\u002Fsecuring-serverless-functions","https:\u002F\u002Fgithub.com\u002Fvikasvardhanv\u002Fjerry_skills","https:\u002F\u002Fgithub.com\u002Fvikasvardhanv","2026-08-25 13:16:33",{"source":8,"skillName":5,"commands":53,"prompt":63,"zipAvailable":64},[54,57,60],{"tool":55,"command":56},"npx","npx skills add vikasvardhanv\u002Fjerry_skills --skill securing-serverless-functions",{"tool":58,"command":59},"bunx","bunx skills add vikasvardhanv\u002Fjerry_skills --skill securing-serverless-functions",{"tool":61,"command":62},"pnpm","pnpm dlx skills add vikasvardhanv\u002Fjerry_skills --skill securing-serverless-functions","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fvikasvardhanv\u002Fjerry_skills\u002Fblob\u002Fmain\u002Fskills\u002Fcurated_premium_skills\u002FAnthropic-Cybersecurity-Skills\u002Fskills\u002Fsecuring-serverless-functions\u002FSKILL.md",true,[66,70,76],{"path":67,"resourceType":67,"resourceTypeDesc":68,"sizeBytes":69,"sourceHtmlUrl":15},"LICENSE","许可证",11255,{"path":71,"resourceType":72,"resourceTypeDesc":73,"sizeBytes":74,"sourceHtmlUrl":75},"references\u002Fapi-reference.md","REFERENCE","参考文档",2116,"https:\u002F\u002Fgithub.com\u002Fvikasvardhanv\u002Fjerry_skills\u002Fblob\u002Fmain\u002Fskills\u002Fcurated_premium_skills\u002FAnthropic-Cybersecurity-Skills\u002Fskills\u002Fsecuring-serverless-functions\u002Freferences\u002Fapi-reference.md",{"path":77,"resourceType":78,"resourceTypeDesc":79,"sizeBytes":80,"sourceHtmlUrl":81},"scripts\u002Fagent.py","SCRIPT","脚本",7302,"https:\u002F\u002Fgithub.com\u002Fvikasvardhanv\u002Fjerry_skills\u002Fblob\u002Fmain\u002Fskills\u002Fcurated_premium_skills\u002FAnthropic-Cybersecurity-Skills\u002Fskills\u002Fsecuring-serverless-functions\u002Fscripts\u002Fagent.py",[83,91,98,105,112,119],{"skillNo":84,"name":85,"nameZh":6,"description":86,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":87,"licenseFileUrl":6,"sourceHtmlUrl":88,"categories":89,"keywords":90,"publishedAt":19},"01M7BESR1CJ3H5SP9XM8KYJZ9W","syllabus","Generates a curated supplementary reading list from any course syllabus using Consensus academic search. Grill-me intake (syllabus input format + course audience + year range) plus a grouping forcing-options checkpoint before any search runs — so the reading list matches the course's level and recency need. Parses the syllabus to extract topics and learning outcomes, searches Consensus for recent peer-reviewed papers per topic, and produces a professionally formatted .docx with clickable Consensus links, plain-language summaries calibrated to audience level, and Bloom-higher-order discussion questions tied to course learning goals. Use when the user uploads a syllabus, course outline, or curriculum document and wants supplementary readings (e.g., 'create a reading list from this syllabus', 'find recent papers for my course') — even casual mentions with a syllabus attached should trigger this skill.","MIT","https:\u002F\u002Fgithub.com\u002Fvikasvardhanv\u002Fjerry_skills\u002Fblob\u002Fmain\u002Fskills\u002Fresearch\u002Fsyllabus\u002Fskills\u002Fsyllabus\u002FSKILL.md",[],[],{"skillNo":92,"name":93,"nameZh":6,"description":94,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":87,"licenseFileUrl":6,"sourceHtmlUrl":95,"categories":96,"keywords":97,"publishedAt":19},"01M7BES1YA6R97W7QPMFFM1PED","pulse","Multi-source recency research skill that takes the pulse of any topic across Reddit, Hacker News, the open web, and optionally X\u002FTwitter within a configurable recent window (default 30 days). Forcing intake clarifies topic specificity, angle (trend\u002Fsentiment\u002Fproblems\u002Fopportunities\u002Fcomparison), time window, and platform scope before searching. Returns a synthesized briefing with citations, engagement metrics, and cross-platform pattern analysis. Use when the user requests multi-source recency intelligence on a topic (e.g., 'pulse on [topic]', 'what's happening with [topic]', 'what are people saying about [topic]', 'current conversation about [topic]', 'take the pulse of [topic]', 'trending: [topic]', 'find me info on [topic]'), and for competitor research, trend discovery, tool comparisons, and audience sentiment analysis.","https:\u002F\u002Fgithub.com\u002Fvikasvardhanv\u002Fjerry_skills\u002Fblob\u002Fmain\u002Fskills\u002Fresearch\u002Fpulse\u002Fskills\u002Fpulse\u002FSKILL.md",[],[],{"skillNo":99,"name":100,"nameZh":6,"description":101,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":87,"licenseFileUrl":6,"sourceHtmlUrl":102,"categories":103,"keywords":104,"publishedAt":19},"01M7BERNHYGY035AR00VRT03KE","patent","Patent prior-art and landscape intelligence skill — not generic patent help. Commits to one of five sub-use-cases via forcing intake (novelty search \u002F freedom-to-operate \u002F competitive landscape \u002F acquisition diligence \u002F litigation prior-art) before any search runs. Searches Google Patents, Espacenet, USPTO, and optionally Lens.org for citation-graph signals. Output is an editable Word document (.docx) with verdict, ranked closest art (claim-text extracted), CPC-class-aware landscape, family-resolved hits, geographic coverage, FTO flags where applicable, strategy recommendations, and full audit log. Use when the user asks for patent searching or analysis (e.g., 'prior art search for [invention]', 'freedom to operate analysis for [product]'). Produces search signal, not legal advice — always recommends consulting a patent attorney before filing or licensing decisions. Trademark, copyright, and trade-secret questions are out of scope.","https:\u002F\u002Fgithub.com\u002Fvikasvardhanv\u002Fjerry_skills\u002Fblob\u002Fmain\u002Fskills\u002Fresearch\u002Fpatent\u002Fskills\u002Fpatent\u002FSKILL.md",[],[],{"skillNo":106,"name":107,"nameZh":6,"description":108,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":87,"licenseFileUrl":6,"sourceHtmlUrl":109,"categories":110,"keywords":111,"publishedAt":19},"01M7BERCK1EAKTWW7R436WAR0J","notebooklm","Browser automation skill for controlling Google's NotebookLM. Use when the user wants anything done in NotebookLM (e.g., 'open NotebookLM', 'check my [name] notebook', 'ask my notebook about X', 'add [source] to NotebookLM', 'generate a Video Overview from my notebook', 'use NotebookLM Studio'). Handles reading and querying notebooks, adding sources (URLs, text, files, YouTube links, synthesized content), generating Studio outputs (Audio\u002FVideo Overviews, Mind Maps, Reports incl. Briefing Doc\u002FStudy Guide\u002FFAQ, Flashcards, Quiz, slide decks, infographics — discover the exact set from the live Studio panel; the UI evolves fast), and creating new notebooks. Requires browser automation environment — fails gracefully when unavailable.","https:\u002F\u002Fgithub.com\u002Fvikasvardhanv\u002Fjerry_skills\u002Fblob\u002Fmain\u002Fskills\u002Fresearch\u002Fnotebooklm\u002Fskills\u002Fnotebooklm\u002FSKILL.md",[],[],{"skillNo":113,"name":114,"nameZh":6,"description":115,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":87,"licenseFileUrl":6,"sourceHtmlUrl":116,"categories":117,"keywords":118,"publishedAt":19},"01M7BEQZAZAQRTXFJRY7RHV3TY","litreview","Academic literature orientation skill that searches papers via free keyless APIs (PubMed E-utilities + OpenAlex) by default — with the Consensus MCP as an optional enhancement lane when connected — builds a strategic search plan using PICO (default) or SPIDER \u002F Decomposition \u002F hybrid as fallbacks, and synthesizes findings into a formatted Word (.docx) research guide. Grill-me intake (research question specificity + framework hint + tentative depth) before the recon search; a second forcing checkpoint after Phase 2 confirms framework + sub-areas + depth before searches consume budget. Configurable depth (5\u002F10\u002F20 queries) controls coverage vs. speed. Output is a 'launching pad' — an orientation guide that lets a researcher dive in confidently, not a finished review. Use when the user starts literature-oriented research (e.g., 'litreview on [topic]', 'literature review on [topic]', 'I'm starting a literature review on X', 'I'm writing a paper on X', 'help me research X', 'I'm doing research on X', 'can you help me research X'). Do NOT use for single one-off paper searches wanting a quick list — that's a plain PubMed\u002FOpenAlex (or Consensus) query.","https:\u002F\u002Fgithub.com\u002Fvikasvardhanv\u002Fjerry_skills\u002Fblob\u002Fmain\u002Fskills\u002Fresearch\u002Flitreview\u002Fskills\u002Flitreview\u002FSKILL.md",[],[],{"skillNo":120,"name":121,"nameZh":6,"description":122,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":87,"licenseFileUrl":6,"sourceHtmlUrl":123,"categories":124,"keywords":125,"publishedAt":19},"01M7BEQKJ45K31QK5VRAQSVJCJ","grants","NIH grant research skill for clinical researchers. Grill-me intake (research idea + career stage + preliminary data + environment + submission posture + known institute targets) locks down the funding strategy before any search runs. Runs a 5-facet Consensus positioning analysis (with draft Significance\u002FInnovation language), maps the research to the right NIH institutes and study sections via RePORTER, finds NOSIs and funded overlap, and produces an editable Word document (.docx) with budget\u002Fscope-aware mechanism recommendations, submission timelines, and a mandatory program officer recommendation. Use when the user asks about research funding or makes any grant-related request (e.g., 'grants for [topic]', 'find grants for my research idea', 'what grants match my research', 'help me find NIH funding', 'grant opportunities for my research'). NIH-only scope — non-NIH funders (PCORI, DOD CDMRP, VA, foundations) are out of scope and flagged at intake.","https:\u002F\u002Fgithub.com\u002Fvikasvardhanv\u002Fjerry_skills\u002Fblob\u002Fmain\u002Fskills\u002Fresearch\u002Fgrants\u002Fskills\u002Fgrants\u002FSKILL.md",[],[]]