[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7ABB2D7BMR158K891KP1MYC":3,"skill-same:01M7ABB2D7BMR158K891KP1MYC":84},{"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":47,"commitSha":48,"skillDirectory":49,"forksCount":14,"repositoryHtmlUrl":50,"repositoryHomepageUrl":6,"ownerHtmlUrl":51,"ownerBlogUrl":6,"ownerDescription":52,"updatedAt":53,"install":54,"resources":67},"01M7ABB2D7BMR158K891KP1MYC","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.","NeelakshSaxena\u002FVayu","NeelakshSaxena","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F87892838?v=4","01M7A3B9YFS6F6N9DD1787DT86","Neelaksh Saxena","01M7A3B9ZKBT09MNMPX2XN69BY",0,"Apache-2.0","https:\u002F\u002Fgithub.com\u002FNeelakshSaxena\u002FVayu\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fsecuring-serverless-functions\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FNeelakshSaxena\u002FVayu\u002Fblob\u002Fmain\u002F.agents\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":25,"author":31,"domain":32,"license":15,"version":33,"nist_csf":34,"subdomain":39,"description":40,"mitre_attack":41},[26,27,28,29,30],"serverless-security","aws-lambda","azure-functions","function-hardening","supply-chain","mahipal","cybersecurity","1.0.0",[35,36,37,38],"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",[42,43,44,45,46],"T1078.004","T1530","T1537","T1580","T1003","main","7540bbccf0c1ded6156a467b02c95b61ad62413f",".agents\u002Fskills\u002Fsecuring-serverless-functions","https:\u002F\u002Fgithub.com\u002FNeelakshSaxena\u002FVayu","https:\u002F\u002Fgithub.com\u002FNeelakshSaxena","Currently exploring the intersection of tech","2026-09-11 03:02:31",{"source":8,"skillName":5,"commands":55,"prompt":65,"zipAvailable":66},[56,59,62],{"tool":57,"command":58},"npx","npx skills add NeelakshSaxena\u002FVayu --skill securing-serverless-functions",{"tool":60,"command":61},"bunx","bunx skills add NeelakshSaxena\u002FVayu --skill securing-serverless-functions",{"tool":63,"command":64},"pnpm","pnpm dlx skills add NeelakshSaxena\u002FVayu --skill securing-serverless-functions","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FNeelakshSaxena\u002FVayu\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fsecuring-serverless-functions\u002FSKILL.md",true,[68,72,78],{"path":69,"resourceType":69,"resourceTypeDesc":70,"sizeBytes":71,"sourceHtmlUrl":16},"LICENSE","许可证",11255,{"path":73,"resourceType":74,"resourceTypeDesc":75,"sizeBytes":76,"sourceHtmlUrl":77},"references\u002Fapi-reference.md","REFERENCE","参考文档",2116,"https:\u002F\u002Fgithub.com\u002FNeelakshSaxena\u002FVayu\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fsecuring-serverless-functions\u002Freferences\u002Fapi-reference.md",{"path":79,"resourceType":80,"resourceTypeDesc":81,"sizeBytes":82,"sourceHtmlUrl":83},"scripts\u002Fagent.py","SCRIPT","脚本",7302,"https:\u002F\u002Fgithub.com\u002FNeelakshSaxena\u002FVayu\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fsecuring-serverless-functions\u002Fscripts\u002Fagent.py",[85,92,99,106,113,120],{"skillNo":86,"name":87,"nameZh":6,"description":88,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":89,"categories":90,"keywords":91,"publishedAt":20},"01M7ACCCVNCFKMA9X6D15X6G98","runpodctl","Runpod CLI for managing GPU\u002FCPU workloads from the terminal — pods, serverless endpoints, templates, network volumes, Hub deploys, models, SSH, and file transfer (send\u002Freceive). Use for terminal\u002FCI\u002Fscripting, Hub browse\u002Fdeploy, SSH setup, `doctor`, or when the Runpod MCP tools are not connected. For structured tool calls in an MCP-enabled session, prefer runpod-mcp.","https:\u002F\u002Fgithub.com\u002FNeelakshSaxena\u002FVayu\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Frunpodctl\u002FSKILL.md",[],[],{"skillNo":93,"name":94,"nameZh":6,"description":95,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":96,"categories":97,"keywords":98,"publishedAt":20},"01M7ACC63SRHEA5KMCHSMZK2TC","runpod","Start here for any Runpod task — running GPU\u002FCPU pods, deploying serverless endpoints, templates, network volumes, building images, or understanding how Runpod works. Routes to the right skill (runpod-mcp, runpodctl, flash, companion-clis, runpod-usage, runpod-templates, runpod-migrate) and indexes two dozen live-verified end-to-end examples (golden paths) — use it when the lane is unclear, and for any multi-step or provisioning task even when it is not.","https:\u002F\u002Fgithub.com\u002FNeelakshSaxena\u002FVayu\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Frunpod\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},"01M7ACC0Q1C89N9BZBV91CTQTF","runpod-usage","How Runpod works and how to work it — pods vs serverless, GPU\u002FVRAM selection, storage, building a container, networking, plus the agentic pod development loop (provision → ssh-exec → set up → poll readiness) and on-pod install hygiene (uv\u002Fapt). Use to answer \"how does X work\", \"which GPU\", \"how do I build a container\", or \"how do I stand up a workload on a pod\". Guidance, not a tool — execute with runpodctl, runpod-mcp, or flash.","https:\u002F\u002Fgithub.com\u002FNeelakshSaxena\u002FVayu\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Frunpod-usage\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":6,"sourceHtmlUrl":110,"categories":111,"keywords":112,"publishedAt":20},"01M7ACBRPE345GF5GM5B8P8RRC","runpod-templates","Runpod's official prebuilt pod templates (ComfyUI, PyTorch, and others): what each image ships, which ports and paths it uses, how to pick one, how to pin a version, and what is missing on first boot. Use when a task says \"run \u003CX> on a pod\" and an official template already covers it, instead of building an image — and when a user needs help with or wants to fix something about a Runpod template they are already running (won't boot, can't reach the UI, missing models, wrong CUDA line, broken ComfyUI workflow metadata on imported workflows): start here and route onward. Deploy with runpodctl or runpod-mcp; end-to-end walkthroughs live in the runpod router's golden paths.","https:\u002F\u002Fgithub.com\u002FNeelakshSaxena\u002FVayu\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Frunpod-templates\u002FSKILL.md",[],[],{"skillNo":114,"name":115,"nameZh":6,"description":116,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":117,"categories":118,"keywords":119,"publishedAt":20},"01M7ACBJATHKVX1TWES2F44GY8","runpod-migrate","Migrate a codebase from the Runpod GraphQL API or REST v1 to REST v2 — inventory which parts use which API version, rewrite the call sites, flag breaking changes, and verify. Use when someone asks to move to v2, asks what v2 would change, or asks which Runpod API their code is on. For managing infrastructure rather than migrating code, use runpod-mcp or runpodctl.","https:\u002F\u002Fgithub.com\u002FNeelakshSaxena\u002FVayu\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Frunpod-migrate\u002FSKILL.md",[],[],{"skillNo":121,"name":122,"nameZh":6,"description":123,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":124,"categories":125,"keywords":126,"publishedAt":20},"01M7ACBC7GHVH6T9YEAPCG2AP8","runpod-mcp","Manage Runpod infrastructure — pods, serverless endpoints, jobs, templates, network volumes, container-registry auth, GPU\u002FCPU catalog, and billing — via the Runpod MCP server's structured tool calls. Use when the Runpod MCP tools (create-pod, list-endpoints, …) are connected in this session, or to connect them (hosted OAuth or local npx). Prefer this over runpodctl for plain infra CRUD when MCP is available; use runpodctl for the terminal, file transfer, or SSH setup.","https:\u002F\u002Fgithub.com\u002FNeelakshSaxena\u002FVayu\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Frunpod-mcp\u002FSKILL.md",[],[]]