macOS/Unix: mounted volumes never use hardware AES because CPU features are not detected in the core service process
AI-generated report. It was written by an AI coding assistant, which reviewed the source and ran the benchmark below.
In plain terms: on Macs, VeraCrypt encrypts mounted volumes with its slower software AES code instead of the processor's built-in AES instructions, even though Preferences says hardware AES is available. The data is still encrypted correctly. The encryption step is about 10× slower, though, and it loses the hardware path's resistance to timing attacks. The fix is probably one call in main().
Summary
On macOS, and on Linux when FUSE is used, the sectors of a mounted volume are encrypted in the core service process and in the FUSE process forked from it. CPU feature detection never runs in those processes, so HasAESNI() is 0 there. AES then falls back to the table-based software implementation, even though Preferences shows "Yes" for processor AES support (PreferencesDialog.cpp:255) and the user has not disabled hardware acceleration.
Details (HEAD 078b4adb; the same code is in VeraCrypt_1.26.29)
DetectX86Features()andDetectArmFeatures()are only called fromUserInterface::Init()(src/Main/UserInterface.cpp:685and:688).- In
main()(src/Main/Unix/Main.cpp), both service processes start beforeApplication::Initialize()(lines 97 and 112), which is what leads toUserInterface::Init():- the elevated service branches off at line 62 (
CoreService::ProcessElevatedRequests); - the user-level service is forked by
CoreService::Start()at line 76.
- the elevated service branches off at line 62 (
- In those processes
g_hasAESARMandg_hasAESNIkeep their initial value of 0 (src/Crypto/cpu.c:492and:200).CipherAES::IsHwSupportAvailable()then cachesHasAESNI()as false (src/Volume/Cipher.cpp:255). - Mounts are routed to the service through
CoreService::RequestMountVolume(src/Core/Unix/CoreServiceProxy.h:126and:150). The service callsCipher::EnableHwSupport (!options.NoHardwareCrypto)(src/Core/Unix/CoreUnix.cpp:1196). That shows hardware AES is intended there: the preference is passed through, but it has no effect because detection never ran. - Both that Preferences line and the Benchmark run in the GUI process, where detection did run, so neither of them shows the problem.
- On x86 this appears to go back to commit fe31cf5b (1.18). That commit replaced the direct
is_aes_hw_cpu_supported()check inCipher.cppwith the cachedg_hasAESNIflag.
Impact
- Performance. I compiled VeraCrypt's own XTS-AES code standalone for arm64 and ran it on an Apple M1, single thread, with 64 KiB requests. It encrypts at about 2.6 to 3.0 GB/s when
DetectArmFeatures()has been called and about 258 MB/s when it has not. The ciphertext is identical either way. Real-world throughput also depends on the thread pool and on FUSE overhead. - Security. Table-based software AES is open to cache-timing attacks from other code running on the same machine. The hardware path avoids that. Users who see "Yes" in Preferences are actually getting the software path.
Suggested fix
Run CPU feature detection at the start of main() in src/Main/Unix/Main.cpp, before the elevated-service branch and before CoreService::Start(). Use the same guards as UserInterface::Init() (#ifdef CRYPTOPP_CPUID_AVAILABLE and #if CRYPTOPP_BOOL_ARMV8).
How to confirm on a shipped build
Mount an AES volume and copy a large file to it. While the copy runs, sample the service or FUSE process (sudo sample <pid> 5). With the bug present, the samples show Gladman's aes_encrypt/aes_decrypt. With hardware AES in use, they show aes_hw_cpu_encrypt_32_blocks/aes_hw_cpu_decrypt_32_blocks.
How this was found
Found by the AI-assisted review mentioned at the top. The code paths were checked against master, and the arm64 behaviour was confirmed by building VeraCrypt's crypto sources outside the app and benchmarking them with and without the detection call. I did not observe it on the shipped binary, because 1.26.29 cannot mount on my test machine: the macFUSE kext is unavailable under Full Security, and there is also GH #1887.
Environment
VeraCrypt version: 1.26.29 (macFUSE build) and master at 078b4adb Operating system: macOS 15.8.1 CPU: Apple M1 (arm64)
Thanks for the detailed report. I have confirmed the problem and pushed a fix in 61bfca247b5e69c288196fc49f3d54fdfeb77af3.
CPU feature detection now runs before the core services start, including the elevated service. Forked services inherit the detected capabilities, so hardware AES can be used where volume data is processed.
The commit also updates the Unix instruction probes to restore the signal mask after a failed probe. Moving detection earlier could otherwise leave SIGILL blocked in child processes and break elevation through doas on Linux.
I'm still working on 1.26.30 version that will be published soon and include this change.