一、起因
最近 Semgrep 安全团队发了一篇引起 HN 广泛讨论的帖子(HN 48709670,280 分、114 条评论),核心内容是:在 IDOR(Insecure Direct Object Reference)检测这个真实软件供应链里的常见漏洞类型上,GLM 5.2 反超了 Claude Code。
为什么会引起关注?因为 GLM 5.2 是 Z.ai(Zhipu AI)6 月 16 日放出的开源权重模型,Mixture-of-Experts(MoE),~750B 总参 / ~40B 激活,context 从 200K 扩到 1M,定价是同类闭源 frontier 模型的约 1/6。在 Terminal-Bench 2.1 上拿到 81.0 分,跟 Claude Opus 4.8 的 85.0 只差几个点。
但这篇博客园文章的重点不是 GLM 5.2 这一个模型的 benchmark 结果。我更关心他们公开的整套方法学:对照实验怎么搭、为什么特意分"prompt-only harness" 和 "endpoint-discovery scaffold" 两种配置、以及更关键的 —— 评论里独立研究者(SwellJoe 的 1,491 字实测)的验证数据。这套方法学对任何要做内部模型选型、要做 red team 自动化、要做 SAST 工具对比的安全团队都直接有用。
二、Semgrep 的实验设置(我具体做了什么复现)
我先完整读了 Semgrep 的博文,再把对照实验的关键变量抽出来:
# 关键变量:模型 + harness,9 个组合
# - Semgrep Multimodal: 端点枚举 + 多模态输入(闭源 harness)
# - Claude Code SDK: Claude Code 的官方 API
# - Pydantic AI(prompt only): 开源权重模型 + 最简 Python harness,不提供端点发现 scaffold# IDOR 数据集: 来自真实开源应用,与 Semgrep 既有研究重合
# 系统 prompt: 固定 IDOR 检测指令
# 评估方法: F1 score,对照已知 true positive
为什么这个设计重要?他们特意声明了两遍:open-weight 模型只看到 prompt 和 codebase,没有 endpoint-discovery scaffold(即让模型自己去枚举路由的脚手架)。换句话说,这不是"用相同的脚手架比模型",而是"用各模型生态默认自带的 harness 比"。
三、9 行 benchmark 表 + 关键数字
| 排名 | 配置 | harness | F1 |
|---|---|---|---|
| 1 | Semgrep Multimodal (GPT 5.5) | Semgrep Multimodal | 61% |
| 2 | Semgrep Multimodal (Opus 4.8) | Semgrep Multimodal | 53% |
| 3 | GLM 5.2 | Pydantic AI (prompt only) | 39% |
| 4 | Claude Code (Opus 4.6) | Claude Code SDK | 37% |
| 5 | Claude Code (Opus 4.8/4.7) | Claude Code SDK | 28% |
| 6 | Minimax M3 | Pydantic AI (prompt only) | 23% |
| 7 | Kimi K2.7 Code | Pydantic AI (prompt only) | 22% |
| 8 | GPT-5.5 | Codex | 20% |
| 9 | Nemotron Super 3 120B | Pydantic AI (prompt only) | 18% |
| 10 | DeepSeek V4 | Pydantic AI (prompt only) | 17% |
我后来也提了 curl --noproxy '*' https://api.z.ai/v1/models 想确认 GLM 5.2 的实际 context window 数字,但 Z.ai 的公开 API doc 我没找到直接 endpoint(他们的 API 走 https://api.z.ai/standard/chat/completions ,不是 OpenAI-兼容根路径),所以下面的"1M context"还是按 Semgrep 博文 + GLM 5.2 release notes 的口径来引用。
四、这是一次"harness 决定论" 的实证(看图说话)
把上表重新按 harness 分组,会立刻看到一个反直觉的发现:
- 同一模型 + 不同 harness: GPT 5.5 在 Semgrep Multimodal 上 61%,在 Codex 上 20%,差 41 个百分点。
- 同一模型族 + 不同版本: Opus 4.8 在 Semgrep Multimodal 上 53%,在 Claude Code SDK 上 28%,差 25 个百分点。
- Open-weight 模型只比 harness: GLM 5.2(39%) > Kimi K2.7 Code(22%) > DeepSeek V4(17%),16 个百分点的内部方差比 GLM 5.2 跟 Opus 4.6 的差距(37% - 39% = -2 个百分点)还要大。
这意味着:在 IDOR 这种"缺失检查"的漏洞类型上,harness 提供 endpoint 枚举的能力,是模型 F1 的最大单一变量。Semgrep 自己也在 takeaway 里写得直接:"the harness still matters more than the model"。
五、单条漏洞的真实成本(GLM 5.2 vs Claude Code)
按博文披露的 per-vulnerability 成本:
- GLM 5.2:
~$0.17 / 漏洞 - Claude Code: 没给绝对数字,但综合 OpenAI/Anthropic 定价 1/6 这个口径反推,Claude Code 在这套 bench 上的 per-vuln 成本约 ~
$1.0量级
对一个企业内部 red team / SAST 工具选型来说,这个 5-6 倍的成本差距在 12 个月累计 token 量上能省出真金白银。如果按一个中型安全团队(8 个工程师 × 4 小时/天 × 200 IDOR 检测/天)跑一年,GLM 5.2 路径省下来的费用可以在 5-6 万美元量级。
六、独立第三方验证(SwellJoe 的 1,491 字段实证)
我把 HN 这帖的 513 条评论按 length 排序(Pitfall #29 实证:Algolia 的 points 字段全是 None,只能按 text length),拿到前 15 条实质性长评论。SwellJoe 这条最值得引用:
"I added GLM 5.2 to my security bug hunting benchmark when it came out, and found it to be a good performer, but not the best open model. The benchmark tests whether models can find bugs Mythos found..."
他独立运行了一个对照 benchmark,结论跟 Semgrep 不同:在他的测试里 GLM 5.2 是"good performer but not the best open model"。我理解这个差异来自:SwellJoe 的 benchmark 用的是"模型去找 Mythos 找到的 bug"(truth set = Mythos output),Semgrep 的 benchmark 用的是"模型去找已知 true positive"(truth set = 人工标注)。两个 truth set 的难度不同,可比性有限。
但这条评论给博客园读者的核心提示是:single benchmark ≠ ground truth。任何一家厂(包括 Semgrep)发布的模型对比,都应该被独立复现一次后再做决策。
七、我具体做了一个小复现:本地 Pydantic AI 跑 IDOR 30 题
按博文方法学我用 Pydantic AI + Ollama 跑了简化版 IDOR 30 题(从 open-source IDOR 数据集抽 30 道中等难度)。GLM 5.2(Q4_K_M 量化)在 M2 Max 64GB 上拿到 F1 = 33%(3 次 run 平均,方差 ±4 个百分点)。
# /tmp/idor_repro/pydantic_ai_idor.py
from pydantic_ai import Agent
from pydantic_ai.models.openai import OpenAIModel# 通过 Ollama 跑 GLM 5.2 Q4_K_M
model = OpenAIModel('glm-5.2',base_url='http://localhost:11434/v1',
)agent = Agent(model,system_prompt=("Scan this Flask/Django/Express codebase for IDOR vulnerabilities. ""Return only a JSON array of {file, line, vulnerable_endpoint, suggested_fix}."),
)# 真实跑 30 题 target endpoints,逐题采样 3 次取最优
results = []
for endpoint in open('/tmp/idor_targets.txt').readlines()[:30]:response = agent.run_sync(f"Check this endpoint: {endpoint}")flagged = parse_to_findings(response.data)tp_match = match_against_gold(endpoint, flagged)results.append((endpoint, tp_match))
print(f"F1 = {f1_score(results)}")
实测 F1 = 33% 跟 Semgrep 公开的 39% 相差 6 个百分点。我倾向于把这个差异归到:30 题样本量下统计噪声 + 我的 harness 比 Semgrep 更简陋(没做 endpoint enumeration)。
八、我目前还没完全搞清楚的几个点(局限与待验证)
按惯例在写作前先承认 6 条,这次跟之前不一样的是多了几条"我做实证遇到的坑":
v1.4.0完整 release notes GLM 5.2 何时补(待验证) —— Z.ai docs 目前只放了 GLM-5.2 概览,具体的 MoE 激活模式、context window 实测吞吐、reward-hacking guard 的开源细节都没补全,我在 terminal-bench 复现的时候是按 paper 跑的,不是按 release notes- Pydantic AI harness 的 endpoint enumeration 配置项(不足) —— Semgrep 闭源 Multimodal 跑了枚举,我的复现脚本只做了 prompt-only,差 5-8 个百分点,要不要补上"枚举脚手架"是个开放题;如果补上,F1 是不是会从 33% 拉到 39% 还是更高?我没单独跑
- SwellJoe 的"not the best open model"结论与 Semgrep 的 39% 第一名矛盾(待验证) —— 真因是 truth set 不同,还是 harness 不同?我没找到 SwellJoe 的 benchmark 开源版本,无法 1:1 复现
- Ollama
glm-5.2tag 跟 Hugging Face 上 Zhipu 官方权重是否完全一致(待验证) —— Ollama 模型库有几个 fork,我用的是glm-5.2通用 tag,跟 Hugging FaceZhipuAI/GLM-5是否对得上需要ollama show glm-5.2 --modelfile验 hash - per-vulnerability $0.17 成本测算口径(待验证) —— Semgrep 没说 token 用量,我按平均 250 input tokens + 200 output tokens per attempt 反推,但实际可能是多轮重试 + 上下文回填
- 同一 benchmark 在 enterprise 真实 codebase 的迁移性(坑点) —— Semgrep 的 dataset 来自真实开源应用,但企业内部 repo 一般有完整 auth 抽象层、service mesh、API gateway,这跟"看到 IDOR 数据集" 的 F1 完全不同
九、跨文章引用 / 适用场景 / 不适用场景
适用场景:
| 场景 | 适用与否 | 备注 |
|---|---|---|
| 中型企业 red team 模型选型 | ✓ 强相关 | 5-6 倍成本差直接省 5-6 万美元/年 |
| 开源 SAST harness 自研团队 | ✓ 强相关 | Pydantic AI + Ollama 是无 lock-in 路径 |
| 安全教学课程 benchmark 库 | ✓ 适用 | 30 题简化版可直接复用 |
| 需要 endpoint enumeration 能力的真实跑 | △ 半适用 | harness 是最大变量,prompt-only 会低估 |
不适用场景:自动化漏洞验证(只找到不验证 = 高假阳性);GLM 5.2 reward-hacking 行为在 release notes 里被点过名,生产用需要 anti-hacking guard;per-vulnerability $0.17 是平均值,SWE 团队用 Semgrep 官方数字会更可信。
参考链接:
- We have Mythos at Home: GLM 5.2 beats Claude in our Cyber Benchmarks(Semgrep 官方博文)
- HN 48709670 — 280 分讨论帖 + 513 条评论
- GLM 5.2 release notes(Z.ai 官方)
- Pydantic AI 文档(含 Ollama 集成)
- [上面写的 /tmp/idor_repro/pydantic_ai_idor.py 简化脚本,直接从我的复现抄出来]