zeroize: possible UB in `Zeroize` implementation for `Option<T>`
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
Research direction
Start with zeroize/src/lib.rs around line 330 and reproduce the reported behavior using the linked Rust Playground or Miri example. Determine a sound approach for the Option implementation and verify that the resulting behavior no longer triggers the reported undefined-behavior error.
Written by the indexing model from the issue text.
Description
Originally filed by @jessa0 as https://github.com/iqlusioninc/crates/issues/782:
It seems the
Zeroizeimplementation forOption<T> where T: Zeroizehas language-level UB here:I believe, as a
repr(Rust)enum, the memory layout and set of valid bit-patterns forOptionis not defined, and that setting an enum's storage to an invalid bit-pattern while a reference to it exists, even if the value is never read, is instant language-level UB. The documentation forOptiondoes mention guarantees for several special cases, but theNonecase still isn't defined for many of those cases, and theZeroizeimplementation is more generic than that. Here's an example of a miri error in such a situation, that scottmcm came up with on URLO here.
- Dominant language
- Rust
- Stars
- 674
- Forks
- 170
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 10
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from RustCrypto/utils
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
RustCrypto/utils#1546 · 1 comment ·
-
Difficulty 3/5 1-2 days Newbie friendliness 55/100
RustCrypto/utils#1537 · 7 comments ·
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
RustCrypto/utils#1534 · 2 comments ·
-
Difficulty 5/5 Over a week Newbie friendliness 45/100
RustCrypto/utils#1529 · 4 comments ·
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
RustCrypto/utils#1510 · 1 comment ·
All issues in RustCrypto/utils
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
nautechsystems/nautilus_trader#5095 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
stellar/rs-soroban-env#1739 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
bug good first issue package: quic
Difficulty 2/5 1-3 hours Newbie friendliness 78/100