Sast Graphql 标志

Sast Graphql

社区热门
utkusen
sast-graphql

使用三阶段方法检测代码库中的 GraphQL 注入漏洞:侦察阶段(确认是否使用 GraphQL,并查找不安全的操作文档拼接位置)、分批验证(由并行子智能体追踪用户输入到这些位置,每批最多 3 个候选位置)和汇总(整合各批结果)。需要 sast/architecture.md(请先运行 sast-analysis)。将发现结果输出到 sast/graphql-results.md。如果第一阶段未发现 GraphQL 技术,则跳过后续阶段。当有人要求查找 GraphQL 注入、不安全的 GraphQL 文档构造或操作字符串注入漏洞时使用。

Add to TypingMind

概览

发布者utkusen
代码仓库sast-skills
技能名称sast-graphql
星标数
1.3K
复刻数
64
附带文件
仅含指令
许可协议MIT
链接
  • Markdown 格式的指令

    模型按需加载 SKILL.md 文件,因此只有在请求确实与该技能匹配时才会消耗 Token。

  • 兼容任何大语言模型

    AI 技能采用纯 Markdown,而非特定提供商的代码,因此可搭配 GPT、Claude、Gemini、Grok 或本地模型使用。

  • 指令自成一体

    模型所需的一切都包含在指令中,无需同步额外文件。

  • 开源

    由 utkusen 发布于 GitHub。请在安装前查看技能的源文件。

安装

在 TypingMind 中安装 Sast Graphql AI 技能,即可搭配任意大语言模型使用;也可以将其放入其他支持读取 SKILL.md 的智能体中。

1

安装到 TypingMind

TypingMind 可直接从 GitHub 文件夹安装技能:读取 SKILL.md,打包资源文件,并将结果保存在本地。

  1. 打开应用,前往“插件 → 技能”。
  2. 选择“从 GitHub 安装”。
  3. 粘贴下方的技能文件夹 URL 并确认。
    https://github.com/utkusen/sast-skills/tree/main/sast-files/.agents/skills/sast-graphql
  4. 请在每个需要使用该技能的聊天中启用它。
依次选择“插件 → 技能 → 添加技能 → 从 GitHub URL 导入”,然后粘贴文件夹 URL 并点击“继续”。
2

安装到其他智能体

任何支持 Agent Skills 格式的智能体都可以使用此技能,只需将文件夹复制到该智能体的技能目录中。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/utkusen/sast-skills.git /tmp/sast-skills
mkdir -p .claude/skills
cp -r /tmp/sast-skills/sast-files/.agents/skills/sast-graphql .claude/skills/sast-graphql
复制后,请重启 Claude Code,以加载新技能。

在 TypingMind 中使用此技能

在任意 TypingMind 聊天中启用 Sast Graphql,后续即可交由模型处理。技能的名称和描述会放在系统提示词中,一旦请求匹配,模型就会自动加载完整指令,无需您手动调用,且在实际使用前不会消耗 Token。

一旦请求与技能匹配,模型就会自动加载 Sast Graphql。

兼容任何 AI 模型

AI 技能是纯 Markdown 指令,而非特定提供商的代码,因此 Sast Graphql 不局限于最初适配的模型。只需在 TypingMind 中安装一次,即可搭配 GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 或您自行运行的本地模型使用,全程使用您自己的 API 密钥。

  • 仅在需要时加载

    系统提示词中仅包含技能名称和描述。首次遇到匹配的请求时才会加载完整指令,因此技能未使用时,这些指令不会消耗 Token。

  • 在聊天中切换模型

    技能是指令而非代码,因此切换模型不会导致技能失效,新模型会读取同一个 SKILL.md。

技能指令

这是模型会加载的 SKILL.md 内容。请在安装前阅读,因为技能就是模型将遵循的指令。

GraphQL Injection Detection

You are performing a focused security assessment to find GraphQL injection vulnerabilities. This skill uses a three-phase approach with subagents: recon (confirm GraphQL usage and find every location where a GraphQL operation document is assembled unsafely), batched verify (trace whether user-supplied input reaches those assembly sites, in parallel batches of up to 3 sites each), and merge (consolidate batch results into the final report).

Prerequisites: sast/architecture.md must exist. Run the analysis skill first if it doesn't.


What is GraphQL Injection

GraphQL injection occurs when user-controlled data is embedded into the GraphQL document (the query, mutation, or subscription string) rather than passed only through the variables map. The parser then interprets attacker-controlled syntax — new fields, aliases, directives, or fragments — which can bypass intent, reach unauthorized resolvers, or change server-side behavior when that document is executed or forwarded.

The core pattern: unvalidated user input alters the structure or text of the GraphQL operation string passed to execute, graphql, a gateway client, or an HTTP body query field built from string operations.

What GraphQL Injection IS

  • Concatenating or interpolating user input into an operation string: `query { user(id: "${id}") { name } }`, "query { user(id: \"" + id + "\") { name } }"
  • Building the JSON query field for a downstream GraphQL HTTP request with string concat from request body or params
  • Forwarding req.body.query (or similar) into another interpolated template that wraps or extends the operation
  • Dynamic gql / graphql-tag template literals where a non-static expression changes document structure (not just a bound variable value inside a static document)
  • Server-side code that selects or assembles operation text from user input (including "persisted query" ID → document maps without allowlisting)
  • Wrappers around graphql.execute(), graphqlHTTP, Yoga/Apollo request pipeline where the first argument (document/source) is built from variables that could be user-influenced

What GraphQL Injection is NOT

Do not flag these as GraphQL injection:

  • SQL injection in resolvers: Resolver code that builds SQL from args — that is SQL injection (sast-sqli), not this skill
  • NoSQL / command injection in resolvers: Same — use the appropriate SAST skill
  • IDOR via GraphQL arguments: Passing another user's ID in a variables JSON with a static document — authorization flaw, not document injection
  • Normal variable binding: Static document with {"query": "query($id: ID!) { user(id: $id) { name } }", "variables": {"id": userInput}} — values are bound as variables; the document structure is fixed (still verify authorization in resolvers)
  • Introspection / field suggestion enabled: Information disclosure and hardening topic; only flag as GraphQL injection if the finding is specifically about injecting into the operation string
  • Query depth / complexity DoS: Rate limiting and cost analysis — different class

Patterns That Prevent GraphQL Injection

1. Static operation documents with variables

javascript
const GET_USER = gql`
  query GetUser($id: ID!) {
    user(id: $id) { name }
  }
`;
// execute(schema, GET_USER, null, context, { id: userId });

2. Server uses standard HTTP handler; client sends document; server parses once

The risk is not the mere presence of req.body.query on the server if the server only parses and executes it as the client's operation — injection in that path is client-side. Flag server-side construction of a new document that incorporates user strings before execute or before forwarding.

3. Persisted queries / allowlisted operation IDs

Document looked up by ID from a server-side registry; client cannot inject arbitrary document text.

4. graphql-js Source with static string; dynamic values only in variableValues

javascript
graphql({ schema, source: staticQueryString, variableValues: { id: userId } });

Vulnerable vs. Secure Examples

Node.js — dynamic document for downstream API

javascript
// VULNERABLE: user input in operation text
app.post('/proxy', async (req, res) => {
  const fragment = req.body.fragment;
  const query = `query { me { ${fragment} } }`;
  const data = await fetch('https://api.internal/graphql', {
    method: 'POST',
    body: JSON.stringify({ query }),
  });
});

// SECURE: static operation, user data only in variables
const PROXY_QUERY = `query ProxyMe { me { id name email } }`;
app.post('/proxy', async (req, res) => {
  const data = await fetch('https://api.internal/graphql', {
    method: 'POST',
    body: JSON.stringify({ query: PROXY_QUERY }),
  });
});

Python — string format into execute

python
# VULNERABLE
def run_custom_query(user_gql: str):
    document = f"query {{ user {{ {user_gql} }} }}"
    return graphql_sync(schema, document)

# SECURE: validate against allowlist of named operations or use static documents only
ALLOWED = {"id", "name", "email"}
fields = [f for f in requested_fields if f in ALLOWED]
document = "query { user { " + " ".join(ALLOWED.intersection(set(requested_fields))) + " } }"
# Better: fixed FieldNodes, not string building from user input

Execution

This skill runs in three phases using subagents. Pass the contents of sast/architecture.md to all subagents as context.

Phase 1: GraphQL Technology Recon and Injection Candidate Sites

Launch a subagent with the following instructions:

Goal: (1) Determine whether this codebase uses GraphQL at all. (2) If it does, find every location where a GraphQL operation document (query/mutation/subscription source string) is built using string concatenation, interpolation, formatting, or dynamic assembly such that a variable could change the document text (not merely variables JSON). Write results to sast/graphql-recon.md.

Context: You will be given the project's architecture summary. Use it for stack, API layout, and BFF/gateway patterns.

Part A — Is GraphQL used?

Search for:

  • Dependencies: graphql, @apollo/server, apollo-server-express, @nestjs/graphql, graphql-yoga, @graphql-yoga/node, mercurius, strawberry-graphql, graphene, sangria, gqlgen, async-graphql, juniper, graphql-ruby, Hot Chocolate / GraphQL.Server, etc.
  • Schema artifacts: *.graphql, *.graphqls, codegen config (e.g. GraphQL Code Generator)
  • Server routes or plugins mounting /graphql or similar

Set the summary to exactly one of:

  • GraphQL is used in this codebase. (list libraries and main entry points)
  • GraphQL is not used in this codebase.

Part B — Injection candidate sites (only if GraphQL is used)

If GraphQL is not used, omit the "Injection Candidate Sites" section or state there are none. Do not invent candidates.

If GraphQL is used, search for unsafe document construction:

  1. String concatenation / interpolation into operation text:
    • `query { ... ${x} ...}`, "mutation { " + userFragment + " }"
    • sprintf, format, % formatting, .format() building query or source arguments
  2. Calls where the document argument is not a compile-time constant:
    • graphql(schema, dynamicString, ...), execute({ schema, document: parsedDynamic, ...}) where the string feeding parse or execute is built from non-static parts
    • graphqlHTTP({ schema, rootValue, context: (req) => ({ query: req.body.query + something }) }) patterns that mutate or wrap the query string with user data
  3. HTTP clients forwarding a constructed GraphQL body:
    • JSON.stringify({ query: ...${userPart}... }), axios.post(url, { query: builtFromInput })
  4. Unsafe persisted / stored query lookup:
    • Operation text loaded by key from user input without allowlist → file path or DB value becomes document source

What to skip (do not flag as Phase 1 candidates):

  • Fully static source / query strings; only variableValues / variables come from the request
  • Schema definition with buildSchema / SDL files with no user interpolation
  • Resolver implementations that only use args with parameterized DB APIs (optional: note "resolver uses ORM" but not a GraphQL injection candidate unless the document is built unsafely)

Output format — write to sast/graphql-recon.md:

markdown
# GraphQL Recon: [Project Name]

## Summary
GraphQL is [used / not used] in this codebase.
[If used: libraries, main server files, typical endpoint paths]
Found [N] injection candidate site(s) where operation documents may be built unsafely. [If not used, say N/A or 0 and skip candidate list]

## GraphQL Surface (only if used)
- **Libraries / frameworks**: ...
- **Entry points**: ...
- **Notable files**: ...

## Injection Candidate Sites

### 1. [Descriptive name]
- **File**: `path/to/file.ext` (lines X-Y)
- **Function / endpoint**: ...
- **Execution / call pattern**: [graphql.execute / fetch with body / gql template / etc.]
- **Construction pattern**: [concat / template literal / format / forwarded body mutation]
- **Interpolated variable(s)**: ...
- **Code snippet**:

...


[Repeat for each site; if none, write "No injection candidate sites found." under the heading]

After Phase 1: Gates Before Phase 2

After Phase 1 completes, read sast/graphql-recon.md.

Gate 1 — No GraphQL technology

If the summary states GraphQL is not used (or equivalent: no GraphQL libraries, no schema, no server — clear absence), skip Phases 2 and 3. Write the following to sast/graphql-results.md and stop:

markdown
# GraphQL Injection Analysis Results

No GraphQL technology detected in this codebase.

Gate 2 — GraphQL used but no injection candidates

If GraphQL is used but there are zero injection candidate sites (summary reports 0 candidates, or the "Injection Candidate Sites" section states none found / is empty), skip Phases 2 and 3. Write the following to sast/graphql-results.md and stop:

markdown
# GraphQL Injection Analysis Results

No vulnerabilities found.

Otherwise proceed to Phase 2.

Phase 2: Trace User Input to Injection Candidate Sites (Batched)

After Phase 1 completes and both gates pass (GraphQL used and at least one candidate site), read sast/graphql-recon.md and split the Injection Candidate Sites into batches of up to 3 sites each (each ### N. section is one site). Launch one subagent per batch in parallel. Each subagent traces taint only for its assigned sites and writes results to its own batch file.

Batching procedure (you, the orchestrator, do this — not a subagent):

  1. Read sast/graphql-recon.md and count the numbered candidate sections under "Injection Candidate Sites" (### 1., ### 2., etc.).
  2. Divide them into batches of up to 3. For example, 8 sites → 3 batches (1-3, 4-6, 7-8).
  3. For each batch, extract the full text of those candidate sections from the recon file.
  4. Launch all batch subagents in parallel, passing each one only its assigned candidate sections (plus architecture context).
  5. Each subagent writes to sast/graphql-batch-N.md where N is the 1-based batch number.
  6. Identify the project's primary language/framework from sast/architecture.md and select only the matching examples from the "Vulnerable vs. Secure Examples" section above. For example, if the project uses Node.js, include the "Node.js — dynamic document for downstream API" example; if Python, include "Python — string format into execute". Include these selected examples in each subagent's instructions where indicated by [TECH-STACK EXAMPLES] below.

Give each batch subagent the following instructions (substitute the batch-specific values):

Goal: For each assigned injection candidate site, determine whether user-supplied data can reach the dynamic part of the operation document. Our goal is to find GraphQL injection vulnerabilities. Write results to sast/graphql-batch-[N].md.

Your assigned candidate sites (from the recon phase):

[Paste the full text of the assigned candidate sections here, preserving the original numbering]

Context: You will be given the project's architecture summary. Use it for API layout, request handling, and BFF/gateway patterns.

GraphQL injection reference — What to look for:

User-controlled data must not alter the GraphQL document text (query/mutation/subscription source) except through bound variables on a static document. Flag when taint reaches string assembly of the operation.

What GraphQL injection is NOT — do not flag these here:

  • SQL/NoSQL injection in resolvers — other SAST skills
  • IDOR with static document + variables — authorization, not document injection
  • Normal variable binding on a fixed document string
  • Introspection enabled — unless the finding is specifically operation-string injection
  • Query depth/complexity DoS — different class

Mitigations that reduce risk:

  • Allowlist of fields or operation IDs before any string assembly
  • Parser validation that rejects unexpected definitions (still prefer no user-controlled document structure)

Vulnerable vs. secure examples for this project's tech stack:

[TECH-STACK EXAMPLES]

For each assigned site, trace dynamic values backward:

  1. Direct user input — query params, path params, JSON body fields (including nested query if re-wrapped), headers, cookies
  2. Indirect user input — helpers, middleware, context builders
  3. Second-order — stored preferences or DB fields later used to build a document; trace write path
  4. Server-only — config, env, hardcoded fragments — not exploitable from the client

Classification:

  • Vulnerable: User-controlled data reaches document construction with no effective mitigation
  • Likely Vulnerable: Probable taint or weak sanitization
  • Not Vulnerable: Server-side-only or effective allowlist / static document path
  • Needs Manual Review: Opaque flow

Output format — write to sast/graphql-batch-[N].md:

markdown
# GraphQL Batch [N] Results

## Findings

### [VULNERABLE] Descriptive name
- **File**: `path/to/file.ext` (lines X-Y)
- **Endpoint / function**: ...
- **Issue**: ...
- **Taint trace**: ...
- **Impact**: [e.g., unauthorized fields, gateway bypass, SSRF-style behavior to internal GraphQL]
- **Remediation**: [static operations; variables only; persisted query allowlist]
- **Dynamic Test**:

[curl or in-browser GraphQL request showing injected fragment/directive/field]


### [LIKELY VULNERABLE] Descriptive name
- **File**: ...
- **Endpoint / function**: ...
- **Issue**: ...
- **Taint trace**: ...
- **Concern**: ...
- **Remediation**: ...
- **Dynamic Test**:

...


### [NOT VULNERABLE] Descriptive name
- **File**: ...
- **Endpoint / function**: ...
- **Reason**: ...

### [NEEDS MANUAL REVIEW] Descriptive name
- **File**: ...
- **Endpoint / function**: ...
- **Uncertainty**: ...
- **Suggestion**: ...

Phase 3: Merge — Consolidate Batch Results

After all Phase 2 batch subagents complete, read every sast/graphql-batch-*.md file and merge them into a single sast/graphql-results.md. You (the orchestrator) do this directly — no subagent needed.

Merge procedure:

  1. Read all sast/graphql-batch-1.md, sast/graphql-batch-2.md, ... files.
  2. Collect all findings from each batch file and combine them into one list, preserving the original classification and all detail fields.
  3. Count totals across all batches for the executive summary.
  4. Write the merged report to sast/graphql-results.md using this format:
markdown
# GraphQL Injection Analysis Results: [Project Name]

## Executive Summary
- Candidate sites analyzed: [total across all batches]
- Vulnerable: [N]
- Likely Vulnerable: [N]
- Not Vulnerable: [N]
- Needs Manual Review: [N]

## Findings

[All findings from all batches, grouped by classification:
 VULNERABLE first, then LIKELY VULNERABLE, then NEEDS MANUAL REVIEW, then NOT VULNERABLE.
 Preserve every field from the batch results exactly as written.]
  1. After writing sast/graphql-results.md, delete all intermediate batch files (sast/graphql-batch-*.md).

Important Reminders

  • Read sast/architecture.md and pass its content to all subagents as context.
  • If Phase 1 finds no GraphQL technology, skip Phases 2 and 3 — write the "No GraphQL technology detected" results file.
  • If GraphQL is used but Phase 1 finds no injection candidates, skip Phases 2 and 3 — write "No vulnerabilities found."
  • Phase 2 must run after Phase 1 completes — it depends on the recon output.
  • Phase 3 must run after all Phase 2 batches complete — it depends on all batch outputs.
  • Batch size is 3 candidate sites per subagent. If there are 1-3 sites total, use a single subagent. If there are 10, use 4 subagents (3+3+3+1).
  • Launch all batch subagents in parallel — do not run them sequentially.
  • Each batch subagent receives only its assigned candidates' text from the recon file, not the entire recon file. This keeps each subagent's context small and focused.
  • Phase 1 does not trace taint; Phase 2 does.
  • Resolver-layer SQL/NoSQL issues belong to other skills; this skill targets operation document construction.
  • When in doubt, classify as "Needs Manual Review" rather than "Not Vulnerable".
  • Clean up intermediate files: delete sast/graphql-recon.md and all sast/graphql-batch-*.md files after the final sast/graphql-results.md is written.

常见问题

Sast Graphql AI 技能有什么作用?

使用三阶段方法检测代码库中的 GraphQL 注入漏洞:侦察阶段(确认是否使用 GraphQL,并查找不安全的操作文档拼接位置)、分批验证(由并行子智能体追踪用户输入到这些位置,每批最多 3 个候选位置)和汇总(整合各批结果)。需要 sast/architecture.md(请先运行 sast-analysis)。将发现结果输出到 sast/graphql-results.md。如果第一阶段未发现 GraphQL 技术,则跳过后续阶段。当有人要求查找 GraphQL 注入、不安全的 GraphQL 文档构造或操作字符串注入漏洞时使用。

为什么在 TypingMind 中使用 Sast Graphql?

因为您只需安装一次,就能搭配任何模型使用。Sast Graphql 采用纯 Markdown 格式,而非特定提供商专用的代码,因此同一技能可用于 GPT-5、Claude、Gemini、Grok 或本地模型。您甚至可以在聊天中途切换模型,而不会影响技能的正常使用。TypingMind 使用您自己的 API 密钥,因此您直接向提供商付费,而不是按席位订阅;您的技能和聊天记录也都保留在您自己的存储空间中。

如何在 TypingMind 中安装 Sast Graphql?

在 TypingMind 中打开“插件 → 技能 → 从 GitHub 安装”,然后粘贴 https://github.com/utkusen/sast-skills/tree/main/sast-files/.agents/skills/sast-graphql。TypingMind 会读取其中的 SKILL.md,并将其安装为技能,供您在各个聊天中按需启用。

哪些 AI 模型可以使用 Sast Graphql?

您在 TypingMind 中连接的任何模型都可以。AI 技能采用纯 Markdown 指令,而非特定提供商专用的代码,因此 GPT、Claude、Gemini、Grok 和本地模型都能在请求匹配时加载此技能。

Sast Graphql 可以搭配多少个 AI 模型使用?

数量不限。只要模型支持技能,您就可以将它与 Sast Graphql 搭配使用。GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 等模型都可以通过您自己的 API 密钥接入 TypingMind。

Sast Graphql AI 技能免费吗?

是的。utkusen 已在 GitHub 上根据 MIT 许可证发布了该技能。您只需向自己的 AI 提供商支付所用 Token 的费用。

什么是 AI 技能?

AI 技能是一组可复用的指令,用于教会 AI 模型完成某项特定任务。它遵循开放的 Agent Skills 格式:包含名称和描述的 SKILL.md 文件,以及模型可能需要的脚本、模板或参考文件。模型仅在您的请求与技能匹配时才会读取这些指令,因此已安装的技能在使用前不会产生任何费用。

AI 技能与插件或 MCP 服务器有何不同?

插件或 MCP 服务器为模型提供可调用的新工具,也就是在某处运行并返回结果的代码。AI 技能则为模型提供知识和流程:如何处理任务、遵循哪些步骤,以及怎样的输出才算优质。技能采用纯 Markdown 格式,因此不需要服务器、API 密钥或运行时环境,并且适用于任何模型。

查看全部

立即创建您自己的 AI 工作区

订阅我们的电子简报,获取新功能和后续赠奖活动的通知 👇