Skip to content

Test zeroization when going out of scope #1310

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

Closed
wants to merge 2 commits into from

Conversation

dvdplm
Copy link

@dvdplm dvdplm commented Apr 29, 2025

Test that zeroization actually occurs when a SecretBox goes out of scope.

Uses unsafe code, likely relies on UB and adds a custom allocator, hence the draft: is something like this acceptable?

@tony-iqlusion
Copy link
Member

A test like this would make more sense in zeroize itself

Comment on lines +395 to +397
let bytes: &[u8] = core::slice::from_raw_parts(ptr as *const u8, size_of::<u128>());
assert!(
bytes.iter().all(|&b| b == 0),
Copy link
Member

@tony-iqlusion tony-iqlusion Apr 29, 2025

Choose a reason for hiding this comment

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

This is UB since you're making a Rust reference that's UAF.

You could avoid UB by performing only raw pointer operations, i.e. computing new pointers and dereferencing them, which would be fairly trivial to do here.

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

Successfully merging this pull request may close these issues.

2 participants