Repository navigation
Conversation
flatstik
force-pushed
the
fix-1982-clear-keys-latch
branch
2 times, most recently
from
November 3, 2026 17:04
2632683 to
cc92bb5
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Insufficient service-control permissions allow local non-administrators to trigger key wiping or encrypted-system crashes on device insertion and disable boot-loader and SetupConfig maintenance.
1 open issue
What changed in this PR
This PR adds an optional until-restart lock to Windows device-insertion key clearing, addressing #1982 within VeraCrypt’s system-encryption protections.
Changes:
- Adds driver lock/query controls and integrates the lock with system settings and service behavior.
- Prevents a superseded service from restoring older boot-loader components before restart.
- Adds lock prompts, failure messages, and documentation explaining the administrator limitation.
| File | Description |
|---|---|
Translations/Language.zh-tw.xml |
Adds English lock messages. |
Translations/Language.zh-hk.xml |
Adds English lock messages. |
Translations/Language.zh-cn.xml |
Adds English lock messages. |
Translations/Language.vi.xml |
Adds English lock messages. |
Translations/Language.uz.xml |
Adds English lock messages. |
Translations/Language.uk.xml |
Adds English lock messages. |
Translations/Language.tr.xml |
Adds English lock messages. |
Translations/Language.th.xml |
Adds English lock messages. |
Translations/Language.sv.xml |
Adds English lock messages. |
Translations/Language.sl.xml |
Adds English lock messages. |
Translations/Language.sk.xml |
Adds English lock messages. |
Translations/Language.ru.xml |
Adds English lock messages. |
Translations/Language.ro.xml |
Adds English lock messages. |
Translations/Language.pt-br.xml |
Adds English lock messages. |
Translations/Language.pl.xml |
Adds English lock messages. |
Translations/Language.nn.xml |
Adds English lock messages. |
Translations/Language.nl.xml |
Adds English lock messages. |
Translations/Language.nb.xml |
Adds English lock messages. |
Translations/Language.my.xml |
Adds English lock messages. |
Translations/Language.lv.xml |
Adds English lock messages. |
Translations/Language.ko.xml |
Adds English lock messages. |
Translations/Language.ka.xml |
Adds English lock messages. |
Translations/Language.ja.xml |
Adds English lock messages. |
Translations/Language.it.xml |
Adds English lock messages. |
Translations/Language.id.xml |
Adds English lock messages. |
Translations/Language.hu.xml |
Adds English lock messages. |
Translations/Language.he.xml |
Adds English lock messages. |
Translations/Language.fr.xml |
Adds English lock messages. |
Translations/Language.fi.xml |
Adds English lock messages. |
Translations/Language.fa.xml |
Adds English lock messages. |
Translations/Language.eu.xml |
Adds English lock messages. |
Translations/Language.et.xml |
Adds English lock messages. |
Translations/Language.es.xml |
Adds English lock messages. |
Translations/Language.el.xml |
Adds English lock messages. |
Translations/Language.de.xml |
Adds English lock messages. |
Translations/Language.da.xml |
Adds English lock messages. |
Translations/Language.cs.xml |
Adds English lock messages. |
Translations/Language.co.xml |
Adds English lock messages. |
Translations/Language.ca.xml |
Adds English lock messages. |
Translations/Language.bg.xml |
Adds English lock messages. |
Translations/Language.be.xml |
Adds English lock messages. |
Translations/Language.ar.xml |
Adds English lock messages. |
src/SetupDLL/Setup.c |
Notifies an unstoppable service that it is superseded. |
src/Setup/Setup.c |
Sends the superseded notification during installation. |
src/Mount/Mount.c |
Integrates locking into the service and settings dialog. |
src/Driver/Ntdriver.c |
Stores and reports the until-restart lock state. |
src/Common/Language.xml |
Defines the English lock prompt and failure message. |
src/Common/Dlgcode.h |
Declares service controls and the lock-query helper. |
src/Common/Dlgcode.c |
Forwards new notifications and queries driver lock state. |
src/Common/Apidrvr.h |
Defines the lock and query driver controls. |
doc/html/en/VeraCrypt RAM Encryption.html |
Documents lock activation and its administrator limitation. |
Review effort: Max
flatstik
force-pushed
the
fix-1982-clear-keys-latch
branch
2 times, most recently
from
November 8, 2026 16:57
9b96f83 to
5854701
Compare
… restart "Clear encryption keys from memory if a new device is inserted" can be disabled at any time without a restart: by unchecking it, by changing its registry value, or by stopping the VeraCrypt system service, which is what clears the keys. Someone at an unlocked machine can then connect a device without the keys being cleared. When the option is enabled, offer to also prevent it from being disabled until Windows restarts. The dialog requests this with a driver configuration flag, which only an administrator can write (every local user can send custom controls to the service, so a control alone is not enough), and the service then locks the option in the driver, which keeps this state until Windows restarts. While locked: - the service clears the keys on new device insertion whatever the registry value, and does not rebuild its list of known devices; - the service does not accept SERVICE_CONTROL_STOP. Setup already replaces a service that cannot be stopped when Windows restarts; it now also sets a service configuration flag, so that the running executable does not reinstall its own, older boot loader until then; - the settings dialog shows the option as checked and disabled. The lock is requested after the other settings are saved; if it cannot be confirmed through the driver, an error is shown. This does not protect against an administrator, who can still terminate the service process. Fixes veracrypt#1982
flatstik
force-pushed
the
fix-1982-clear-keys-latch
branch
from
November 10, 2026 15:01
5854701 to
5c68ffa
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Fixes #1982.
"Clear encryption keys from memory if a new device is inserted" can be disabled at any time without a restart: by unchecking it, by changing its registry value, or by stopping the VeraCrypt system service, which is what clears the keys.
This PR offers, when the option is enabled, to also prevent it from being disabled until Windows restarts. The prompt defaults to No, so nothing changes for users who answer No.
SERVICE_CONTROL_STOP;The Linux and macOS counterpart is in #1984.
Testing:
Ntdriver.c), Mount, Format, ExpandVolume, Setup and SetupDLL; no compiler warnings came from the changed files.Since I cannot test on Windows (or macOS), please feel free to merge this, close it, or take it as a basis for your own implementation, as you see fit.