detecting-serverless-function-injection
できること
このツールは、AWS Lambdaなどのクラウド関数内で不正なコードを実行させようとする攻撃を見つけて防ぐのに役立ちます。関数が受け取るデータを使って、意図しないコマンドを実行したり、情報を盗んだりできないかを確認します。
使う場面
- ✓関数が受け取るデータを通じて攻撃される可能性があるかを確認するとき。
- ✓攻撃者が関数のコードを改変し、継続的にアクセスできるようにしていないかを調べるとき。
- ✓攻撃者が本来より多くの権限を得られる方法がないかを探すとき。
スキルのリンク
https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/detecting-serverless-function-injection/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“Lambda関数をスキャンして、イベントデータを経由したコードインジェクションがないか調べて。”
毎週5つの新しいスキル。1分で読めます。
仕組み
このツールは、関数のコードとクラウドのアクティビティログを分析します。関数が受け取るデータを使って悪意のあるコマンドが実行されてしまう可能性のある、危険なパターンを探します。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)を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
…
よくある質問
「サーバーレス関数」とは何ですか?
サーバーを自分で管理しなくても、クラウド上で動作するプログラムのことです。代表的なものにAWS Lambda、Azure Functions、Google Cloud Functionsがあります。
「コードインジェクション」とは何ですか?
攻撃者が悪意のあるコードをプログラムに埋め込む攻撃の一種です。そのコードが実行されると、攻撃者がプログラムを乗っ取ったり、データを盗んだり、別の被害を与えたりできてしまいます。
「イベントソースポイズニング」とは何ですか?
クラウド関数を起動させるサービス(ストレージにアップロードされたファイルや、キューに入ったメッセージなど)を通じて、悪意のあるデータを送り込む攻撃です。そのデータを使って関数を攻撃します。
詳細
作者による元の説明
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
人気
- GitHubのスター
- 35k
- ランキング
- #7871
- ライセンス
- Apache-2.0
- 更新日
- 2026/8/31
コメント
- …
このリポジトリの他のスキル
abusing-dpapi-for-credential-access
35k特定のタスク向けに用意された指示をAIエージェントに与え、より良く、より速く作業できるようにします。
abusing-shadow-credentials-for-privesc
35kAIエージェントに、明確で構成のしっかりした文章の書き方を教えます。
achieving-cmmc-level-2-compliance
35kエージェントがCMMC Level 2への準拠に向けた環境を整えられるようにします。セキュリティ要件を実装し、必要なドキュメントを管理します。
acquiring-disk-image-with-dd-and-dcfldd
35kエージェントがハードディスクの完全なコピーを作成できるようにします。調査中に情報が失われたり改変されたりしないようにするのに役立ちます。
似ているスキル
add-model-provider
394k安全なセットアップコマンドで新しいAIモデルプロバイダーをOpenClawに接続し、APIキーを平文で残さず、ライブテストを行うようエージェントを支援します。
acp-router
394kClaude CodeやCursorなどのコーディングアシスタントに、OpenClaw経由でタスクを渡し、その作業がそのツール内で行われるようエージェントを支援します。
browser-automation
394kログイン、タブ、応答しなくなったページからの復旧を含め、Webページを段階的に操作するようエージェントに教えます。