mirror of
https://github.com/veracrypt/VeraCrypt.git
synced 2026-10-22 14:22:36 +00:00
Wipe token keyfile buffers on failure and release
Use a size_t counter in burn so large erasures retain their full length. Install cleanup guards before token verification and keyfile application, including the Windows token export path. Reserve the complete EMV keyfile output before copying its components, and wipe temporary components on every exit. Erase cached card data before clearing or replacing it, including when copying a card fails. Validation: Linux console and GUI builds with algorithm tests; cleanup checks with GCC and Clang UBSan. PR 1816 still applies cleanly.
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
*/
|
||||
|
||||
#include "Platform/Serializer.h"
|
||||
#include "Platform/Finally.h"
|
||||
#include "Common/SecurityToken.h"
|
||||
#include "Common/EMVToken.h"
|
||||
#include "Crc32.h"
|
||||
@@ -36,6 +37,7 @@ namespace VeraCrypt
|
||||
{
|
||||
// Apply keyfile generated by a security token
|
||||
vector <uint8> keyfileData;
|
||||
finally_do_arg (vector <uint8> *, &keyfileData, { if (!finally_arg->empty()) burn (&finally_arg->front(), finally_arg->size()); });
|
||||
Token::getTokenKeyfile(wstring(Path))->GetKeyfileData(keyfileData);
|
||||
|
||||
if (keyfileData.size() < MinProcessedLength)
|
||||
@@ -57,8 +59,6 @@ namespace VeraCrypt
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
burn(&keyfileData.front(), keyfileData.size());
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user