detecting-serverless-function-injection
What it does
This tool helps find and prevent attacks that try to run malicious code in cloud functions (like AWS Lambda). It checks if data received by these functions can be used to execute unwanted commands or steal information.
When to use it
- ✓When checking if cloud functions can be attacked through the data they receive.
- ✓When investigating if an attacker modified a function's code for persistent access.
- ✓When looking for ways an attacker could gain more permissions than they should have.
Skill link
https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/detecting-serverless-function-injection/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agent’s skills folder.
Example of what to ask your AI
“Scan my Lambda functions for code injection via event data.”
5 new skills a week. 1 minute to read.
How it works
The tool analyzes the function's code and cloud activity logs. It looks for dangerous patterns that could allow malicious commands to be executed using the data the function receives.
Technical content (original SKILL.md)
Original text by the author, straight from GitHub.
Detecting Serverless Function Injection
When to Use
- Auditing Lambda/Cloud Functions for code injection vulnerabilities where unsanitized event data flows into dangerous runtime functions (
eval,exec,child_process.exec,os.system) - Investigating incidents where an attacker modified function code or layers to establish persistence or exfiltrate data from the serverless environment
- Detecting privilege escalation paths where an adversary with
lambda:UpdateFunctionCodeandiam:PassRolecan assume higher-privilege execution roles - Analyzing event source poisoning attacks where malicious payloads are injected through S3 object uploads, SQS messages, DynamoDB stream records, or API Gateway requests that trigger function execution
- Building detection rules for SOC teams monitoring serverless workloads for unauthorized function modifications, layer additions, and suspicious invocation patterns
Do not use for load testing or denial-of-service simulation against serverless functions, for testing against production functions processing live customer data without explicit authorization, or for modifying IAM policies in shared accounts without change management approval.
Prerequisites
- AWS account access with read permissions for Lambda, CloudTrail, IAM, CloudWatch Logs, and EventBridge
- AWS CLI v2 configured with appropriate credentials and region
- CloudTrail enabled with Data Events for Lambda (captures
Invokeevents) and Management Events (capturesUpdateFunctionCode,UpdateFunctionConfiguration,CreateFunction) - Python 3.9+ with
boto3,bandit(Python SAST), andsemgrepfor static analysis - Access to function source code or deployment packages for static analysis
- CloudWatch Logs Insights access for querying Lambda execution logs
Workflow
Step 1: Enumerate the Serverless Attack Surface
Map all Lambda functions and their event source triggers to understand injection entry points:
- List all Lambda functions and their configurations:
aws lambda list-functions --query 'Functions[*].[FunctionName,Runtime,Role,Handler,Layers]' --output table - Map event source mappings: Each event source mapping is a potential injection entry point where untrusted data enters the function:
aws lambda list-event-source-mappings --output json | \ jq '.EventSourceMappings[] | {Function: .FunctionArn, Source: .EventSourceArn, State: .State}' - Identify API Gateway triggers: API Gateway routes pass HTTP request data (headers, query strings, body, path parameters) directly into the Lambda event object:
For each API, enumerate resources and methods to identify which Lambda functions receive user-controlled HTTP input.aws apigateway get-rest-apis --query 'items[*].[id,name]' --output table - Identify S3 event triggers: S3 bucket notifications can trigger Lambda with attacker-controlled object keys and metadata:
aws s3api get-bucket-notification-configuration --bucket <bucket-name> - Catalog function environment variables: Secrets in environment variables are exposed if an attacker achieves code execution inside the function:
aws lambda get-function-configuration --function-name <name> \ --query 'Environment.Variables' --output json - Identify overprivileged execution roles: Functions with
*resource permissions or administrative policies are high-value escalation targets:aws iam list-attached-role-policies --role-name <lambda-exec-role> aws iam list-role-policies --role-name <lambda-exec-role>
Step 2: Static Analysis for Injection Sinks
Scan function code for dangerous patterns that allow injected event data to execute as code or commands:
- Download function deployment packages:
aws lambda get-function --function-name <name> --query 'Code.Location' --output text | xargs curl -o function.zip unzip function.zip -d function_code/ - Python injection sinks (Lambda Python runtimes): Search for functions that execute strings as code:
# DANGEROUS: Direct eval/exec of event data eval(event['expression']) # Code injection via eval exec(event['code']) # Arbitrary code execution os.system(event['command']) # OS command injection subprocess.call(event['cmd'], shell=True) # Shell injection os.popen(event['input']) # Command injection
…
FAQ
What are 'serverless functions'?
These are programs that run in the cloud without you needing to manage servers. Common examples include AWS Lambda, Azure Functions, and Google Cloud Functions.
What is 'code injection'?
It's a type of attack where an attacker inserts malicious code into a program. If the program runs this code, the attacker can gain control, steal data, or cause other damage.
What is 'event source poisoning'?
This is an attack where malicious data is sent through services that trigger cloud functions (like files uploaded to storage or messages in a queue). This data can then be used to attack the function.
Details
Original description by the author
Detects and prevents code injection attacks targeting serverless functions (AWS Lambda, Azure Functions, Google Cloud Functions) through event source poisoning, malicious layer injection, runtime command execution, and IAM privilege escalation via function modification. The analyst combines static analysis of function code, CloudTrail event correlation, runtime behavior monitoring, and IAM policy
Popularity
- GitHub stars
- 35k
- Ranking position
- #7871
- License
- Apache-2.0
- Updated
- 8/31/2026
Comments
- …
More skills from this repository
abusing-dpapi-for-credential-access
35kGives your AI agent ready-made instructions for a specific task, so it does it better and faster.
abusing-shadow-credentials-for-privesc
35kTeaches your AI agent to write clear, well-structured text.
achieving-cmmc-level-2-compliance
35kHelps your agent prepare an environment for CMMC Level 2 compliance. It implements security requirements and manages necessary documentation.
acquiring-disk-image-with-dd-and-dcfldd
35kHelps your agent create exact copies of hard drives. This is useful for ensuring no information is lost or altered during investigations.
Similar skills
add-model-provider
394kLets your agent connect a new AI model provider to OpenClaw using safe setup commands, keep API keys out of plain text, and run a live test.
acp-router
394kHelps your agent send a task to a coding assistant such as Claude Code or Cursor through OpenClaw, so the work runs in that tool.
browser-automation
394kTeaches your agent to control web pages step by step, including logins, tabs, and recovery when a page stops responding.