scrypt: zeroize the B, V and T buffers before freeing them

Đang mở
#938 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

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
55/100
Loại issue
Tính năng
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
cryptography, rust
Lĩnh vực
cryptography, security

Hướng nghiên cứu

The three heap buffers b in scrypt() and v and t in romix_sequential and romix_parallel are all in scrypt/src/lib.rs. Read how they are allocated and dropped, then check scrypt/Cargo.toml for an existing zeroize dependency. Done means each buffer is cleared before it is freed, and the existing scrypt test vectors still pass. Whether to gate this behind a zeroize feature is a maintainer decision, so ask in the issue first.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Version: scrypt 0.12.0. Master as of 2026-10-10 is the same (scrypt/src/lib.rs has the same allocations and no zeroize).

scrypt::scrypt allocates three heap buffers that hold password-derived data, then frees them without zeroizing:

  • b in scrypt() (p * 128 * r bytes): the PBKDF2-HMAC-SHA256 output of the password and salt. ROMix mixes it in place, and it then becomes the salt of the final PBKDF2 step.
  • v in romix_sequential / romix_parallel (N * 128 * r bytes, 256 MiB at log_n = 18, r = 8).
  • t in the same two functions (128 * r bytes).

After scrypt() returns, their contents stay in freed heap memory until something reuses it. This matters beyond ordinary hygiene. The first block of v is shuffle_in(B), a fixed permutation of the initial one-iteration PBKDF2 output. Anyone who later reads that freed memory, for example in a core dump, in swap or through a later allocation in the same process, can test password guesses for the cost of one PBKDF2-HMAC-SHA256 iteration each. That skips the memory-hard work scrypt exists to force.

Suggestion: zeroize b, v and t before they drop, either always or behind an optional zeroize feature like other RustCrypto crates. It costs one write pass over v, which is small next to the 2N BlockMix calls ROMix already makes.

Context: we use scrypt() as a passphrase KDF for file encryption (an age v1 scrypt stanza; log_n = 18, r = 8, p = 1).

Ngôn ngữ chính
Rust
Star
920
Fork
122
Merge trung bình
52 phút
Pull request đã merge (30 ngày)
11

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

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của RustCrypto/password-hashes

Tất cả issue của RustCrypto/password-hashes

Issue tương tự

Thêm issue về Rust

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.