Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Protect pages with secret data from being swapped to disk #165

Open
alnyan opened this issue Mar 10, 2021 · 3 comments
Open

Protect pages with secret data from being swapped to disk #165

alnyan opened this issue Mar 10, 2021 · 3 comments

Comments

@alnyan
Copy link

alnyan commented Mar 10, 2021

In secrets.rs, the array which is used to store secret key data has zeroize to be erased once dropped, but that doesn't prevent OS from swapping the pages to disk unencrypted.
A possible solution to that may be to use secrets crate to wrap the secret data. That'll additionally provide the functionality zeroize already gives.

@tarcieri
Copy link
Contributor

secrets has a hard FFI dependency on libsodium, whereas zeroize is pure Rust.

FWIW, there's some discussion about adding various strategies (including mlock) for protecting data in-memory to the pure Rust secrecy crate, which is built on zeroize:

iqlusioninc/crates#480

@benma
Copy link

benma commented Aug 15, 2021

I think the secrets module might also leave unwanted copies on the stack which are not zeroed, e.g. these:

ed25519-dalek/src/secret.rs

Lines 267 to 269 in 925eb9e

let mut hash: [u8; 64] = [0u8; 64];
let mut lower: [u8; 32] = [0u8; 32];
let mut upper: [u8; 32] = [0u8; 32];

Or this:

let mut bits: [u8; 32] = expanded_secret_key.key.to_bytes();

@isislovecruft
Copy link
Member

I'd be interested in the future if a cross-platform solution which does not pull in something large like libsodium were available to ensure pages aren't swapped.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants