rust-keyutils icon indicating copy to clipboard operation
rust-keyutils copied to clipboard

Secure the payload with mlock

Open mathstuf opened this issue 9 years ago • 5 comments

Also probably offer a structure for locking it down on its way in as well.

mathstuf avatar Nov 20 '15 05:11 mathstuf

http://ironframework.io/doc/libc/funcs/posix88/mman/fn.munlock.html

mathstuf avatar Nov 20 '15 05:11 mathstuf

I would propose a different approach here and in #8. Rust crates like secstr https://crates.io/crates/secstr already do this. You could either take a dependency on them, or just make keyutils compatible with secstr by just always taking data by reference.

josephlr avatar Jun 21 '19 10:06 josephlr

Hmm. It seems that by using Cow<[u8]> in the KeyPayload, the "take by reference" is always up to the user. I do see some potential holes:

  • keytypes::encrypted::Payload::Load is a Vec<u8> of data to load into the key. This is then placed into a String which takes it out of any secure storage
  • keytypes::rxrpc::Payload::session_key might warrant being in a secure array.
  • keytypes::rxrpc_s::Payload::key probably needs to be in one as well.
  • keytypes::trusted::Payload has some potentially sensitive information stored in a Vec.

mathstuf avatar Jun 21 '19 18:06 mathstuf

Hmm. The caller using SecBox around the entire payload should be sufficient for rxrpc's bits (since they're static-sized arrays). The ticket in rxrpc::Payload and other Vec<u8> bits should probably be SecVec<u8> now. Thoughts?

mathstuf avatar Jun 26 '19 23:06 mathstuf

Hrm. Returning a Cow::Owned moves the struct data back into a blob not in a zero-ing block of memory.

mathstuf avatar Jun 26 '19 23:06 mathstuf