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

Usage of mlock() happens after the data is written to unlocked mem #14

Open
tigusoft-vm opened this issue Apr 28, 2016 · 1 comment
Open

Comments

@tigusoft-vm
Copy link

In cases like below, we first write the secret data into variable k (in initialization list),
and after that we lock this memory location.

This means that for a short time the secret data is not protected.
For example if at exactly that time system would happen to swap the memory page with k,
it could land in swap space etc.

It would require a very bad luck, but maybe with ephemeral keys generated many times per minute eventually it could happen in practice sometimes.

For example in

unboxer(const box_public_key& pk, const box_secret_key& sk, const encoded_bytes& nonce_constant) : k(crypto_box_beforenm(pk.get().to_binary(), sk.get().to_binary())), n(nonce_constant, pk.get().to_binary() > sk.pk.get().to_binary()) {
mlock(k);
}

    unboxer(const box_public_key& pk, const box_secret_key& sk, const encoded_bytes& nonce_constant) : k(crypto_box_beforenm(pk.get().to_binary(), sk.get().to_binary())), n(nonce_constant, pk.get().to_binary() > sk.pk.get().to_binary()) {
        mlock(k);
    }
@tigusoft-vm
Copy link
Author

We're now writing a fix to this.

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

1 participant