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:
Mounir IDRASSI
2026-10-11 23:10:55 +09:00
parent b2b28d5793
commit 62253154cb
7 changed files with 48 additions and 15 deletions
+2 -2
View File
@@ -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;
}