I'm using the Windows credentials store like this:
PCREDENTIAL cred = nullptr;
if (CredRead(entryName, 1, 0, &cred) != TRUE || !cred)
return -1;
// ... code which handles cred.UserName and cred.CredentialBlob
CredFree(cred);
As you can see I free the buffer as required. However, I see that the LPBYTE pointer CredentialBlob
is still valid an still contains the password in memory. Do I have to SecureZeroMemory
it manually and who owns the buffer? I found no other source code which does that...
I haven't found anything, https://msdn.microsoft.com/library/aa919793.aspx contains just the following generic statement:
Clear credential data from memory after use
Do not leave credentials in memory after use. Clear all credential data from temporary storage after use by calling SecureZeroMemory.