Skip to content

Zero PIN buffers before freeing them - #195

Open
LockedWayi wants to merge 1 commit into
miekg:masterfrom
LockedWayi:zero-pin-buffers
Open

LockedWayi wants to merge 1 commit into
miekg:masterfrom
LockedWayi:zero-pin-buffers

Conversation

@LockedWayi

Copy link
Copy Markdown

Login, InitPIN, SetPIN and InitToken copy the PIN with C.CString and release it with C.free, so the PIN stays in freed memory until the allocator reuses it.

This zeroes the copy before it is freed. The writes go through a volatile pointer so the compiler cannot remove them. No API change.

Tested with go test -race ./... against SoftHSM2 2.6.1. secret_test.go checks that the whole allocation is zeroed.

Login, InitPIN, SetPIN and InitToken copy the PIN with C.CString and
release it with C.free, so the PIN stays in freed memory until the
allocator reuses it. Zero the copy before freeing it.
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.

1 participant