Potential soundness issue in `bitpacking` 0.9.3
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 72/100
Hướng nghiên cứu
Start with the safe wrappers in src/bitpacker1x.rs:161 and the unsafe implementation in src/macros_simple.rs:424-438. Run the provided short-slice reproducer under Miri, then inspect the corresponding sorted variants. Done means the public sorted APIs reject invalid block lengths or otherwise avoid undefined behavior, with the reproducer no longer reporting the dangling-pointer access.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Hello, and thank you for maintaining this crate.
I found a sanitizer/Miri failure reachable through public crate APIs using safe Rust code. I may be missing crate-specific preconditions, but the behavior looks worth checking because safe callers should not be able to trigger undefined behavior.
Summary
- Crate:
bitpacking - Version tested:
0.9.3 - API paths with similar failures observed:
BitPacker1x::num_bits_sortedBitPacker1x::num_bits_strictly_sortedBitPacker4x::num_bits_sortedBitPacker4x::num_bits_strictly_sorted
Observed diagnostics
Miri undefined behavior: error: Undefined Behavior: memory access failed: attempting to access 4 bytes, but got 0x4[noalloc] which is a dangling pointer (it has no provenance)
Reproduction
The snippets below are minimal readable reproducers. Each PoC also includes the source location most relevant to the reported failure.
PoC 1: test_bitpacking3::generated_test_3
Relevant source location:
src/bitpacker1x.rs:161: the safe wrapper callsUnsafeBitPackerImpl::num_bits_sorted.src/macros_simple.rs:424-438: the unsafe implementation loads a full fixed block fromdecompressed.
Readable equivalent PoC:
use bitpacking::{BitPacker, BitPacker1x};
#[test]
fn poc() {
let packer = BitPacker1x::new();
let short_block: Vec<u32> = Vec::new();
let _ = packer.num_bits_sorted(0, &short_block);
}
Observed diagnostic:
error: Undefined Behavior: memory access failed: attempting to access 4 bytes, but got 0x4[noalloc] which is a dangling pointer (it has no provenance)
Source review and suggested fix
Brief reasoning:
- The public
num_bitspath already checks for the exact block length. - The sorted variants skip that check and still load a full block from the slice.
- That makes the length precondition caller-visible through a safe API.
Suggested fix:
- Validate the exact block length before calling the unsafe routine, or make the precondition explicit in an
unsafeAPI.
Thanks again for taking a look.
- Ngôn ngữ chính
- Rust
- Star
- 346
- Fork
- 37
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của quickwit-oss/bitpacking
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
quickwit-oss/bitpacking#60 ·
-
Remove simd bitpacking implementations for high bit widthCó thể làm lại được @trinity-1686a đã nhận 1172 ngày trước và không có pull request nào đang mở. Đang mởgood first issue
quickwit-oss/bitpacking#47 · 2 bình luận · 1 người được giao ·
-
This crate vs tantivy-bitpackerĐang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 15/100
quickwit-oss/bitpacking#44 · 2 bình luận ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
quickwit-oss/bitpacking#21 · 6 bình luận ·
-
Hacktoberfest
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
quickwit-oss/bitpacking#20 · 2 bình luận ·
Tất cả issue của quickwit-oss/bitpacking
Issue tương tự
-
[M09] Silence parser misreads ffmpeg times in scientific notation (6.25e-05 → 6.25 s)Có thể đã có người làm @G-darshan-32 đã nhận hôm nay. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
clipy-recorder/clipy#164 · 1 bình luận ·
-
p2 ready-mac
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
quickwit-oss/tantivy#3299 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
P2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
arcships/dim#2294 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
`stream enable` fails with "already enabled" on every fresh session since streaming became always-onĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
vercel-labs/agent-browser#2797 ·
Maintainer thường phản hồi trong vòng 1 ngày