RustCrypto / RustCrypto/utils

zeroize: possible UB in `Zeroize` implementation for `Option<T>`

オープン
#653 コメント 3 件 リアクション 2 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

主要言語
Rust
スター
674
フォーク
170
平均マージ
1日 12時間
マージ済み PR(30日)
10

説明

Originally filed by @jessa0 as https://github.com/iqlusioninc/crates/issues/782:

It seems the Zeroize implementation for Option<T> where T: Zeroize has language-level UB here:

https://github.com/RustCrypto/utils/blob/00b569b52b6dece2a8ae881f8e5a150a45ccc674/zeroize/src/lib.rs#L330

I believe, as a repr(Rust) enum, the memory layout and set of valid bit-patterns for Option is 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 for Option does mention guarantees for several special cases, but the None case still isn't defined for many of those cases, and the Zeroize implementation 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.

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

zeroize/src/lib.rs の330行目付近から始め、リンクされた Rust Playground または Miri の例を使って報告された動作を再現します。Option の実装に対する健全なアプローチを決定し、結果として得られる動作が報告された未定義動作エラーをもはや発生させないことを検証します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
rust
領域
security
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。