From 5b381ce7d7ec45e02765b4a180f9aa1ee8aeee40 Mon Sep 17 00:00:00 2001 From: Mounir IDRASSI Date: Mon, 8 Aug 2016 00:49:00 +0200 Subject: Windows: Fix vulnerability inherited from TrueCrypt that allows an attacker to detect with high probability if a hidden volume is present. Vulnerability reported by Ivanov Alexey Mikhailovich. --- src/Format/InPlace.c | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) (limited to 'src/Format/InPlace.c') diff --git a/src/Format/InPlace.c b/src/Format/InPlace.c index d3b3212b..f37cb8be 100644 --- a/src/Format/InPlace.c +++ b/src/Format/InPlace.c @@ -566,6 +566,8 @@ int EncryptPartitionInPlaceBegin (volatile FORMAT_VOL_PARAMETERS *volParams, vol // Prepare the backup header for (int wipePass = 0; wipePass < (wipeAlgorithm == TC_WIPE_NONE ? 1 : PRAND_HEADER_WIPE_PASSES); wipePass++) { + PCRYPTO_INFO dummyInfo = NULL; + nStatus = CreateVolumeHeaderInMemory (hwndDlg, FALSE, header, volParams->ea, @@ -607,6 +609,47 @@ int EncryptPartitionInPlaceBegin (volatile FORMAT_VOL_PARAMETERS *volParams, vol if (nStatus != ERR_SUCCESS) goto closing_seq; + + // write fake hidden volume header to protect against attacks that use statistical entropy + // analysis to detect presence of hidden volumes + nStatus = CreateVolumeHeaderInMemory (hwndDlg, FALSE, + header, + volParams->ea, + FIRST_MODE_OF_OPERATION_ID, + NULL, + 0, + 0, + NULL, + &dummyInfo, + dataAreaSize, + dataAreaSize, + TC_VOLUME_DATA_OFFSET + dataAreaSize, // Start of the encrypted area = the first byte of the backup heeader (encrypting from the end) + dataAreaSize, // No data is encrypted yet + 0, + volParams->headerFlags | TC_HEADER_FLAG_NONSYS_INPLACE_ENC, + volParams->sectorSize, + wipeAlgorithm == TC_WIPE_NONE ? FALSE : (wipePass < PRAND_HEADER_WIPE_PASSES - 1)); + + if (nStatus != ERR_SUCCESS) + goto closing_seq; + + crypto_close (dummyInfo); + + offset.QuadPart += TC_HIDDEN_VOLUME_HEADER_OFFSET; + + if (!SetFilePointerEx (dev, offset, NULL, FILE_BEGIN)) + { + nStatus = ERR_OS_ERROR; + goto closing_seq; + } + + // Write the fake hidden backup header to the partition + if (!WriteEffectiveVolumeHeader (TRUE, dev, (byte *) header)) + { + nStatus = ERR_OS_ERROR; + goto closing_seq; + } + } @@ -1045,6 +1088,8 @@ inplace_enc_read: for (int wipePass = 0; wipePass < (wipeAlgorithm == TC_WIPE_NONE ? 1 : PRAND_HEADER_WIPE_PASSES); wipePass++) { + PCRYPTO_INFO dummyInfo = NULL; + nStatus = CreateVolumeHeaderInMemory (hwndDlg, FALSE, header, headerCryptoInfo->ea, @@ -1081,6 +1126,40 @@ inplace_enc_read: if (nStatus != ERR_SUCCESS) goto closing_seq; + + // write fake hidden volume header to protect against attacks that use statistical entropy + // analysis to detect presence of hidden volumes + nStatus = CreateVolumeHeaderInMemory (hwndDlg, FALSE, + header, + headerCryptoInfo->ea, + headerCryptoInfo->mode, + NULL, + 0, + 0, + NULL, + &dummyInfo, + masterCryptoInfo->VolumeSize.Value, + masterCryptoInfo->VolumeSize.Value, + masterCryptoInfo->EncryptedAreaStart.Value, + masterCryptoInfo->EncryptedAreaLength.Value, + masterCryptoInfo->RequiredProgramVersion, + masterCryptoInfo->HeaderFlags | TC_HEADER_FLAG_NONSYS_INPLACE_ENC, + masterCryptoInfo->SectorSize, + wipeAlgorithm == TC_WIPE_NONE ? FALSE : (wipePass < PRAND_HEADER_WIPE_PASSES - 1)); + + if (nStatus != ERR_SUCCESS) + goto closing_seq; + + crypto_close (dummyInfo); + + offset.QuadPart += TC_HIDDEN_VOLUME_HEADER_OFFSET; + + if (SetFilePointerEx (dev, offset, NULL, FILE_BEGIN) == 0 + || !WriteEffectiveVolumeHeader (TRUE, dev, (byte *) header)) + { + nStatus = ERR_OS_ERROR; + goto closing_seq; + } } // Update the configuration files -- cgit v1.2.3