26. Hardening: fix plans, executions and rollback
This guide describes Lawliet 1.6.3.b (the current release, a beta: earlier releases are beta. The first stable release will be 2.0.0). Screens, commands and procedures may change in later versions; the usage guide is updated with each release. Check the version your server runs under Settings > Platform or with ./lawliet version, and see the Releases page for what changed.
Hardening changes the configuration of a managed host so that failed compliance controls pass. It is the only part of the compliance area that changes hosts, so every live run is held for approval and every step that has a rollback script can be reversed.
Two pages sit beside it, reached with the buttons at the top of the Hardening page:
- Planner - what to fix first on a host or a group, why, what it will break and what must be fixed before it; audit steps and enforce requests (chapter 41).
- Host baseline - what each host uses and hardening must not disrupt (chapter 42).
The life of a hardening run:
scan -> Fix plan or Planner (choose fixes; one host, or a batch of hosts) -> run "Pending approval"
-> Approve & Execute (four-eyes) -> agent runs each step -> Completed / Partially completed / Failed
-> optional Rollback (four-eyes) -> Rolled backMany hosts at once: a batch creates one run per host and is approved once (chapter 57); its runs are listed under Batches on this page, not in the runs table, and cannot be approved one by one.
Permissions:
| Task | Permission | Four-eyes |
|---|---|---|
| See runs and their steps | View hardening | - |
| Create a run from a scan's Fix plan or the planner | Run hardening | no (the run waits for approval) |
| Start a lock-out-risky control (typed acknowledgement) | Run hardening | the run then needs someone other than the requester to approve it |
| Approve & Execute a run | Run hardening | yes - critical action "Execute remediation" |
| Roll back a run | Run hardening | yes - "Execute remediation" |
| Cancel a run | Run hardening | no |
| Issue or download a recovery artifact | Run hardening | yes - "Execute remediation" |
Every route runs the same checks#
Whether a run is created from the Fix plan, the planner, a drift Re-apply or the older API calls (POST /api/v1/hardening/executions, the compliance harden call), the executor checks every catalog control in it against the planner's rules: guards, order and conflicts (counting every live run on the host), duplicates, the audit step, the do-not-disrupt baseline and breakage over the fixed 30-day window. It refuses (409) instead of skipping. The checks run when the run is created and again when it is approved, against the host as it is then; a run still waiting after 24 hours (HARDENING_PENDING_EXPIRY_HOURS) expires and must be requested again (41.6).
After an upgrade to 1.5.14.s, a baseline or guard override signed under an earlier version is refused when its run is approved: plan the host again and request the override again through the planner (41.7).
26.1 What the Hardening page shows#
Path: Hardening.
- A warning: "Hardening changes live system configuration. Dry-run executions preview what would happen without queuing real commands. Approve non-dry-run executions only after reviewing all steps and confirming the target agent."
- "N failed steps across all executions" with View in review queue, when steps failed.
- Recovery / break-glass panel (26.5).
- Tiles: Total, Running, Done, Dry OK, Partial, Failed, Pending.
- Filters: Search ID or framework... and a status list (Pending approval, Approved, Executing, Completed, Dry run complete, Partially completed, Failed, Rolled back, Cancelled).
- Table: Mode (live or dry run), Status, Frameworks, Steps, Created. Details opens a run.
The run drawer shows the header ("Live execution - scan #N" or "Dry-run preview - no real commands were queued"), Status, Mode, Requested by, Approved by, the Step summary (each step with its output), View failed steps in Review Queue, and the Actions that apply to the run's status.
26.2 Procedure: approve and execute a run#
Before you start: the run was created from a scan (chapter 22). If any selected control can lock you out of the host, issue its recovery artifact first (26.5).
Risk: the commands run with the agent's privileges and change live system configuration. A wrong fix can stop a service or block remote access. Rollback: Rollback (26.3) reverses each step that has a rollback script. Steps without one must be reverted by hand.
- Open Hardening and press Details on the run with status Pending approval.
- Read every step in Step summary and check the target agent.
- Press Approve & Execute. The confirmation says: "This queues N remediation command(s) for execution on agent #ID" and warns that only steps with a rollback script can be reversed.
- Press Confirm and execute.
- Four-eyes: type a reason and press Send for approval (20.4). A second person approves in Approvals; you then press Execute now in Approvals > My requests within the execution window.
What you see: "Execution approved - remediation commands queued." The status moves to Executing, then Completed, Partially completed or Failed. The agent receives the commands on its next check-in.
- Run the compliance scan again to confirm the controls now pass.
A control whose change takes effect only after a restart is marked needs reboot in the plan. Once applied, its step shows Restart needed and is validated only after the agent reports that the host restarted (agents 2.1.10.s report a boot identity a clock change cannot move). Restart the host in its maintenance window, by hand or from Restart needed on this page (56). With an older agent the step says "Restart needed - this agent cannot report restarts; re-scan after restarting".
On Linux, these take effect only after a restart: the AppArmor, audit and audit-backlog kernel arguments, the audit lock (-e 2) and a separate /tmp. Some steps find out on the host that a restart is needed and show Restart needed even though the plan did not say so: audit rules added while the audit configuration is locked, and a kernel module that is in use and cannot be unloaded now (it stays blocked from loading). A rollback the running kernel keeps until a restart (a kernel argument removed, the audit lock removed, the /tmp mount) shows the same. Umask, shell timeout and the core-dump limit show Takes effect after sign-out or restart: sessions and services that are already running keep the old value. A step whose reload or restart of sshd, journald, rsyslog, chrony or auditd fails is Failed, with the service's error in the step output; the setting is not reported as applied.
If it fails:
| What you see | Cause | Fix |
|---|---|---|
| "Approve failed: ..." | The run is no longer pending, or permission | Read the message; refresh the page |
| Status stays Executing | The agent is offline | Check the host in Environment > Hosts |
GUARD_BLOCKED, GUARD_CHANGED, "new use seen since the enforce was requested" | The host changed while the run waited | Plan the host again (chapter 41) |
| "This execution waited for approval longer than allowed and has expired ..." | Pending more than 24 hours | Request it again |
| Partially completed / Failed | Some steps failed on the host | Open the run, read each failed step's output; View failed steps in Review Queue |
When a change is in force#
A step that ran is not always a change in force. The step and the run say which:
| Label | Meaning | What to do |
|---|---|---|
| Restart needed | In force only after the host restarts (the catalog says so, or the script found it out on the host, e.g. a module in use). The control reads not assessed until then. | Restart the host; the step is validated on the next boot. |
| Takes effect after sign-out or restart | In force for new sign-ins only (user rights, per-user settings, WDigest, umask/TMOUT). Validated after the next boot, which ends every session. | Restart the host, or wait for the next maintenance restart. |
| Rolled back - restart needed | The rollback ran; the previous setting returns only after the restart. The run reads rolled back with a note. | Restart, then re-scan. |
| Overridden by domain policy | Applied and validated, but a domain GPO (named when the agent knows it) sets this value and puts its own back at the next policy refresh. The control is not compliant and a review item opens. | Change the setting in that GPO. |
A step marked "Group Policy key - a domain GPO that sets it would revert it" is advice only: the setting lives under a policy key, and no GPO was reported setting it.
A held change blocks applying that control again on the host until the restart validates it: its run stays in progress and the control reads not assessed, so a new run, the planner, the automatic drift re-apply and the automatic baseline of a new host all skip or refuse it with the reason. A sign-out alone does not release the hold - Lawliet validates on the next boot - so restart the host (Restart needed on this page, 56) to settle it.
A held rollback on an agent older than 2.1.10.s reads "Rolled back - restart cannot be detected on this agent version; update the agent": restart the host, re-scan, and update the agent. If a run is cancelled or rolled back while a change waits for its restart, that step ends Validation failed with "Execution stopped before the restart; not validated - re-scan to confirm the host's state", and the control returns to its previous status.
26.3 Procedure: roll back a run#
Rollback is offered for runs that are Approved, Executing, Completed, Partially completed or Failed.
Risk: rollback also changes the host; it restores the previous settings of the reversible steps. Rollback of the rollback: none - re-run hardening if needed.
- Open the run with Details and press Rollback.
- Read the note: "Rollback queues reversal commands on the agent. Only steps with a rollback script will be reversed. Validate system state after rollback and re-run a compliance scan to confirm restoration."
- Press Confirm rollback, then complete the four-eyes request as in 26.2 step 5.
What you see: each step shows its rollback as rollback queued, rollback sent to host, then rolled back (host confirmed) or rollback failed - change still on host (also rollback not answered). The run becomes Rolled back only when every queued rollback is confirmed by the host. A rollback the host refused is queued again on the next request; a request while one is still with the agent, or with nothing left to roll back, is refused (409) and changes nothing.
If it fails: "Rollback failed: ..." names the reason. Steps without a rollback script are not reversed; revert them by hand.
No automatic rollback. The Fix plan marks a control "no automatic rollback" before you apply it when nothing can undo it automatically (re-enabling reversible password encryption, reinstalling a removed service). Such a change is never reported rolled back: after a rollback it stays listed as a change with no rollback, still on the host.
Manual changes. "Manual changes, not applied by Lawliet" in the Fix plan lists the controls Lawliet only checks, each with what it needs (for example "Requires Group Policy deployment" for user rights, or a LAPS deployment). They are never offered as fixes.
Built-in Administrator / Guest rename (CIS 2.3.1.5 / 2.3.1.6). The account is renamed by its SID and the rollback renames it back by SID. On a domain controller the change is refused - the built-in accounts there are the domain's - rename them with a domain GPO instead, or set HARDENING_ALLOW_DC_BUILTIN_RENAME=true on the server to allow it. Both controls ask you to accept the lock-out risk and need a second administrator.
Domain policy. A step shows when a domain policy overrides or reverts its setting. A step whose setting a domain GPO manages shows "domain policy manages this setting": the next Group Policy refresh puts the GPO's value back unless the GPO is changed. A step that a later scan finds reverted on a domain member shows "overridden by domain policy" (or "reverted after apply - check domain policy"); change the setting in the GPO, not on the host. The step does not name the GPO in this release.
Already restored. The value from before the first apply is kept on the host per control. When two runs applied the same control, the first rollback restores that value; the other run's rollback then reads "Already restored ..." and is rolled back, not failed.
26.4 Procedure: cancel a run#
Cancel is offered while a run is Pending approval, Approved or Executing. No four-eyes.
- Open the run and press Cancel.
- Read: "Cancel this execution? Steps already queued on the agent may continue until the agent receives the cancellation on next check-in."
- Press Confirm cancel. You see "Execution cancelled."
A step that already ran is not undone by Cancel. Use Rollback for that.
26.5 Recovery and break-glass#
Before you apply a control that can lock you out - key-only SSH, firewall lockdown, disabling the built-in administrator, disk encryption - issue the matching recovery artifact, so there is always one authorised way back in.
| Kind | Use |
|---|---|
| SSH recovery key | A way back in after SSH is set to key-only |
| Break-glass admin | An emergency administrator account |
| Disk recovery key | Recovery for disk encryption |
| Firewall rollback | A way to undo a firewall lockdown |
Procedure: issue and download a recovery artifact#
Permission: Run hardening. Four-eyes: yes for both issue and download.
- Open Hardening and expand Recovery / break-glass.
- Choose the host in Select a host... and the kind.
- Type the reason in Reason (audited) and press Issue. Complete the four-eyes request.
- Read the State column. It says in words where the artifact stands and, under To do:, what you still have to do. It updates by itself while it waits on the host.
- When To do: says so, press Download once. Complete the four-eyes request.
- Store the secret offline, in your organisation's safe.
The states:
| State | Meaning | What you do |
|---|---|---|
| Waiting for the host | The task has not reached the host yet (it picks it up at its next check-in). | Nothing; if it stays, check the agent is online. |
| Installing on the host / Reading from the host | The agent received the task and is creating the account (or reading the key or ruleset). | Nothing; the row moves on by itself. |
| Ready to download | The account is on the host (or the key was captured). | Download once and store it offline. |
| Done | The account is on the host and you downloaded its secret. | Nothing. |
| Not installed / Not captured | The agent reported a failure; the reason is shown. The secret does not open the host. | Fix the cause and issue a new artifact. |
| No answer from the host | The agent took the task but never reported back; nobody knows whether the account exists. | Check the agent is online and up to date, then issue a new artifact. |
Windows agents up to 2.1.14.s cannot create the break-glass administrator (fixed in the next agent). For those hosts the kind shows "(not available on this host)", Issue is disabled and the panel says: "This Windows agent version cannot create the break-glass account (fixed in the next agent). Create a local administrator by hand and record it, or accept the lock-out risk to go ahead without one: type ACCEPT LOCKOUT RISK in the lock-out box, or turn on automatic risk acceptance on the server (sudo ./lawliet hardening-risks accept-all)." The lock-out box in the Fix plan says the same instead of asking you to issue it. Automatic risk acceptance (sudo ./lawliet hardening-risks accept-all, the HARDENING_AUTO_ACCEPT_RISKS setting; normal turns it off) accepts the lock-out risk for every hardening change an administrator starts. An artifact issued for such a host before this update reads Not installed with that reason.
A break-glass admin or SSH recovery key can be downloaded as soon as it is issued, but it opens the host only once the state says the account is on the host. The planner's break-glass check counts it only from then.
Each secret can be downloaded once, then it is purged. If the download fails ("Download failed (already used, or not ready).") issue a new artifact.
Lock-out-risky controls in the Fix plan#
A control that can lock you out of the host (for example key-only SSH, or a WinRM change) is not started on the first press. The Fix plan (and Request enforce / Override baseline with approval in the planner) shows a red box: "This control can lock you out of the host" (or "N controls can lock you out of the host"), and for each control its id and name, Risk: and Before you start: (the recovery artifact to issue).
Risk: if the change locks you out and you have no recovery artifact, you need console or physical access to the host. Rollback: roll the run back from Hardening; the recovery artifact is the way back in if the host is unreachable.
- Issue the recovery artifact for the host first (see "Recovery / break-glass" above).
- In the box, type ACCEPT LOCKOUT RISK ("To start anyway, type ACCEPT LOCKOUT RISK. The run still waits for approval.").
- Press Start with lockout risk accepted. Cancel sends nothing. The request sent is the one that was refused; changing the selection, the WinRM ranges or the NTLM exceptions closes the box (start again).
What you see: "Hardening run N created. It waits for approval before anything changes on the host." (Fix plan) or the planner's result line. Every other check still applies. The run's detail on Hardening says "Someone other than the requester must approve this run: it carries an accepted lockout risk or a risky re-apply."; the requester cannot approve it, and the audit entry names the controls.
26.6 Windows: which changes wait for a restart or a sign-out#
Windows reads many security settings only when something starts, so a Windows control is reported fixed when the setting is in force, not when the value is written:
| Windows controls | Held as | Why |
|---|---|---|
| SChannel protocols, ciphers, hashes and suite order; .NET strong crypto; LSA protection (RunAsPPL); UAC on (EnableLUA); LSASS plug-in audit; early-launch antimalware; FIPS; kernel object protection and case-insensitivity; safe DLL search; machine inactivity limit; Netlogon secure channel signing/sealing and strong key; VBS, memory integrity, System Guard, kernel stack protection, DMA protection, exploit protection (SEHOP, DEP, ASLR, CFG); Credential Guard | Restart needed (the change and its rollback) | Read at start-up by LSASS, the kernel or the boot loader. |
| SMBv1 removal, Windows Server feature removal (IIS, WebDAV, FTP, Fax, SNMP, ...) | Restart needed only when Windows says the removal finishes at the next restart | Windows reports it while making the change. |
| User rights assignment, per-user Office/Explorer/privacy policies, WDigest off, Kerberos AES-only, UAC approval mode for the built-in Administrator | Takes effect after sign-out or restart | In the sign-in token or the user's session; running sessions keep the old setting. |
After the restart, VBS, memory integrity, System Guard and kernel stack protection pass only when Windows reports them running (Win32_DeviceGuard), and LSA protection only when LSASS started as a protected process in this boot. Configured but not running reads "Configured, not running" and the step fails validation: check the firmware (virtualization, Secure Boot) and drivers.
LSA protection is written without the UEFI lock (RunAsPPL 2) on Windows 11 22H2 and later and Windows Server 2025; older builds only know the locked mode (RunAsPPL 1), which a Secure Boot host copies into firmware at the next restart. From then on the registry no longer turns it off, and a rollback on such a host says "Not reverted: LSA protection is UEFI-locked on this host ... Run LsaPplConfig.efi (Microsoft LSA Protected Process Opt-out tool) at the console, then restart" instead of claiming it reverted.
Overridden by domain policy on a Windows step means the agent found, in the host's Resultant Set of Policy, a domain GPO that sets the same registry value (machine or user), security option, registry permission, user right, password or lockout policy, or audit subcategory; the step names the GPO when Windows reports it. Make the change in that GPO. A host that is not in a domain, or a value only the local policy sets, is never shown as overridden.
The agent compares the GPO's value with the one the control sets. The same value is not an override: the domain already enforces the setting ("enforced by domain policy <GPO>") and the control can be compliant. The agent reports what it knows as gpo_state in the step result: overridden (a domain GPO sets another value, or one the agent could not compare), enforced (a domain GPO sets the same value; gpo_enforced_by names it), clear (no domain GPO sets it, the host is not in a domain, or the change is nothing a GPO sets), or unknown - a domain member whose resultant policy could not be read, usually because Group Policy result logging ("Turn off Resultant Set of Policy logging") is enabled on it, or the query failed (gpo_detection says which). An unknown step has not been checked against domain policy: run gpresult /h on the host, or turn result logging back on and re-apply.
26.7 The hardening report#
A one-click report of what hardening did, for an auditor: per host, per host group or per batch, as PDF, HTML or JSON (the record the other two render). Permission: View hardening; waiver reasons and compensating controls appear only with View compliance too ("Hidden: needs the View compliance permission" otherwise). Four-eyes: no (it changes nothing). Every download is signed with this installation's evidence key - the same key and format as the framework reports (chapter 43) - and audit-logged with its scope, format and SHA-256. A sandbox account reports on sandbox hosts, groups and batches only. Command output in the report (errors, rollback notes, skip reasons) has secrets redacted, as in the framework reports.
Where the buttons are ("Hardening report: PDF | HTML | JSON"):
| Scope | Path |
|---|---|
| One host | Hardening > Planner, open the host: under the host line |
| A host group | Hardening > Host baseline, the group's card (listed and tag members) |
| A batch | Hardening, the Batches list, the batch row (live batches; a dry run changes nothing) |
What it holds:
- Header - the scope, when it was generated and by whom, the Lawliet version, and for a batch who requested and approved it; then one outcome line with every count.
- Score before and after - per host and benchmark. Before: the host's result on the scan the hardening ran from. After: the newest scan of that benchmark measured after the last change. With no such scan it says "Not re-scanned since the last change: scan the host to measure the result" - the report never projects a score. Where a live waiver covers a failing control, a second figure excludes it ("with N waived excluded"); a waived control is never counted as passed.
- Controls applied - only changes Lawliet applied and then validated, and that domain policy did not override or revert, with the time, who requested and who approved ("no second signature recorded" when the run needed none).
- Applied, then overridden or reverted - applied and validated, but a domain GPO overrides it, or a later scan found it changed back: the host does not hold it, so it is not counted as applied.
- Restarts pending - applied, validated only after the host restarts (chapter 56).
- Controls skipped - with the reason in plain words: refusal codes and safety-check ids are shown as their titles (for example "A safety check is not satisfied: Domain replication must be healthy first"), and a waived control reads "Waived until <date> (<reason>)".
- Controls that failed and Controls rolled back (including "rollback failed").
- Original value unknown - rollbacks with no record of the value from before; what Lawliet knows (the current value) and that it must be restored by hand.
- Domain policy - applied changes that domain Group Policy enforces or manages (the local change lasts only while the GPO agrees).
- Safety checks relaxed by Lockdown - for a Lockdown batch, every check it relaxed per control (for example the do-not-disrupt baseline, the audit wait, an accepted lock-out risk). Lockdown's own skips ("no automatic rollback", "would cut the Lawliet agent") are under Controls skipped, marked "Lockdown:".
- Waivers (accepted risk) - every waiver covering a host in scope: live ("Waived until"), requested, revoked or lapsed, with reason, compensating control and approver.
- Still in progress - steps not finished yet.
Procedure: download a hardening report#
- Open the host (Planner), the host group (Host baseline) or the batch (Hardening, Batches).
- Press PDF, HTML or JSON next to "Hardening report".
What you see: the file downloads as lawliet-hardening-report-<scope>-<time>.<pdf|html|json>, with its signature beside it (<file>.sig). The PDF footer and header name the signing key's fingerprint. If it fails: the reason shows next to the buttons ("The report could not be built." and the server's reason). API: GET /api/v1/hardening/report?agent_id=<id> (or group_id, batch_id) &format=pdf|html|json; the signature document comes base64-encoded in the X-Lawliet-Signature response header.
Procedure: verify a hardening report#
- Open Compliance > Frameworks and press Verify (as for a framework report).
- Choose the report file and its
.sigfile.
What you see: valid, or why not ("the file was modified after it was signed", "not signed by this installation's evidence key"). A report signed before the key was rotated still verifies: its download is in the audit log, which is the issuance record. Offline: verify_lawliet_signature.py --public-key KEY.pem FILE FILE.sig.