detecting-serverless-function-injection
ما الذي تفعله
تساعد هذه المهارة على اكتشاف الهجمات التي تحاول تشغيل شيفرة خبيثة في الدوال السحابية (مثل AWS Lambda) ومنعها. تتحقق مما إذا كانت البيانات التي تستقبلها هذه الدوال يمكن أن تُستخدم لتنفيذ أوامر غير مرغوب فيها أو لسرقة المعلومات.
متى تستخدمها
- ✓عند التحقق مما إذا كان يمكن مهاجمة الدوال السحابية عبر البيانات التي تستقبلها.
- ✓عند التحقيق في ما إذا عدّل مهاجم شيفرة دالة للحصول على وصول دائم.
- ✓عند البحث عن طرق قد يحصل بها المهاجم على صلاحيات أكبر من المسموح.
رابط المهارة
https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/detecting-serverless-function-injection/SKILL.mdانسخه والصقه في الذكاء الاصطناعي الذي تستخدمه (Claude أو ChatGPT أو Cursor) واطلب منه اتباع التعليمات.
طريقة الاستخدام
أسهل طريقة: انسخ الرسالة والصقها في الذكاء الاصطناعي الذي تستخدمه. سيقرأ المهارة وينفّذ تعليماتها.
رسالة جاهزة للصق
لـ Claude Code أو Codex أو Cursor: شغّله داخل مجلد مشروعك وستُثبَّت المهارة.
نزّل ملف SKILL.md وضعه في مجلد مهارات وكيلك.
مثال على ما تطلبه من الذكاء الاصطناعي
“افحص دوال Lambda الخاصة بي بحثًا عن حقن الشيفرة عبر بيانات الأحداث.”
5 مهارات جديدة كل أسبوع. قراءة في دقيقة واحدة.
كيف تعمل
تحلل هذه المهارة شيفرة الدالة وسجلات النشاط السحابي. تبحث عن أنماط خطرة قد تسمح بتنفيذ أوامر ضارة باستخدام البيانات التي تستقبلها الدالة.
المحتوى التقني (ملف 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
- آخر تحديث
- 31/8/2026
التعليقات
- …
المزيد من المهارات من هذا المستودع
abusing-dpapi-for-credential-access
35kيمنح وكيل الذكاء الاصطناعي تعليمات جاهزة لمهمة محددة، ليؤديها بشكل أفضل وأسرع.
abusing-shadow-credentials-for-privesc
35kيعلّم وكيل الذكاء الاصطناعي لديك كتابة نص واضح ومنظم جيدًا.
achieving-cmmc-level-2-compliance
35kيساعد وكيلك على تجهيز بيئة للامتثال لمستوى CMMC 2. يطبق متطلبات الأمان ويدير الوثائق اللازمة.
acquiring-disk-image-with-dd-and-dcfldd
35kيساعد وكيلك على إنشاء نسخ مطابقة تمامًا لأقراص التخزين. هذا مفيد لضمان عدم فقدان أي معلومات أو تغييرها أثناء التحقيقات.
مهارات مشابهة
add-model-provider
394kتتيح لوكيلك ربط مزوّد نموذج ذكاء اصطناعي جديد بـ OpenClaw باستخدام أوامر إعداد آمنة، وإبقاء مفاتيح API خارج النص العادي، وإجراء اختبار حي.
acp-router
394kيساعد وكيلك على إرسال مهمة إلى مساعد برمجة مثل Claude Code أو Cursor عبر OpenClaw، فيعمل العمل داخل تلك الأداة.
browser-automation
394kتعلّم وكيلك التحكم في صفحات الويب خطوة بخطوة، بما في ذلك تسجيل الدخول والتبويبات والتعافي عندما تتوقف الصفحة عن الاستجابة.