Object::clone, Repository::config and Repository::index can wrap libgit2 reference counts
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
Start by tracing Object::clone, Repository::config and Repository::index in git2-rs to the bundled libgit2 reference count increments described in the report. The issue asks for checks on those increments; the payload does not name the bundled source files or tests. Done means the three reproductions no longer allow reference counts to wrap and the reported use-after-free paths are addressed.
由索引模型根据 Issue 内容生成。
描述
libgit2 1.9.7, which libgit2-sys bundles, keeps reference counts in a 32-bit atomic int and does not check them before incrementing.
Object::clone calls git_object_dup. With one handle, one surviving clone and the reference held by libgit2's object cache, forgetting 2^32 - 2 further clones (std::mem::forget is safe) and dropping the original frees the object. The surviving handle's next call, Object::kind, reads freed memory.
Repository::config() and Repository::index() return the repository's cached config or index with its count incremented. GIT_REFCOUNT_DEC frees when the decremented count is <= 0 and the owner pointer is null, so 2^31 - 1 forgotten handles are enough. Dropping the Repository then frees the config or index while a Config or Index handle remains.
We ran all three paths with git2 0.21.0 (bundled libgit2 1.9.7) and a program with no unsafe code. AddressSanitizer reports a heap use-after-free in Object::kind, Config::get_string and Index::len. We reported this to libgit2 privately and have had no reply. Could you patch the bundled libgit2 to check these increments?
- 主要语言
- Rust
- 星标
- 2.1k
- 派生
- 470
- 平均合并
- 2 天 17 小时
- 30 天内合并 PR
- 18
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
rust-lang/git2-rs 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 85/100
维护者通常 1 天内回复
-
`stash_foreach` crashes on stash entries with no message or a non-UTF-8 message可能已有人在做 @shivampwm2020 于 43 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
难度 3/5 1-2 天 新手友好度 68/100
维护者通常 1 天内回复
-
难度 3/5 1-2 天 新手友好度 64/100
维护者通常 1 天内回复
查看 rust-lang/git2-rs 的全部 Issue
相似的 Issue
-
bug P2
难度 2/5 1-3 小时 新手友好度 85/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 85/100
维护者通常 1 天内回复
-
Windows microphone listing treats words in a device name as DirectShow labels可能已有人在做 @Sujal-chaudhary 今天认领。 未关闭bug
难度 2/5 1-3 小时 新手友好度 88/100
clipy-recorder/clipy#447 · 2 条评论 ·
维护者通常 1 天内回复
-
nightly-cleanup
难度 2/5 1-3 小时 新手友好度 78/100
max-sixty/worktrunk#4939 · 1 个 reaction ·
维护者通常 1 天内回复
-
flaky
难度 2/5 1-3 小时 新手友好度 68/100
stacks-network/stacks-core#7918 · 1 条评论 ·
维护者通常 2 天内回复