Fixing Drift Automatically: From Detection to Remediation
Published · Updated
Detection tells you what drifted. Remediation puts it back. This article walks through the loop that connects the two, the benefits and limits of automatic fixes, and a phased way to introduce them.
Why reactive operations don't scale
Picture a typical infrastructure team's morning: alerts come in, tickets pile up, someone logs into the affected servers, investigates, applies a fix, documents the change (if they remember), and moves on to the next fire.
That works with 50 servers and a team of five. It stops working as the fleet grows, spreads across data centers and clouds, and changes daily. Humans can't keep up with every small deviation by hand.
What goes wrong
- Time lag. By the time someone notices a misconfiguration, investigates and fixes it, the system has been exposed for hours, or days over a weekend.
- Human error. Fixes applied at 3 AM after a page are where mistakes happen: the wrong firewall rule disabled, the wrong service restarted.
- Inconsistency. Five engineers fix the same problem five different ways. The fleet becomes a patchwork of "solutions" nobody fully understands.
Adding headcount rarely closes the gap, because the problems grow faster than the team. That is usually when organizations start looking at automated remediation, not because it's fashionable but because manual firefighting has hit a wall.
What automated remediation means
The industry often calls this "self-healing infrastructure": systems that detect, diagnose and correct deviations without waiting for a human. It rests on three principles:
- Continuous checking. Systems are checked against the desired state on a fixed cycle, not only during an annual audit or a quarterly scan.
- Decisions defined in advance. Rules state what "correct" looks like and what to do when a system is wrong, so the response doesn't depend on who is on call.
- Prompt correction. A defined fix is applied as soon as the deviation is found, which shortens the exposure window.
The goal is a fleet that returns to its intended configuration when it drifts, with a record of every correction.
The remediation loop
The loop has five stages:
- Define the desired state. Establish what "correct" looks like through configuration baselines, security policies and compliance requirements. This is the reference point for every check.
- Observe the actual state. Agents or monitoring systems collect the actual configuration of each system on a regular cycle.
- Compare. Compare actual state to desired state and identify the specific differences. This is where you decide whether a change is authorized or is drift.
- Remediate. Apply a predefined corrective action: revert a configuration value, re-enable a service, restore a permission.
- Verify and record. Check again to confirm the fix worked, and log the whole event for the audit trail. If the fix fails, a human needs to see it, with full context.
The loop doesn't stop. It runs on every check cycle, catching issues before they turn into incidents.
Operational benefits
Shorter time to remediation
Manual remediation means someone gets paged, logs in, investigates and fixes. Automated remediation applies the fix on the next check cycle.
Example: A firewall rule that exposes a database port is reverted on the next check, instead of waiting for a human to be paged, investigate and fix it by hand.
Consistency across the fleet
Automated remediation applies the same logic on every system. A fleet of hundreds is handled the same way as a fleet of ten: same command, same outcome.
Example: When a policy changes, the updated rule is checked, and where a fix is defined, applied, on every host in scope, instead of through weeks of manual updates.
Less alert fatigue
When routine drift is fixed automatically, operators aren't paged for every minor deviation. Alerts can be reserved for problems that need human judgment.
Example: Instead of waking the on-call engineer because someone stopped auditd on a test server, the service is re-enabled and the event is logged for morning review.
A steadier compliance posture
Continuous checking means you know your compliance state between audits, not just during them.
Example: PCI DSS requires logging of access to cardholder data. If log forwarding stops, a check with a defined fix can detect it and restore it, and the record shows when it failed and when it was fixed.
Security benefits
- Restoring disabled controls. When someone stops auditd or switches SELinux to permissive, a remedy can turn it back on and the history shows it happened.
- Catching privilege changes. Unauthorized changes to sudoers, SUID binaries or PAM configuration can be detected and, where a safe fix exists, reverted.
- Checking update policy. Checks can confirm that update and patch settings match policy, so gaps in your patching process show up. (Applying patches is a job for your patch-management tooling.)
- Spotting persistence. Attackers often persist through cron jobs, startup scripts or kernel modules. Checks for unexpected entries make these visible; removing them should usually involve a human.
Automated remediation isn't a replacement for incident response. It narrows the window in which a known-bad configuration can sit unnoticed.
How LEA handles remediation
LEA Platform builds this loop around rules and keeps every decision on the server:
- Checks on every cycle. Each rule has a check cycle (for example, every hour). The agent runs the rule's read-only validation command and sends the raw output to the server. The server decides pass or fail; the host never grades itself.
- Remedies are opt-in, per rule. A rule can include a
remedycommand for each OS and distribution. Rules without a remedy only report, which gives you detection-only mode by default. - Fix, then re-check. When a validation fails and the rule has a remedy, the server sends the remedy to the agent. The agent runs the remedy, then runs the validation again, and reports both results together.
- Remedy history. Remedy attempts are stored as their own result type, so you can see what was fixed, where, when, and whether the re-check passed.
- Readable rules. Rules are JSON: a validation command, the expected result, an optional remedy, tags and severity. For example: "if
net.ipv4.ip_forwardis not 0, runsysctl -w net.ipv4.ip_forward=0and check again." - Stage with groups. Assign a rule with a remedy to a test group first, then widen the group once you trust the fix.
- Notifications. Email, Slack, Microsoft Teams and webhooks (ServiceNow, Jira, PagerDuty and more) tell your team about compliance changes.
- Agentless option. If you already run Ansible or AWX, a gateway playbook can fetch rules and post results over SSH.
LEA runs on Linux, macOS and Windows hosts and is self-hosted on your own servers.
Rolling out automated remediation: best practices
- Start with detection only. Monitor and alert without automatic fixes. This builds confidence in the checks and surfaces false positives.
- Test remedies thoroughly. Validate that each remedy works in every scenario you can think of before enabling it, and make it idempotent: running it twice must have the same effect as running it once.
- Roll out gradually. Enable remedies on non-critical systems first and expand to production as confidence grows.
- Keep humans in the loop. Log every remediation, and make sure people can override or disable a rule quickly.
- Keep refining. As your environment changes, update rules to match new requirements and infrastructure.
Where this leaves you
As infrastructure grows more complex, fixing every deviation by hand doesn't scale. Automated remediation, introduced carefully and with a full record, lets teams spend less time on repeat configuration fixes and more time on the work that needs judgment.
LEA Platform produces evidence; certification is granted only by an accredited auditor.
Try LEA Platform on your own servers:
Start a free POC