Repository navigation
feat(mdm): require BitLocker per Windows host on Fleet Free CU-17tkuw6a8db #293
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+1,272
−19
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
48fb5ce
feat(mdm): CU-17tkuw6a8db require BitLocker per Windows host on Fleet…
andrii-flamingo fc8cbd0
fix(mdm): CU-17tkuw6avb8 require the server URL on a tenant config up…
andrii-flamingo 928a8fc
fix(mdm): CU-17tkuw6a8db clear the key time with the BitLocker key row
andrii-flamingo 48ba46d
fix(mdm): CU-17tkuw6a8db count a repeated host id once in the BitLock…
andrii-flamingo f0a0ef4
fix(mdm): CU-17tkuw6a8db take the BitLocker key of a host that left MDM
andrii-flamingo 8302101
fix(mdm): CU-17tkuw6a8db move the BitLocker requirement to the Window…
andrii-flamingo 3d24a1c
fix(mdm): CU-17tkuw6a8db lift the old tenant's BitLocker requirement …
andrii-flamingo 16a45a4
Merge branch 'main' into feat/windows-disk-encryption
andrii-flamingo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| # BitLocker required per host on Fleet Free (OpenFrame) | ||
|
|
||
| Upstream requires disk encryption per team and only on Premium. In the fork a team is a tenant, and a tenant | ||
| requires encryption for some of its customers only, so each Windows host has its own requirement. | ||
|
|
||
| Only in OpenFrame mode (`FLEET_OPENFRAME_MODE`) or shared mode; otherwise everything below is upstream's. macOS | ||
| and Linux keep the team's setting, except the archived keys (below). | ||
|
|
||
| ## Requirement | ||
|
|
||
| - `POST /api/_version_/fleet/disk_encryption/hosts` with `{"host_ids": [1, 2]}` requires the hosts to encrypt; | ||
| `DELETE` on the same path with the same body lifts that. Both answer `{"hosts": <n>}`, the number of hosts they | ||
| applied to, and can be repeated. Permission is the one for upstream's `POST /disk_encryption`, on the pinned team. | ||
| - Hosts of another tenant, hosts that don't exist and hosts that don't run Windows are dropped. In shared mode a | ||
| call without a tenant is refused. | ||
| - `openframe_host_disk_encryption` (`migrations/openframe/20261201000001_AddHostDiskEncryptionTable.go`) keeps a row | ||
| per host that was ever required, with the tenant it was required in. Lifting keeps the row with `required = 0`. | ||
| A host moved to another tenant is not required there, and starts there without the old tenant's error and key | ||
| time. The move lifts the old tenant's requirement in the same row, which keeps the old tenant: a consumer of the | ||
| row sees the requirement end. Deleting the host deletes the row. | ||
|
|
||
| ## Result | ||
|
|
||
| The same row keeps what fleetd reported, without the key, so that the table can be captured by the CDC connector and | ||
| `host_disk_encryption_keys`, which holds the keys, never has to be: | ||
|
|
||
| - `client_error`: fleetd's last error, empty when there is none. A failing fleetd reports it again every config cycle; | ||
| a repeated error changes nothing in the row. | ||
| - `key_stored_at`: when the host's last key was stored, NULL before the first. An error keeps it. | ||
|
|
||
| Both are cleared where upstream deletes the key row, MDM re-enrollment and team change: after a wipe or a reinstall the | ||
| disk is another one. A required host's fleetd then sends a new key. Lifting the requirement keeps both. The archived key | ||
| stays readable after a re-enrollment, so NULL in `key_stored_at` does not mean that Fleet has no key. | ||
|
|
||
| ## What follows it | ||
|
|
||
| - **fleetd** (`setDiskEncryptionNotifications`): a required host that is in MDM gets `EnforceBitLockerEncryption` | ||
| under upstream's conditions; any other host does not, whatever the team's setting is. Lifting never turns | ||
| BitLocker off. | ||
| - **The key** (`SetOrUpdateDiskEncryptionKey`): stored for a host that was ever required, also after the requirement | ||
| was lifted or the host left MDM. On a drive that was already encrypted fleetd removes the other recovery keys before | ||
| it sends the new one, so a dropped key would leave none that opens the drive. Outside MDM only a key is taken: an | ||
| error is refused, as upstream refuses everything. | ||
| - **The status** (`GetMDMWindowsBitLockerStatus`, `os_settings.disk_encryption` in host details): shown on Free for a | ||
| required host, empty for any other. No startup PIN is ever required. | ||
|
|
||
| `GET /hosts/{id}/encryption_key` is upstream's. The host is fenced (`HostLite`), and in shared mode the key is | ||
| decrypted with the pair of the host's tenant. | ||
|
|
||
| ## Archived keys | ||
|
|
||
| Without an archived key of the host itself, upstream returns one by hardware serial. In OpenFrame mode, and for a | ||
| request pinned to a tenant, it does not, on any platform: the serial can be another machine's, of the tenant or of | ||
| another one. | ||
|
|
||
| ## Known limits | ||
|
|
||
| - A host that was deleted and enrolls again is a new host: it is not required, and its archived key stays under the old | ||
| host and is not found. Requiring the new host makes fleetd send a new key. | ||
| - fleetd sends again a key that Fleet did not take only while the host is told to encrypt. A key that failed to | ||
| reach Fleet is lost if the requirement is lifted, or the host leaves MDM, before the next try. | ||
| - The result is written after the key, not with it. Its write is retried on a deadlock or a lock timeout; if it | ||
| fails, `key_stored_at` stays as it was until the next key. | ||
| - Reading a key needs Windows MDM to be on for the tenant (`VerifyMDMWindowsConfigured`), as upstream. | ||
|
|
||
| ## Tests | ||
|
|
||
| - `server/service/openframe_windows_disk_encryption_test.go` | ||
| - `server/datastore/mysql/openframe_windows_disk_encryption_test.go` (`MYSQL_TEST=1`) |
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
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
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
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
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
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
37 changes: 37 additions & 0 deletions
37
server/datastore/mysql/migrations/openframe/20261201000001_AddHostDiskEncryptionTable.go
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| package openframe | ||
|
|
||
| import ( | ||
| "database/sql" | ||
| "fmt" | ||
| ) | ||
|
|
||
| func init() { | ||
| MigrationClient.AddMigration(Up_20261201000001, Down_20261201000001) | ||
| } | ||
|
|
||
| // Up_20261201000001 adds `openframe_host_disk_encryption`: the Windows hosts OpenFrame has ever required to encrypt, and | ||
| // whether it still does. A row stays when the requirement is lifted, so that a key on its way is accepted. `team_id` is | ||
| // the host's tenant when the row was written: a row does not follow the host to another tenant. `client_error` and | ||
| // `key_stored_at` repeat what host_disk_encryption_keys knows without the key, so that this table can be captured by the | ||
| // CDC connector and that one never has to be. See openframe/docs/windows-disk-encryption.md. | ||
| // | ||
| // Idempotent. | ||
| func Up_20261201000001(tx *sql.Tx) error { | ||
| if _, err := tx.Exec(` | ||
| CREATE TABLE IF NOT EXISTS openframe_host_disk_encryption ( | ||
| host_id INT UNSIGNED NOT NULL, | ||
| team_id INT UNSIGNED DEFAULT NULL, | ||
| required TINYINT(1) NOT NULL, | ||
| client_error VARCHAR(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', | ||
| key_stored_at TIMESTAMP(6) NULL DEFAULT NULL, | ||
| updated_at TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), | ||
| PRIMARY KEY (host_id) | ||
| ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci`); err != nil { | ||
| return fmt.Errorf("creating openframe_host_disk_encryption: %w", err) | ||
| } | ||
| return nil | ||
| } | ||
|
andrii-flamingo marked this conversation as resolved.
Resolved
|
||
|
|
||
| func Down_20261201000001(tx *sql.Tx) error { | ||
| return nil | ||
| } | ||
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.