Skip to content

Zero scrypt scratch buffers before freeing#416

Open
gperciva wants to merge 1 commit into
masterfrom
zero-scrypt-buffers
Open

Zero scrypt scratch buffers before freeing#416
gperciva wants to merge 1 commit into
masterfrom
zero-scrypt-buffers

Conversation

@gperciva

Copy link
Copy Markdown
Member

No description provided.

@gperciva

Copy link
Copy Markdown
Member Author

This is #414, but I've added the bug reporter's name and (probable) bounty, as per our usual practice.

Comment thread lib-platform/crypto/crypto_scrypt.c Outdated
#else
free(V0);
#endif
insecure_memzero(XY, 256 * r + 64);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you move these two insecure_memzero calls above the #if then we don't need them in the error path.

Comment thread lib/crypto/crypto_scrypt-ref.c Outdated
return (0);

err2:
insecure_memzero(XY, 256 * r);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed here; it's impossible to reach err2 after writing to these buffers.

@gperciva

Copy link
Copy Markdown
Member Author

Whoops, I should have caught that. Added a REBASE commit, and moved the clearing into a separate /* Clear memory. */ paragraph for easier verification.

@cperciva

Copy link
Copy Markdown
Member

I would s/clear buffers/sanitize memory/ but I'm fine with either spelling. Please rebase.

@gperciva
gperciva force-pushed the zero-scrypt-buffers branch from 5b096cf to c7d87b0 Compare July 19, 2026 02:13
Reported by:	ChronoNova
Bug bounty:	$10 ("harmless")
@gperciva

Copy link
Copy Markdown
Member Author

Rebased, along with Sanitize memory

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants