跳转到正文
报告库
用途分类 / 开发辅助

Golang Concurrency Skill 安全审计

作者说它能做什么(原文)

Golang concurrency design — goroutine lifecycle and leak prevention, channels and `select`, channel ownership and direction, `sync.Mutex`/`RWMutex`/`sync.Map`/`sync.Once`/atomics, `errgroup`, `singleflight`, worker pools, and fan-out/fan-in pipelines. Use when writing or reviewing concurrent Go code, when choosing between channels and mutexes, when protecting a shared map or counter, or when a gor

第三方安全检查结论

发现安全风险

已检查文件
5
发现的风险
4
会不会运行危险命令?检查是否下载程序后直接运行、让他人远程控制电脑,或藏起要运行的命令。发现 1 项风险
中风险

全项目 go test 会执行仓库中的代码

原文依据:2 处
发现了什么

Skill 明确建议 `go test -race ./...`,同时允许所有 `go` 子命令。该命令会编译并执行所有匹配包中的初始化逻辑、TestMain 和测试代码;依赖缺失时,Go 还可能按环境配置下载模块。

为什么需要注意

在不可信或副作用较大的仓库中,测试可能修改文件、连接服务、使用本地凭据或消耗大量资源。

这是实际检查清单中的命令,不只是测试样例;同时权限覆盖全部 `go` 子命令。若代理按建议运行 `go test -race ./...`,它会编译并执行仓库所有匹配包的测试、`TestMain` 和相关初始化代码,并可能依照 Go 环境获取依赖。因此,不可信仓库代码可能以代理进程权限运行。用户可要求先审阅测试入口,并限制网络、凭据及文件写权限。

SKILL.md:17来自说明文档打开原文件
    install: []allowed-tools: Read Edit Write Glob Grep Bash(go:*) Bash(golangci-lint:*) Bash(git:*) Agent AskUserQuestionpaths:
查看另外 1 个位置
SKILL.md:123来自说明文档打开原文件
| `wg.Add` inside goroutine | Call `Add` before `go` — `Wait` may return early otherwise || Forgetting `-race` in CI | Always run `go test -race ./...` || Mutex held across I/O | Keep critical sections short |
会不会泄露文件和密钥?检查是否发送含密码或密钥的文件,以及代码里是否直接写了密钥。发现 1 项风险
低风险

pprof 诊断可能把运行时内部信息带入代理输出

原文依据:4 处
发现了什么

Skill 提供命令从 localhost 获取 goroutine 泄漏 profile,并同时建议堆栈转储。诊断内容可能包含源码路径、函数名、运行结构及其他内部上下文;文本没有要求先检查或脱敏。

为什么需要注意

如果目标是生产进程,诊断内容可能进入终端记录、AI 会话或共享报告,扩大内部运行信息的可见范围。所示 URL 仅为 localhost,没有证据表明数据会发送到外部站点。

这段证据能说明什么

源码确实给出了从本机 pprof 端点读取 goroutine 泄漏信息的命令,并提到堆栈转储;这些诊断结果可能含函数名和源码路径。但它没有指示把结果发送到外部,也没有说明代理必须运行命令;而声明的 Bash 白名单不包含 `curl`,所以第一条命令在遵守权限的宿主中应不可用。`go tool pprof` 是否运行及结果是否进入代理上下文取决于具体任务和宿主,风险条件存在但证据不足以断言会发生。

这项判断针对展示的代码和适用条件,不表示风险已经实际发生。
SKILL.md:139来自说明文档打开原文件
```bashcurl http://localhost:6060/debug/pprof/goroutineleak?debug=2go tool pprof http://localhost:6060/debug/pprof/goroutineleak```
查看另外 3 个位置
SKILL.md:144来自说明文档打开原文件
Keep existing tools:- tests: `go.uber.org/goleak`- runtime count: `runtime.NumGoroutine()`- stack dump: `/debug/pprof/goroutine?debug=2`- race checks: `go test -race ./...`
SKILL.md:146来自说明文档打开原文件
- tests: `go.uber.org/goleak`- runtime count: `runtime.NumGoroutine()`- stack dump: `/debug/pprof/goroutine?debug=2`- race checks: `go test -race ./...`
SKILL.md:17来自说明文档打开原文件
    install: []allowed-tools: Read Edit Write Glob Grep Bash(go:*) Bash(golangci-lint:*) Bash(git:*) Agent AskUserQuestionpaths:
会不会删除文件或一直在后台运行?检查是否大范围删除文件、改写磁盘,或设置自动启动。未发现风险
会不会绕过安全保护?检查是否跳过网站安全验证、开放过多文件权限,或取消操作前的确认。发现 2 项风险
中风险

允许所有 git 子命令,权限超出并发代码分析所需范围

原文依据:3 处
发现了什么

`Bash(git:*)` 不仅允许读取差异和状态,也可能允许推送、强制重置、清理或删除分支。Skill 没有把权限限制在其审查和审计目的所需的只读命令。

为什么需要注意

如果代理误用该权限,可能更改远程仓库、丢失未提交文件或改写本地历史。现有内容没有指示这些操作一定会发生。

该权限声明实际允许代理运行任意 `git` 子命令,而本 Skill 的审查/审计用途主要需要读取状态和差异。若宿主仅按此声明授权,代理也可能执行 push、reset、clean 或删分支等会修改本地或远端仓库的操作。源码没有要求执行这些操作,也没有只读限制;用户可要求作者缩小为明确的只读 git 命令,或由宿主拦截写入型命令。

SKILL.md:17来自说明文档打开原文件
    install: []allowed-tools: Read Edit Write Glob Grep Bash(go:*) Bash(golangci-lint:*) Bash(git:*) Agent AskUserQuestionpaths:
查看另外 2 个位置
SKILL.md:28来自说明文档打开原文件
- **Write mode** — implement concurrent code (goroutines, channels, sync primitives, worker pools, pipelines). Follow the sequential instructions below.- **Review mode** — reviewing a PR's concurrent code changes. Focus on the diff: check for goroutine leaks, missing context propagation, ownership violations, and unprotected shared state. Sequential.- **Audit mode** — auditing existing concurrent code across a codebase. Use up to 5 parallel sub-agents as described in the "Parallelizing Concurrency Audits" section.
SKILL.md:29来自说明文档打开原文件
- **Write mode** — implement concurrent code (goroutines, channels, sync primitives, worker pools, pipelines). Follow the sequential instructions below.- **Review mode** — reviewing a PR's concurrent code changes. Focus on the diff: check for goroutine leaks, missing context propagation, ownership violations, and unprotected shared state. Sequential.- **Audit mode** — auditing existing concurrent code across a codebase. Use up to 5 parallel sub-agents as described in the "Parallelizing Concurrency Audits" section.
中风险

大规模审计会把代码访问范围扩展到五个子代理

原文依据:3 处
发现了什么

Skill 要求在大代码库审计中扇出五个子代理,并为此请求 Agent 权限。每个代理分别搜索不同类别的并发问题,因此更多 AI 执行上下文可能接触整个代码库。

为什么需要注意

对包含机密源码或受访问政策约束的仓库,这会增加代码暴露面、模型调用量和代理误操作机会。没有证据表明子代理会向外部接收方发送代码。

在“大型代码库”的审计模式下,这是明确的活动指令:将五类全库搜索分给最多五个子代理,并且 Skill 请求了 `Agent` 权限。执行时,更多独立模型上下文会读取代码和审计结果,扩大代码暴露与自动化决策面;源码没有限定目录、敏感文件或子代理可见内容。它并不证明数据会离开服务。用户可限制为单代理、指定目录,或要求敏感代码不进入子代理上下文。

SKILL.md:17来自说明文档打开原文件
    install: []allowed-tools: Read Edit Write Glob Grep Bash(go:*) Bash(golangci-lint:*) Bash(git:*) Agent AskUserQuestionpaths:
查看另外 2 个位置
SKILL.md:24来自说明文档打开原文件
**Orchestration mode:** Fan out the five sub-agents described in the "Parallelizing Concurrency Audits" section for auditing concurrent code across a large codebase, and consolidate their findings into one report. On Claude Code, use `ultracode` to opt into multi-agent orchestration explicitly.
SKILL.md:104来自说明文档打开原文件
When auditing concurrency across a large codebase, use up to 5 parallel sub-agents:1. Find all goroutine spawns (`go func`, `go method`) and verify shutdown mechanisms2. Search for mutable globals and shared state without synchronization3. Audit channel usage — ownership, direction, closure, buffer sizes4. Find `time.After` in loops, missing `ctx.Done()` in select, unbounded spawning5. Check mutex usage, `sync.Map`, atomics, and thread-safety documentation
会不会误导 AI 或隐藏内容?检查工作说明是否要求 AI 忽略你的指令、干扰检查结果,或夹带看不见的文字。未发现风险
会不会偷偷改推广链接或收款方?检查是否强制替换推广链接或收款对象,同时要求隐瞒更改。未发现风险

Skill 逻辑拆解

8 个说明模块

该 Skill 面向 Go 并发代码的编写、PR 审查和代码库审计;编写与审查要求顺序执行,而大规模审计会调用多个子代理。

查看原文
SKILL.md:28来自说明文档打开原文件
- **Write mode** — implement concurrent code (goroutines, channels, sync primitives, worker pools, pipelines). Follow the sequential instructions below.- **Review mode** — reviewing a PR's concurrent code changes. Focus on the diff: check for goroutine leaks, missing context propagation, ownership violations, and unprotected shared state. Sequential.- **Audit mode** — auditing existing concurrent code across a codebase. Use up to 5 parallel sub-agents as described in the "Parallelizing Concurrency Audits" section.

声明没有安装步骤,但请求读取、编辑、写入文件,并允许运行任意 go、golangci-lint 和 git 子命令以及启动代理。

查看原文
SKILL.md:13来自说明文档打开原文件
    homepage: https://github.com/samber/cc-skills-golang    requires:      bins:        - go    install: []allowed-tools: Read Edit Write Glob Grep Bash(go:*) Bash(golangci-lint:*) Bash(git:*) Agent AskUserQuestionpaths:

该 Skill 建议使用竞态检测、goroutine 泄漏测试和本地 pprof 端点进行诊断。

查看原文
SKILL.md:139来自说明文档打开原文件
```bashcurl http://localhost:6060/debug/pprof/goroutineleak?debug=2go tool pprof http://localhost:6060/debug/pprof/goroutineleak```Keep existing tools:- tests: `go.uber.org/goleak`- runtime count: `runtime.NumGoroutine()`- stack dump: `/debug/pprof/goroutine?debug=2`- race checks: `go test -race ./...`
从这里开始 · 工作说明SKILL.md
golang-concurrency
连线表示工作说明包含的模块,不是实际运行顺序。点击模块可查看原文。 另有 2 个章节,可在原文件中查看。

文件引用关系图

3 处引用
哪些文件发起引用引用了什么
连线表示真实的文件引用,不是运行顺序。点击节点可高亮相关连线,并查看具体文件和原文位置。虚线表示还有文件需要定位。
文件与检查记录5 个文件

检查范围与遗漏

逐文件查看涉及的内容

下方列出本次涉及的原文范围;纳入检查不代表已查清所有问题。

  • SKILL.md已纳入全文
  • references/channels-and-select.md已纳入全文
  • references/pipelines.md已纳入全文
  • references/sync-primitives.md已纳入全文
  • evals/evals.json已纳入全文

这份报告只针对上方版本。我们看了拿到的代码和说明文件,没有实际运行 Skill,也没有检查它另外安装的软件包。因此,这不是“保证安全”的承诺;换了版本或使用环境,结果也可能不同。

  • SKILL.md工作说明
  • evals/evals.json配套文件
  • references/channels-and-select.md配套文件
  • references/pipelines.md配套文件
  • references/sync-primitives.md配套文件

代码和说明中提到的操作

连接外部网站
SKILL.md:12来自说明文档打开原文件
    emoji: "⚡"    homepage: https://github.com/samber/cc-skills-golang    requires:
SKILL.md:140来自说明文档打开原文件
```bashcurl http://localhost:6060/debug/pprof/goroutineleak?debug=2go tool pprof http://localhost:6060/debug/pprof/goroutineleak
SKILL.md:141来自说明文档打开原文件
curl http://localhost:6060/debug/pprof/goroutineleak?debug=2go tool pprof http://localhost:6060/debug/pprof/goroutineleak```
运行命令
SKILL.md:17来自说明文档打开原文件
    install: []allowed-tools: Read Edit Write Glob Grep Bash(go:*) Bash(golangci-lint:*) Bash(git:*) Agent AskUserQuestionpaths:
SKILL.md:139来自说明文档打开原文件
```bashcurl http://localhost:6060/debug/pprof/goroutineleak?debug=2
修改文件
references/sync-primitives.md:155来自说明文档打开原文件
    buf.Write(data)    // ... transform ...
读取文件
references/sync-primitives.md:181来自说明文档打开原文件
        var err error        c.conn, err = sql.Open("postgres", dsn)        if err != nil {
读取了多少行
1,304
文件校验值(用于核对版本)
c5f267aa1262ae5c22d58f5e1a39daadddb2ffbe30fb0ef6f9375e1a15dd2d6f