Serverless Security (SRVLS)
Analyze serverless applications for security vulnerabilities including
overprivileged IAM policies, event data injection, secrets stored in plain-text
environment variables, /tmp directory data reuse between invocations, excessive
timeout configuration, and missing concurrency limits. Serverless architectures
introduce unique attack surfaces where each function is an independent entry
point with its own trust boundary.
Supported Flags
Read ../../shared/schemas/flags.md for the full flag specification. This skill
supports all cross-cutting flags. Key flags for this skill:
--scope determines which files to analyze (default: changed)
--depth standard reads code and checks function configuration
--depth deep traces event flow across function triggers and IAM policy chains
--severity filters output (serverless issues are often high or critical)
Framework Context
Key CWEs in scope:
- CWE-250: Execution with Unnecessary Privileges (overprivileged IAM)
- CWE-94: Improper Control of Generation of Code (event injection)
- CWE-312: Cleartext Storage of Sensitive Information (secrets in env)
- CWE-377: Insecure Temporary File (/tmp reuse)
- CWE-400: Uncontrolled Resource Consumption (timeout, concurrency)
Detection Patterns
Read references/detection-patterns.md for the full catalog of code patterns,
search heuristics, language-specific examples, and false positive guidance.
Workflow
1. Determine Scope
Parse flags and resolve the file list per ../../shared/schemas/flags.md.
Filter to files likely to contain serverless logic:
- Function handlers (
**/handlers/**, **/functions/**, **/lambdas/**)
- Infrastructure as Code (
**/serverless.yml, **/template.yaml, **/*.tf)
- IAM policies (
**/iam/**, **/policies/**, **/roles/**)
- Function configuration (
**/function.json, **/host.json)
- Event sources (
**/events/**, **/triggers/**)
2. Check for Available Scanners
Detect scanners per ../../shared/schemas/scanners.md:
semgrep -- primary scanner for code patterns
checkov -- IaC scanner for serverless misconfigurations
tfsec -- Terraform-specific security scanner
Record which scanners are available and which are missing.
3. Run Scanners (If Available)
If semgrep is available, run with rules targeting serverless:
semgrep scan --config auto --json --quiet <target>
If checkov is available, run for IaC:
checkov -d <target> -o json --quiet
Filter results to serverless-relevant rules. Normalize output to the
findings schema.
4. Claude Code Analysis
Regardless of scanner availability, perform manual code analysis:
- IAM policy audit: Parse IAM policies (SAM, Serverless Framework,
Terraform) and flag
Action: *, Resource: *, or overly broad permissions.
- Event injection: Find event data (API Gateway, SQS, S3, SNS) used
in SQL, shell commands, or file paths without sanitization.
- Secrets in environment: Check for secrets in plaintext environment
variable definitions in IaC templates.
- /tmp reuse: Find code that writes sensitive data to
/tmp without
cleanup, which persists between warm invocations.
- Timeout configuration: Check for excessive timeouts that increase the
cost and blast radius of denial-of-service attacks.
- Concurrency limits: Verify reserved concurrency is configured to
prevent a single function from consuming all account capacity.
When --depth deep, additionally trace:
- Cross-function event flows and trust boundaries
- IAM role assumption chains
- VPC configuration and network isolation
5. Report Findings
Format output per ../../shared/schemas/findings.md using the SRVLS prefix
(e.g., SRVLS-001, SRVLS-002).
Include for each finding:
- Severity and confidence
- Exact file location with code snippet
- Blast radius (what the overprivileged function can access)
- Concrete fix with diff when possible
- CWE references
What to Look For
These are the high-signal patterns specific to serverless security. Each
maps to a detection pattern in references/detection-patterns.md.
Overprivileged IAM policies -- Functions with Action: * or
Resource: * that violate the principle of least privilege.
Event data injection -- Untrusted event data (HTTP body, S3 key, SNS
message) used in SQL queries, shell commands, or file paths.
Secrets in plain-text env vars -- API keys, database passwords, and
tokens defined as plain-text environment variables in IaC templates.
/tmp directory reuse -- Sensitive data written to /tmp persists across
warm invocations and may be accessible to subsequent executions.
Excessive function timeout -- Timeouts set to the maximum (15 minutes
for Lambda) when the function's task requires seconds.
Missing concurrency limit -- No reserved concurrency, allowing a
triggered flood to exhaust the account's concurrent execution quota.
Missing VPC configuration -- Functions accessing internal resources
without VPC attachment, or VPC-attached functions without security groups.
Scanner Integration
| Scanner |
Coverage |
Command |
| semgrep |
Event injection, code patterns |
semgrep scan --config auto --json --quiet <target> |
| checkov |
IAM policies, IaC misconfig |
checkov -d <target> -o json --quiet |
| tfsec |
Terraform IAM, Lambda config |
tfsec <target> --format json |
Fallback (no scanner): Use Grep with patterns from references/detection-patterns.md
to find IAM policies, event handling, environment variable definitions, and
/tmp usage. Report findings with confidence: medium.
Output Format
Use the findings schema from ../../shared/schemas/findings.md.
- ID prefix:
SRVLS (e.g., SRVLS-001)
- metadata.tool:
serverless
- metadata.framework:
specialized
- metadata.category:
SRVLS
- references.cwe:
CWE-250, CWE-94, CWE-312
- references.owasp:
A05:2021 (Security Misconfiguration)
- references.stride:
E (Elevation of Privilege) or T (Tampering)
Severity guidance for this category:
- critical: IAM
Action: * on Resource: *, event injection leading to RCE
- high: Overly broad IAM permissions, secrets in plain-text env vars, event injection in SQL
- medium: /tmp reuse with sensitive data, excessive timeout, missing concurrency limit
- low: Slightly overprivileged IAM that follows a known pattern, informational misconfigs
1---2name: serverless3description: This skill should be used when the user asks to "check serverless security", "audit Lambda functions", "analyze cloud function permissions", "check IAM policies", "find serverless vulnerabilities", or mentions "serverless", "Lambda", "Cloud Functions", "Azure Functions", "IAM policy", "event injection", "overprivileged", or "/tmp reuse" in a security context.4---56# Serverless Security (SRVLS)78Analyze serverless applications for security vulnerabilities including9overprivileged IAM policies, event data injection, secrets stored in plain-text10environment variables, /tmp directory data reuse between invocations, excessive11timeout configuration, and missing concurrency limits. Serverless architectures12introduce unique attack surfaces where each function is an independent entry13point with its own trust boundary.1415## Supported Flags1617Read `../../shared/schemas/flags.md` for the full flag specification. This skill18supports all cross-cutting flags. Key flags for this skill:1920- `--scope` determines which files to analyze (default: `changed`)21- `--depth standard` reads code and checks function configuration22- `--depth deep` traces event flow across function triggers and IAM policy chains23- `--severity` filters output (serverless issues are often `high` or `critical`)2425## Framework Context2627Key CWEs in scope:28- CWE-250: Execution with Unnecessary Privileges (overprivileged IAM)29- CWE-94: Improper Control of Generation of Code (event injection)30- CWE-312: Cleartext Storage of Sensitive Information (secrets in env)31- CWE-377: Insecure Temporary File (/tmp reuse)32- CWE-400: Uncontrolled Resource Consumption (timeout, concurrency)3334## Detection Patterns3536Read `references/detection-patterns.md` for the full catalog of code patterns,37search heuristics, language-specific examples, and false positive guidance.3839## Workflow4041### 1. Determine Scope4243Parse flags and resolve the file list per `../../shared/schemas/flags.md`.44Filter to files likely to contain serverless logic:4546- Function handlers (`**/handlers/**`, `**/functions/**`, `**/lambdas/**`)47- Infrastructure as Code (`**/serverless.yml`, `**/template.yaml`, `**/*.tf`)48- IAM policies (`**/iam/**`, `**/policies/**`, `**/roles/**`)49- Function configuration (`**/function.json`, `**/host.json`)50- Event sources (`**/events/**`, `**/triggers/**`)5152### 2. Check for Available Scanners5354Detect scanners per `../../shared/schemas/scanners.md`:55561. `semgrep` -- primary scanner for code patterns572. `checkov` -- IaC scanner for serverless misconfigurations583. `tfsec` -- Terraform-specific security scanner5960Record which scanners are available and which are missing.6162### 3. Run Scanners (If Available)6364If semgrep is available, run with rules targeting serverless:65```66semgrep scan --config auto --json --quiet <target>67```6869If checkov is available, run for IaC:70```71checkov -d <target> -o json --quiet72```7374Filter results to serverless-relevant rules. Normalize output to the75findings schema.7677### 4. Claude Code Analysis7879Regardless of scanner availability, perform manual code analysis:80811. **IAM policy audit**: Parse IAM policies (SAM, Serverless Framework,82 Terraform) and flag `Action: *`, `Resource: *`, or overly broad permissions.832. **Event injection**: Find event data (API Gateway, SQS, S3, SNS) used84 in SQL, shell commands, or file paths without sanitization.853. **Secrets in environment**: Check for secrets in plaintext environment86 variable definitions in IaC templates.874. **/tmp reuse**: Find code that writes sensitive data to `/tmp` without88 cleanup, which persists between warm invocations.895. **Timeout configuration**: Check for excessive timeouts that increase the90 cost and blast radius of denial-of-service attacks.916. **Concurrency limits**: Verify reserved concurrency is configured to92 prevent a single function from consuming all account capacity.9394When `--depth deep`, additionally trace:95- Cross-function event flows and trust boundaries96- IAM role assumption chains97- VPC configuration and network isolation9899### 5. Report Findings100101Format output per `../../shared/schemas/findings.md` using the `SRVLS` prefix102(e.g., `SRVLS-001`, `SRVLS-002`).103104Include for each finding:105- Severity and confidence106- Exact file location with code snippet107- Blast radius (what the overprivileged function can access)108- Concrete fix with diff when possible109- CWE references110111## What to Look For112113These are the high-signal patterns specific to serverless security. Each114maps to a detection pattern in `references/detection-patterns.md`.1151161. **Overprivileged IAM policies** -- Functions with `Action: *` or117 `Resource: *` that violate the principle of least privilege.1181192. **Event data injection** -- Untrusted event data (HTTP body, S3 key, SNS120 message) used in SQL queries, shell commands, or file paths.1211223. **Secrets in plain-text env vars** -- API keys, database passwords, and123 tokens defined as plain-text environment variables in IaC templates.1241254. **/tmp directory reuse** -- Sensitive data written to `/tmp` persists across126 warm invocations and may be accessible to subsequent executions.1271285. **Excessive function timeout** -- Timeouts set to the maximum (15 minutes129 for Lambda) when the function's task requires seconds.1301316. **Missing concurrency limit** -- No reserved concurrency, allowing a132 triggered flood to exhaust the account's concurrent execution quota.1331347. **Missing VPC configuration** -- Functions accessing internal resources135 without VPC attachment, or VPC-attached functions without security groups.136137## Scanner Integration138139| Scanner | Coverage | Command |140|---------|----------|---------|141| semgrep | Event injection, code patterns | `semgrep scan --config auto --json --quiet <target>` |142| checkov | IAM policies, IaC misconfig | `checkov -d <target> -o json --quiet` |143| tfsec | Terraform IAM, Lambda config | `tfsec <target> --format json` |144145**Fallback (no scanner)**: Use Grep with patterns from `references/detection-patterns.md`146to find IAM policies, event handling, environment variable definitions, and147/tmp usage. Report findings with `confidence: medium`.148149## Output Format150151Use the findings schema from `../../shared/schemas/findings.md`.152153- **ID prefix**: `SRVLS` (e.g., `SRVLS-001`)154- **metadata.tool**: `serverless`155- **metadata.framework**: `specialized`156- **metadata.category**: `SRVLS`157- **references.cwe**: `CWE-250`, `CWE-94`, `CWE-312`158- **references.owasp**: `A05:2021` (Security Misconfiguration)159- **references.stride**: `E` (Elevation of Privilege) or `T` (Tampering)160161Severity guidance for this category:162- **critical**: IAM `Action: *` on `Resource: *`, event injection leading to RCE163- **high**: Overly broad IAM permissions, secrets in plain-text env vars, event injection in SQL164- **medium**: /tmp reuse with sensitive data, excessive timeout, missing concurrency limit165- **low**: Slightly overprivileged IAM that follows a known pattern, informational misconfigs