Repository navigation
Conversation
The command saved every field of every object, so a rewrap also rewrote updated_at, and any other field, of all the rows of a model. It now compares the field values before and after rewrap_secrets(), and saves only the fields that changed, or nothing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A model can define a rewrap_secrets_queryset() class method, to return only the objects that hold secrets. Without it, the command still rewraps all the objects of the model. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Seven command classes encrypt a kwarg with the same context: the mdm.devicecommand model, the kwarg name as the field, and the command UUID. Four modules defined their own get_secret_engine_kwargs(), and two wrote the context inline. They now all use get_secret_engine_kwargs() from commands.base. The audit test finds the encrypted kwargs from the calls to this function, and now requires the same set as its list, so that a regex that matches nothing fails. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The attribute lists the command kwargs that are encrypted with the secret engine, not only the kwargs that are redacted in the audit trail. The next commit also uses it to rewrap these kwargs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The rewrap_secrets management command skipped the DeviceCommand and UserCommand models, so the PINs, the passwords and the FileVault encryption keys in the command kwargs stayed encrypted with the old secret engine. Once that engine was removed, a command that was still queued could not be sent or acknowledged, and the PRK returned for a RotateFileVaultKey command could not be decrypted. The abstract Command model now rewraps the secret_kwargs of its command class. Its rewrap_secrets_queryset() only returns the commands that have one of these kwargs, so that the rewrap does not load every command. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Coverage Report for CI Build 44756742642Coverage increased (+0.04%) to 91.689%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
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.
Problem
The
rewrap_secretsmanagement command rewraps the objects of the models that have arewrap_secrets()method. The MDMDeviceCommandandUserCommandmodels do not have one. Seven command classes keep a secret in their kwargs, encrypted with the secret engine:AccountConfigurationadmin_passwordDeviceLockPINEraseDevicePINRotateFileVaultKeyencryption_keySetAutoAdminPasswordnew_passwordSetFirmwarePasswordnew_passwordSetRecoveryLocknew_passwordThese secrets stay encrypted with the old secret engine. After the removal of this engine, Zentral cannot send or acknowledge a command that is still in the queue, and cannot decrypt the FileVault PRK that a device returns for a
RotateFileVaultKeycommand. The secrets of the acknowledged commands also stay under the old key.The command also saved all the fields of all the objects, so a rewrap set the
updated_atfield of each object to the time of the rewrap.Changes
One commit for each step:
rewrap_secretscompares the field values before and afterrewrap_secrets(), and saves only the fields that changed, withupdate_fields. It does not save an object that has no change.rewrap_secrets_queryset()class method to give the objects to rewrap. Without it, the command rewraps all the objects of the model, as before.get_secret_engine_kwargs(uuid, field)function fromcommands.base. Before, four modules had a copy of this function, and two modules wrote the context inline. The context does not change.audit_secret_kwargsis renamedsecret_kwargs. It lists the encrypted kwargs, which the audit trail redacts and the rewrap rewraps.Commandmodel getsrewrap_secrets()andrewrap_secrets_queryset(), soDeviceCommandandUserCommandboth have them. The queryset gives only the commands whose class has secret kwargs, and whose kwargs have one of them. No user-channel command has a secret today, so theUserCommandqueryset is empty.Tests
DeviceLockreads its PIN after a rewrap.get_secret_engine_kwargs(), so a regex that matches nothing fails.🤖 Generated with Claude Code