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

memset used instead of OQS_MEM_CLEANSE #1864

Open
SWilson4 opened this issue Jul 26, 2024 · 0 comments
Open

memset used instead of OQS_MEM_CLEANSE #1864

SWilson4 opened this issue Jul 26, 2024 · 0 comments
Labels
good first issue Issue for new contributors help wanted Asking for support from non-core team

Comments

@SWilson4
Copy link
Member

In several places throughout the codebase, memset is being used instead of OQS_MEM_CLEANSE. When the data being reset is secret, this is undesirable, as a compiler may optimize out the memset call.

Here are a few examples:

if (idx >= ((1ULL << params->full_height) - 1)) {
// Delete secret key here. We only do this in memory, production code
// has to make sure that this happens on disk.
memset(sk, 0xFF, params->index_bytes);
memset(sk + params->index_bytes, 0, (size_t)(params->sk_bytes - params->index_bytes));

if (idx >= ((1ULL << params->full_height) - 1)) {
// Delete secret key here. We only do this in memory, production code
// has to make sure that this happens on disk.
memset(sk, 0xFF, params->index_bytes);
memset(sk + params->index_bytes, 0, (size_t)(params->sk_bytes - params->index_bytes));

/* On failure, make sure that we don't return anything that might be */
/* misconstrued as a real signature */
memset( signature, 0, signature_buf_len );

All of these examples are from the LMS / XMSS code, but this issue is not limited to that portion of the library.

Reported by @trailofbits in Week 1 of their audit of liboqs.

@baentsch baentsch added help wanted Asking for support from non-core team good first issue Issue for new contributors labels Aug 9, 2024
@praveksharma praveksharma mentioned this issue Aug 29, 2024
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Issue for new contributors help wanted Asking for support from non-core team
Projects
Status: Todo
Development

No branches or pull requests

2 participants