跳转到正文
报告库
用途分类 / 数据分析

Golang Data Structures Skill 安全审计

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

Golang data structures — slices (internals, capacity growth, preallocation, slices package), maps (internals, hash buckets, maps package), arrays, container/list/heap/ring, strings.Builder vs bytes.Buffer, generic collections, pointers (unsafe.Pointer, weak.Pointer), and copy semantics. Use when choosing or optimizing Go data structures, implementing generic containers, using container/ packages,

第三方安全检查结论

发现安全风险

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

Skill 可引导代理生成绕过 Go 类型系统的 unsafe 内存访问

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

参考材料明确介绍 `unsafe.Pointer`,并给出指针重解释、地址运算和系统调用参数示例。这类代码绕过类型系统;示例本身不能保证代理应用它时的输入长度、对齐、对象生命周期和目标平台布局均正确。

为什么需要注意

如果代理把这些模式用于不满足前提的数据或内存布局,生成的程序可能崩溃、读取错误数据或破坏内存;处理外部输入时,这可能扩大为拒绝服务或数据完整性风险。

这段代码的正常用途

材料确实包含 unsafe.Pointer 示例,但这是该数据结构 Skill 明示涵盖的低级内存主题,并非要求代理无条件执行代码。上下文反复限定只能采用 Go 规范允许的模式,指出其他方式属于未定义行为,并推荐避免 uintptr 运算的现代 API。所引示例也标注必须在单个表达式中完成。现有行没有显示错误的长度、对齐或生命周期处理,也不足以证明会生成不安全实现;用户仍可要求在项目中禁用 unsafe,除非有明确的 FFI 或布局需求及边界检查。

这项判断针对展示的代码和适用条件,不表示风险已经实际发生。
references/pointers.md:45来自说明文档打开原文件
## `unsafe.Pointer``unsafe.Pointer` bypasses Go's type system for FFI and low-level memory manipulation. Only the 6 patterns from the Go spec are safe; any other pattern is undefined behavior.### The 6 Valid Patterns (from the Go spec)These are the ONLY safe ways to use `unsafe.Pointer`. Any other pattern is undefined behavior.
查看另外 5 个位置
references/pointers.md:53来自说明文档打开原文件
**Pattern 1: Convert `*T` to `*U` via `unsafe.Pointer`**```go// Reinterpret a float64 as its raw bitsf := 1.5bits := *(*uint64)(unsafe.Pointer(&f))```
references/pointers.md:61来自说明文档打开原文件
**Pattern 2: Convert `unsafe.Pointer` to `uintptr` and back (same expression)**```go// Pointer arithmetic — MUST be a single expressionp := unsafe.Pointer(uintptr(unsafe.Pointer(&s.field)) + offset)```
references/pointers.md:74来自说明文档打开原文件
**Pattern 4: `syscall.Syscall` arguments**```gosyscall.Syscall(SYS_READ, fd, uintptr(unsafe.Pointer(&buf[0])), uintptr(len(buf)))```
references/pointers.md:49来自说明文档打开原文件
### The 6 Valid Patterns (from the Go spec)These are the ONLY safe ways to use `unsafe.Pointer`. Any other pattern is undefined behavior.
references/pointers.md:92来自说明文档打开原文件
### Modern Alternatives (prefer these)| Function | Since | Purpose || --- | --- | --- || `unsafe.Add(ptr, len)` | Go 1.17 | Pointer arithmetic without `uintptr` conversion || `unsafe.Slice(ptr, len)` | Go 1.17 | Create slice from pointer + length || `unsafe.String(ptr, len)` | Go 1.20 | Create string from pointer + length || `unsafe.SliceData(s)` | Go 1.17 | Get pointer to slice's backing array || `unsafe.StringData(s)` | Go 1.20 | Get pointer to string's backing array |These are safer than manual `uintptr` arithmetic because they keep values as pointers (visible to GC) throughout.
会不会泄露文件和密钥?检查是否发送含密码或密钥的文件,以及代码里是否直接写了密钥。未发现风险
会不会删除文件或一直在后台运行?检查是否大范围删除文件、改写磁盘,或设置自动启动。未发现风险
会不会绕过安全保护?检查是否跳过网站安全验证、开放过多文件权限,或取消操作前的确认。发现 1 项风险
中风险

不受限的 git 和子代理权限超出数据结构指导所需范围

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

清单允许 `Bash(git:*)`,没有限制为只读子命令,同时还允许 `Agent`、文件写入和编辑。Skill 正文主要提供 Go 数据结构建议,没有说明为何需要推送、重写历史、删除分支等完整 git 能力。

为什么需要注意

若宿主严格按此清单授权,而代理被错误提示或误判任务,它可能修改仓库历史、切换或删除分支、向已配置的远程仓库发送内容;子代理也会扩大接触项目内容的执行面。权限声明本身不证明这些行为已发生。

该清单确实授予 Edit、Write、Agent 和不区分子命令的 Bash(git:*),而正文所述用途是选择和理解 Go 数据结构。它不会自行执行 Git 操作,但在 Skill 被调用且代理遵循 allowed-tools 时,可能允许修改用户文件、启动子代理,或执行 push、reset 等高影响 Git 命令;正文未说明这些权限为何必要。用户可要求作者将 Git 限为只读子命令、移除 Agent,并仅在明确授权后开放写入。

SKILL.md:17来自说明文档打开原文件
    install: []allowed-tools: Read Edit Write Glob Grep Bash(go:*) Bash(golangci-lint:*) Bash(git:*) Agent Bash(godig:*) Bash(gopls:*) LSP mcp__gopls__* mcp__context7__resolve-library-id mcp__context7__query-docspaths:  - "**/*.go"---
查看另外 2 个位置
SKILL.md:22来自说明文档打开原文件
**Persona:** You are a Go engineer who understands data structure internals. You choose the right structure for the job — not the most familiar one — by reasoning about memory layout, allocation cost, and access patterns.
SKILL.md:24来自说明文档打开原文件
# Go Data StructuresBuilt-in and standard library data structures: internals, correct usage, and selection guidance.
会不会误导 AI 或隐藏内容?检查工作说明是否要求 AI 忽略你的指令、干扰检查结果,或夹带看不见的文字。未发现风险
会不会偷偷改推广链接或收款方?检查是否强制替换推广链接或收款对象,同时要求隐瞒更改。未发现风险

Skill 逻辑拆解

8 个说明模块

该 Skill 是面向 Go 数据结构选择与实现的指导材料,主体包含切片、映射、容器、泛型和指针示例;清单声明不执行安装步骤。

查看原文
SKILL.md:2来自说明文档打开原文件
---name: golang-data-structuresdescription: "Golang data structures — slices (internals, capacity growth, preallocation, slices package), maps (internals, hash buckets, maps package), arrays, container/list/heap/ring, strings.Builder vs bytes.Buffer, generic collections, pointers (unsafe.Pointer, weak.Pointer), and copy semantics. Use when choosing or optimizing Go data structures, implementing generic containers, using container/ packages, unsafe or weak pointers, or questioning slice/map internals. Not for applying optimization patterns once profiling has identified a bottleneck (→ See `samber/cc-skills-golang@golang-performance` skill)."user-invocable: true
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 Bash(godig:*) Bash(gopls:*) LSP mcp__gopls__* mcp__context7__resolve-library-id mcp__context7__query-docs

它请求读取、编辑和写入文件,以及运行 Go、git、分析工具、语言服务器和子代理;这些是能力声明,不代表任何命令已经执行。

查看原文
SKILL.md:17来自说明文档打开原文件
    install: []allowed-tools: Read Edit Write Glob Grep Bash(go:*) Bash(golangci-lint:*) Bash(git:*) Agent Bash(godig:*) Bash(gopls:*) LSP mcp__gopls__* mcp__context7__resolve-library-id mcp__context7__query-docspaths:  - "**/*.go"---

该 Skill 建议优先使用 Go 包信息工具,并把 Context7 作为未收录文档的外部查询后备;是否向该服务发送内容取决于代理实际发出的查询。

查看原文
SKILL.md:165来自说明文档打开原文件
When using third-party libraries, refer to their official documentation and code examples for current API signatures.- For Go package docs, symbols, versions, importers, and known vulnerabilities, → See `samber/cc-skills-golang@golang-pkg-go-dev` skill (`godig`) — prefer it over Context7 for Go package facts.- To navigate this library's usage in your own code (definitions, call sites, diagnostics), → See `samber/cc-skills-golang@golang-gopls` skill (`gopls`).- Context7 remains a fallback for docs not indexed on pkg.go.dev.

`evals/evals.json` 中的任务和断言是评测用例,不是 Skill 主体的实时操作指令;例如其中要求生成使用 unsafe 指针运算的代码。

查看原文
evals/evals.json:37来自说明文档打开原文件
    "id": 4,    "name": "unsafe.Add-modern",    "description": "Read packed binary header using modern unsafe.Add (Go 1.17+)",    "task": "Write a function `ReadFields(data []byte) (magic uint32, version uint16, length uint32)` in package `proto` that reads a packed binary header. The header layout is: 4 bytes magic, 2 bytes version, 2 bytes padding, 4 bytes length. Use unsafe pointer arithmetic to access each field at its offset. Target Go 1.17+.",    "assertions": [      { "id": "4.1", "text": "Uses `unsafe.Add` for pointer arithmetic", "trap": "Without skill, model uses old-style uintptr(base) + offset casting" },      { "id": "4.2", "text": "No intermediate `uintptr` variable", "trap": "Model might split pointer arithmetic across statements" },      { "id": "4.3", "text": "Bounds check before unsafe access", "trap": "none — baseline safety" }    ]
从这里开始 · 工作说明SKILL.md
golang-data-structures
连线表示工作说明包含的模块,不是实际运行顺序。点击模块可查看原文。 另有 5 个章节,可在原文件中查看。

文件引用关系图

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

检查范围与遗漏

逐文件查看涉及的内容

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

  • SKILL.md已纳入全文
  • references/containers.md已纳入全文
  • references/generics.md已纳入全文
  • references/map-internals.md已纳入全文
  • references/pointers.md已纳入全文
  • references/slice-internals.md已纳入全文
  • evals/evals.json已纳入全文

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

  • SKILL.md工作说明
  • evals/evals.json配套文件
  • references/containers.md配套文件
  • references/generics.md配套文件
  • references/map-internals.md配套文件
  • references/pointers.md配套文件
  • references/slice-internals.md配套文件

代码和说明中提到的操作

连接外部网站
SKILL.md:12来自说明文档打开原文件
    emoji: "🗃"    homepage: https://github.com/samber/cc-skills-golang    requires:
SKILL.md:192来自说明文档打开原文件
- [Go Data Structures (Russ Cox)](https://research.swtch.com/godata)- [The Go Memory Model](https://go.dev/ref/mem)
SKILL.md:193来自说明文档打开原文件
- [Go Data Structures (Russ Cox)](https://research.swtch.com/godata)- [The Go Memory Model](https://go.dev/ref/mem)- [Effective Go](https://go.dev/doc/effective_go)
运行命令
SKILL.md:17来自说明文档打开原文件
    install: []allowed-tools: Read Edit Write Glob Grep Bash(go:*) Bash(golangci-lint:*) Bash(git:*) Agent Bash(godig:*) Bash(gopls:*) LSP mcp__gopls__* mcp__context7__resolve-library-id mcp__context7__query-docspaths:
读取了多少行
842
文件校验值(用于核对版本)
3bf08095cf582239195105fc68b75c02cd9851b0f298633fcd56947e46f8ceb7