Go Vuln Injection logo

Go Vuln Injection

Community
yhy0
go-vuln-injection

Use when auditing Go code involving OS command execution, SQL queries, template rendering, or child command invocation. Covers CWE-78/89/77/94/88. Keywords: command injection, SQL injection, exec.Command, os/exec, database/sql, text/template, html/template, argument injection, shell injection, Gogs, Grafana, MCP stdio

Overview

Publisheryhy0
Repositoryghsa-skill-builder
Skill namego-vuln-injection
Stars
75
Forks
8
Bundled files
1
LicenseMIT
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.

  • 1 bundled files

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

  • Open source

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

Installation

Install the Go Vuln Injection 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.
    https://github.com/yhy0/ghsa-skill-builder/tree/main/vuln-skills/skills/go-vuln-injection
  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/yhy0/ghsa-skill-builder.git /tmp/ghsa-skill-builder
mkdir -p .claude/skills
cp -r /tmp/ghsa-skill-builder/vuln-skills/skills/go-vuln-injection .claude/skills/go-vuln-injection
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Go Vuln Injection 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 Go Vuln Injection 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 Go Vuln Injection 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.

Go Injection Vulnerability Patterns (CWE-78/89/77/94/88)

当审计 Go 代码中涉及命令执行、SQL 查询、模板渲染、外部进程调用时加载此 Skill。

Detection Strategy

Sources(攻击入口):

  • HTTP 请求参数(query params, form values, JSON body)
  • gRPC 请求字段
  • Git 仓库内容(commit message, branch name, file content)
  • MCP tool 输入参数
  • 用户提交的配置值(Helm values, Kustomize patches)
  • AI/LLM 生成的 SQL 查询

Sinks(危险操作):

  • exec.Command("sh", "-c", userInput) -- OS 命令注入
  • exec.Command("bash", "-c", userInput) -- 同上
  • exec.Command(binary, "--flag=" + userInput) -- 参数注入 (CWE-88)
  • exec.CommandContext(ctx, "git", "--upload-pack=evil", ...) -- Git argument injection
  • db.Query("SELECT * FROM t WHERE id=" + userInput) -- SQL 注入
  • db.Exec(fmt.Sprintf("INSERT INTO t VALUES ('%s')", userInput)) -- SQL 注入
  • template.New("").Parse(userInput) (text/template) -- 模板注入
  • template.HTML(userInput) -- XSS(绕过 html/template 自动转义)

Sanitization(安全屏障):

  • exec.Command(binary, arg1, arg2) -- 不经过 shell,每个参数独立传递
  • db.Query(sql, args...) / db.Exec(sql, args...) -- 参数化查询
  • html/template(非 text/template)-- 自动 HTML 转义
  • shellescape / shlex 包 -- shell 参数转义
  • 输入白名单验证(正则匹配允许的字符)

检测路径:

bash
# OS 命令执行
grep -rn "exec.Command\|exec.CommandContext\|os.StartProcess" --include="*.go"
# Shell 调用
grep -rn '"sh".*"-c"\|"bash".*"-c"\|"cmd".*"/c"' --include="*.go"
# SQL 拼接
grep -rn 'fmt.Sprintf.*SELECT\|fmt.Sprintf.*INSERT\|fmt.Sprintf.*UPDATE\|fmt.Sprintf.*DELETE' --include="*.go"
grep -rn 'Sprintf.*WHERE\|"+.*WHERE\|`.*%s.*FROM' --include="*.go"
# 模板注入
grep -rn "text/template\|template.New\|template.Must" --include="*.go"
# 参数化查询(安全模式)
grep -rn "db.Query.*,\|db.Exec.*,\|db.QueryRow.*," --include="*.go"
# Argument injection — Git
grep -rn '"git".*"--upload-pack\|"git".*"--exec-path\|"git".*"--config"' --include="*.go"
  1. 定位命令执行/SQL 查询/模板渲染的 Sink 函数
  2. 回溯参数来源,确认是否包含用户输入
  3. 验证是否有安全屏障:
    • exec.Command 是否通过 shell(sh -c)执行?直接传参不经过 shell 通常安全
    • SQL 是否使用参数化查询(? 占位符)?fmt.Sprintf 拼接 SQL 是危险信号
    • 模板是否使用 html/template(安全)而非 text/template(不安全)?
    • Git 命令是否允许用户控制 --upload-pack、--config 等可执行的参数?
  4. 若无安全屏障或屏障可被绕过 -> 标记为候选漏洞

Detection Checklist

  • exec.Command Shell 调用审计 (CWE-78):是否使用 exec.Command("sh", "-c", input) 或 exec.Command("bash", "-c", input) 执行用户输入?Go 中 exec.Command 默认不经过 shell,但显式调用 shell 时存在注入风险。
  • Git Argument Injection 审计 (CWE-88):exec.Command("git", userArgs...) 是否允许用户注入 --upload-pack、--exec-path、--config=core.sshCommand=evil 等可执行参数?Gogs 的 SSH argument injection 是经典案例。
  • SQL 字符串拼接审计 (CWE-89):是否使用 fmt.Sprintf 或字符串连接构造 SQL?应使用 db.Query(sql, args...) 的参数化形式。特别注意 ORDER BY、LIMIT 等不能用参数化的子句。
  • AI/LLM 生成 SQL 审计 (CWE-89):AI 数据库查询工具(如 WeKnora)生成的 SQL 是否经过安全过滤?LLM 输出不可信,必须有 SQL 白名单或 AST 解析验证。
  • text/template 用于 HTML 审计 (CWE-94):是否误用 text/template 生成 HTML 输出?应使用 html/template 以获得自动转义。检查 import 路径。
  • Helm/Kustomize 模板注入审计 (CWE-94):用户提交的 Helm values 是否被直接注入模板?{{ 语法是否能执行任意 Go 模板函数?Flux helm-controller 曾因此导致 RCE。
  • MCP Stdio 命令注入审计 (CWE-78):MCP server 的 stdio transport 配置中的 command 字段是否经过验证?WeKnora 的 MCP stdio test 功能曾允许注入任意命令。
  • os.StartProcess 参数审计 (CWE-78):低层级的 os.StartProcess 调用是否正确隔离了参数?参数数组中是否有用户控制的元素?

False Positive Exclusion Guide

以下模式不是此类漏洞:

  • exec.Command("git", "--version") -- 无用户输入的硬编码命令
  • exec.Command(binary, fixedArgs...) -- 参数完全硬编码,无用户输入
  • db.Query("SELECT * FROM t WHERE id = ?", userID) -- 参数化查询是安全的
  • html/template 渲染用户输入 -- 自动转义会处理 XSS(除非使用 template.HTML() 类型转换)
  • fmt.Sprintf 用于日志而非 SQL -- 拼接字符串用于 log 而非数据库查询

以下模式需要深入检查:

  • exec.Command("git", userProvidedRepoURL) -- URL 中可能包含 --upload-pack 参数
  • db.Exec("CREATE TABLE " + tableName) -- DDL 语句中标识符不能用 ? 参数化
  • text/template 用于非 HTML 输出 -- 如生成 YAML/JSON,可能导致结构注入
  • strings.Replace(input, "'", "''", -1) -- 手工 SQL 转义极易遗漏边缘情况

Real-World Cases

详见 references/cases.md(7 个真实案例,需要时加载)。

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 Go Vuln Injection AI skill do?

Use when auditing Go code involving OS command execution, SQL queries, template rendering, or child command invocation. Covers CWE-78/89/77/94/88. Keywords: command injection, SQL injection, exec.Command, os/exec, database/sql, text/template, html/template, argument injection, shell injection, Gogs, Grafana, MCP stdio

Why use Go Vuln Injection on TypingMind?

Because you install it once and use it with any model. Go Vuln Injection 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 Go Vuln Injection in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/yhy0/ghsa-skill-builder/tree/main/vuln-skills/skills/go-vuln-injection. 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 Go Vuln Injection?

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 Go Vuln Injection?

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

Is the Go Vuln Injection AI skill free?

Yes. It is published on GitHub by yhy0 under the MIT license. 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 👇