Service crashes on Windows Server 2016: "panic: sub-authority index out of range" in RidToString
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 82/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- go
调研方向
从 pkg/sys/rid.go 中的 RidToString 开始:为 SubAuthorityCount 为零/无效 SID 添加防护并返回 UNKNOWN,同时为零 subauthority 的 SID 添加单元测试。沿调用栈进入 pkg/ps/snapshotter_windows.go(newProcState)和 pkg/event/param_windows.go,查看 ProcessTokenIntegrityLevel 如何被解码;只有在修复根因时才调查 14393 上的 Kernel-Process 事件版本。完成意味着在 Server 2016 上不发生 panic 且完整性级别为 UNKNOWN。
由索引模型根据 Issue 内容生成。
描述
Describe the bug
On Windows Server 2016 (build 14393), the Fibratus 3.1.1 service crashes a few seconds after start, as soon as the first process events are processed. The service control manager restarts it and it crashes again each time. The same version runs normally on Windows 10 22H2.
level=info msg=starting [Security Telemetry Logger] trace processing source=etw/source.go:271
level=info msg=starting [NT Kernel Logger] trace processing source=etw/source.go:271
panic: sub-authority index out of range
goroutine 29 [running]:
golang.org/x/sys/windows.(*SID).SubAuthority(..., 0xff)
golang.org/x/[email protected]/windows/security_windows.go:272
github.com/rabbitstack/fibratus/pkg/sys.RidToString(...)
pkg/sys/rid.go:63
github.com/rabbitstack/fibratus/pkg/event.Param.String(...)
pkg/event/param_windows.go:80
github.com/rabbitstack/fibratus/pkg/event.(*Event).GetParamAsString(...)
pkg/event/event.go:349
github.com/rabbitstack/fibratus/pkg/ps.(*snapshotter).newProcState(...)
pkg/ps/snapshotter_windows.go:385
github.com/rabbitstack/fibratus/pkg/ps.(*snapshotter).Write(...)
pkg/ps/snapshotter_windows.go:161
github.com/rabbitstack/fibratus/internal/etw/processors.psProcessor.ProcessEvent(...)
internal/etw/processors/ps_windows.go:51
github.com/rabbitstack/fibratus/internal/etw/processors.(*Chain).ProcessEvent(...)
internal/etw/processors/chain.go:46
github.com/rabbitstack/fibratus/internal/etw.(*Consumer).ProcessEvent(...)
internal/etw/consumer.go:110
github.com/rabbitstack/fibratus/internal/etw.(*Trace).processEventCallback(...)
internal/etw/trace.go:414
newProcState reads ProcessTokenIntegrityLevel from the Microsoft-Windows-Kernel-Process process events (CreateProcessInternal / ProcessRundownInternal). On build 14393 the SID in that parameter has a SubAuthorityCount() of 0, so in RidToString
switch sid.SubAuthority(uint32(sid.SubAuthorityCount() - 1)) {
SubAuthorityCount() - 1 wraps around to 255 (0xff in the trace) and SubAuthority panics. A likely cause is that the event payload layout on this build differs from the one the parser expects, so the SID is read from the wrong offset.
How to reproduce it
- Install Fibratus 3.1.1 (MSI) on Windows Server 2016 Standard, build 14393.
- Start the
fibratusservice, or runfibratus run. - The service terminates within seconds with the panic above (System event log: Service Control Manager 7031, "The Fibratus service terminated unexpectedly").
Reproduced on two separate Server 2016 VMs.
Expected behavior
Fibratus keeps running. If the integrity-level SID can't be decoded, the integrity level should be reported as UNKNOWN (as RidToString already does for a nil SID) instead of crashing the service. A minimal guard:
func RidToString(sid *windows.SID) string {
if sid == nil || !sid.IsValid() || sid.SubAuthorityCount() == 0 {
return "UNKNOWN"
}
switch sid.SubAuthority(uint32(sid.SubAuthorityCount() - 1)) {
It may also be worth checking the Kernel-Process event version on 14393 so the SID is decoded correctly there.
Screenshots
N/A
Environment
- Fibratus version: 3.1.1 (MSI). The same code path is present in 3.0.0, 3.1.0 and on master (
pkg/sys/rid.go). 2.4.0 does not read the integrity level and is not affected. The code was introduced with "feat(process): Enrich processes with integrity level and token elevation info". - Configuration: the 3.1.1 default configuration, with the
eventsourcesection unchanged. Only the rule paths and the output (HTTP instead of console) differ. The crash happens in the process snapshotter, before any rule is evaluated. - OS: Windows Server 2016 Standard, version 10.0.14393, x64 (VMware VMs). Not affected: Windows 10 22H2 (Pro and Education).
Additional context
Happy to test a build with a fix on Server 2016.
- 主要语言
- Go
- 星标
- 2.6k
- 派生
- 222
- 平均合并
- 16 小时 23 分钟
- 30 天内合并 PR
- 11
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
rabbitstack/fibratus 的其他 Issue
-
CI: the test job has been red since September, and TestFsProcessor looks like a real mmap regression未关闭ci
难度 4/5 3-5 天 新手友好度 22/100
rabbitstack/fibratus#754 · 1 条评论 · 1 个 reaction ·
维护者通常 1 天内回复
-
ci rules type: enhancement
难度 5/5 一周以上 新手友好度 15/100
rabbitstack/fibratus#715 ·
维护者通常 1 天内回复
-
scope: hardering type: enhancement
难度 5/5 一周以上 新手友好度 15/100
rabbitstack/fibratus#713 ·
维护者通常 1 天内回复
-
needs: config scope: events/telemetry type: feature
难度 4/5 3-5 天 新手友好度 35/100
rabbitstack/fibratus#710 ·
维护者通常 1 天内回复
-
needs: config scope: events/telemetry type: feature
难度 4/5 3-5 天 新手友好度 30/100
rabbitstack/fibratus#708 ·
维护者通常 1 天内回复
查看 rabbitstack/fibratus 的全部 Issue
相似的 Issue
-
难度 2/5 半天 新手友好度 72/100
hiero-ledger/hiero-sdk-go#1911 ·
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 4 天内回复
-
[Bugs] AMF `ParseGMM()` panic — `RejectedNSSAI.UnmarshalBinary` reads out of bounds可能已有人在做 @PerryLink 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 70/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 62/100
ccfos/nightingale#3514 ·
维护者通常 1 天内回复
-
[bug] Explorer trims leading spaces on file names可能已有人在做 @unshade 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 70/100
mickael-kerjean/filestash#1033 · 1 条评论 ·