The most common wrong decision after a ransomware attack is going back to the backup right before encryption. The attacker may have been in the network for days, sometimes weeks, and every backup taken during that time also carries their accounts, persistence mechanisms and tools. The last backup isn’t the last clean backup. Below we explain how to build the attack timeline to find the last clean recovery point, how to use malware scanning of backups, IOC and YARA searches and signs of encryption, and how to combine the findings in a decision table.
Why the last backup may not be safe
A backup can be “clean” in three different senses. Don’t confuse them:
- Not encrypted: The data is readable. This is the lowest bar.
- Free of malware: No known malicious files, tools or web shells.
- Free of attacker changes: No accounts, services, scheduled tasks, Group Policy changes or firewall exceptions created by the attacker.
A backup from the day before encryption usually meets the first condition; it often doesn’t meet the second and third. The third is the hardest, because attackers frequently use legitimate administration tools and these changes don’t show up in an antivirus scan. That’s why the recovery point isn’t chosen with a single scan; the timeline and multiple methods are used together.
There’s also a balance between choosing the recovery point and data loss. An older point may be safer from an enterprise cybersecurity standpoint, but the business data in between is lost. The way to strike the balance is to think about the system and the data separately: the operating system and application can be restored from an older, clean point, and the business data from a newer point after scanning. To tie the isolated copy to a working recovery scenario, define the test and verification steps in the design of your backup and disaster recovery infrastructure.
Building the attack timeline
The recovery point decision rests on the best estimate of when the attack began. The timeline is compiled from these sources:
| Source | Trace sought |
|---|---|
| EDR telemetry | The first suspicious process, lateral movement, credential access |
| Domain controller Security log | New account (4720), added to a security group (4728, 4732, 4756) |
| Servers’ System and Security logs | New service installed (System 7045), scheduled task created (Security 4698, if auditing is on) |
| VPN and firewall logs | Successful sign-ins from unusual sources, large outbound data |
| Backup console logs | Job deletions, retention changes, sign-ins |
| Backup job statistics | A sudden increase in incremental backup size |
The earliest reliable trace of the attack in the timeline is the starting boundary of the search. Points before this date are considered “candidate clean”, those after “suspicious”. If log retention is short or the attacker deleted logs, the boundary blurs; then the candidate point is pulled further back and the inspection of the backup gains weight. A problem we often see is the DC Security log rolling over with a capacity of a few days. The trace has long since been overwritten. Monitoring attack signs in the console in advance makes this stage easier; details are in the signs of attacks on backup infrastructure article.
Methods for scanning backups for malware
There are three ways to scan the disks in a backup, and the basic rule is the same for all: the disk is mounted read-only, and scanning is done on a system separate from production and the backup server.
- The backup software’s built-in scanning: The Secure Restore feature in Veeam Backup & Replication mounts disks and scans them with antivirus before restoring. The malware detection and backup scanning features introduced in version 12.1 also cover searching for the last clean recovery point and scanning with YARA rules; verify the scope of the features in the documentation for your version.
- Mounting disks on a scanning server: Using the backup software’s disk publishing or mounting feature, the recovery point is mounted read-only on a Linux or Windows scanning server, and the desired tools are run.
- Opening in an isolated environment: The system is started without a network, and a live scan is done with EDR. This is the most thorough method for persistence checks; the environment design is in the isolated recovery environment article.
The example below mounts an exported virtual disk read-only on a Linux scanning server and scans it with ClamAV. The disk format and partition number vary by environment; check with lsblk. Don’t skip the -o ro parameter.
sudo modprobe nbd max_part=8
sudo qemu-nbd --read-only --connect=/dev/nbd0 /backup/review/srv-app01.vmdk
lsblk /dev/nbd0
sudo mkdir -p /mnt/rp
sudo mount -t ntfs-3g -o ro /dev/nbd0p2 /mnt/rp
sudo clamscan -r -i --log=/review/srv-app01-clam.log /mnt/rp
# When done
sudo umount /mnt/rp
sudo qemu-nbd --disconnect /dev/nbd0
Searching with IOCs and YARA rules
Signature-based scanning may miss custom tools used in the incident or recompiled malware. The indicators obtained during incident response (file hashes, file names, paths, domain names) should be searched for directly in the backup. A hash search is simple but effective:
# ioc-sha256.txt: one lowercase SHA-256 value per line
sudo find /mnt/rp -type f -size -100M -print0 |
sudo xargs -0 sha256sum 2>/dev/null |
grep -F -f ioc-sha256.txt
# Executable files changed within a given time range (example date range;
# timestamps may have been altered by the attacker)
sudo find /mnt/rp -type f \( -iname '*.exe' -o -iname '*.dll' -o -iname '*.ps1' \) \
-newermt '2026-09-20' ! -newermt '2026-10-05'
YARA rules search by string and byte patterns inside files and catch variants of a malware family better than a hash search. Rules can be derived from the incident response team, trusted threat intelligence sources or samples found in the incident. Starting the scan with high-risk paths rather than the whole disk shortens the time:
yara -r -w incident-rules.yar "/mnt/rp/Windows/System32/Tasks" > yara-tasks.txt
yara -r -w incident-rules.yar "/mnt/rp/ProgramData" > yara-programdata.txt
yara -r -w incident-rules.yar "/mnt/rp/Users" > yara-users.txt
If a match is found, the same search is repeated on the previous recovery point. This finds the point where the indicator first appears in the backups; that point either confirms the starting boundary in the timeline or pulls it further back. The second case happens more often than you’d think.
Signs of encryption: entropy and rate of change
Encrypted files look close to random data; Shannon entropy per byte approaches the theoretical upper limit of 8 bits. But compressed formats also show high entropy, so the entropy of a single file isn’t proof. More reliable indicators are:
- Change between recovery points: A sudden rise in entropy between two points for file types that normally have low entropy (plain text, CSV, some database exports).
- Incremental backup size: Mass encryption changes many blocks, and the incremental backup size rises far above its usual level.
- File name and extension changes: Many files getting the same new extension, or a ransom note with the same name in every folder.
- Mass deletion or renaming: Thousands of files disappearing within a short time when file system directories are compared.
These indicators help find the point at which encryption started; they don’t show the attacker’s earlier presence. A point without signs of encryption is only clean at the first level. The rest is separate work.
A recovery point decision table
| Finding | Assessment | Action |
|---|---|---|
| Signs of encryption present | Unusable | Move to an older point |
| IOC or YARA match present | Compromised | Move to before the point where the indicator first appears |
| No match, point after the start of the attack | Suspicious | Restore only data, or check persistence in an isolated environment |
| No match, point before the start of the attack | Candidate clean | Verify in an isolated environment, then use |
| No candidate point at all | No clean point found | Rebuild the system, bring over only scanned data |
Record the decision per system: which recovery point was chosen, which scans were done with which rule and signature versions, what the results were and who approved. This record is needed both for retrospective analysis if reinfection occurs and for post-incident reporting. Two weeks after the incident, nobody remembers what was chosen and why.
Checking for persistence mechanisms
Even a point that comes out clean from malware scanning and IOC searches may contain the attacker’s changes. That’s why, at the candidate clean point, these locations are examined on the mounted disk or in the isolated environment:
- Scheduled tasks: the XML files under
Windows\System32\Tasksand their creation dates. - Services: the
Serviceskey in the SYSTEM registry hive; unknown paths and services running from temporary folders. - Autostart: the
RunandRunOncekeys in the SOFTWARE and user NTUSER.DAT hives, and startup folders. - WMI event subscriptions: the contents of
Windows\System32\wbem\Repository. - Remote access tools: unusual RMM or remote desktop software.
- On domain controllers, Group Policy scripts under SYSVOL and newly created Group Policy objects.
- On Linux servers,
/etc/cron*, user crontabs,/etc/systemd/systemand~/.ssh/authorized_keysfiles.
If suspicion of persistence on domain controllers can’t be fully cleared, stop searching for a recovery point and move to a forest recovery approach; the steps are in the AD forest recovery after a ransomware attack article.
This decision process running quickly during an incident depends on a sufficient immutability period, retained logs and scanning tools prepared in advance. Reviewing readiness is within the scope of our cyber incident response readiness and exercises work, and the backup side within our backup security and ransomware readiness work. The primary source for writing rules is the YARA documentation.
Frequently asked questions
Why isn’t the backup right before encryption considered safe?
Because encryption is the last stage of the attack. The attacker may have got into the network much earlier, created accounts and set up persistence mechanisms such as services or scheduled tasks. The backup before encryption contains these changes too; when you restore it, the attacker’s access comes back as well.
Is a backup that passes an antivirus scan safe?
That alone doesn’t show it. Signature-based scanning catches known malware; it doesn’t see persistence set up with legitimate administration tools, accounts the attacker created or modified configurations. Assess the scan result together with IOC searches, persistence checks and the incident timeline.
Does entropy analysis produce false alarms?
Yes. Compressed and encrypted formats such as zip, jpeg and mp4, or Office documents such as docx and xlsx, naturally show high entropy. Interpret entropy not at the level of a single file but through the expected value for the file type in a folder and sudden changes between recovery points.
What do you do if no clean recovery point can be found?
The system can be restored from the oldest suitable backup and cleaned in an isolated environment, or rebuilt from scratch with only the data brought over from backup. For critical systems such as domain controllers and management servers, if suspicion of persistence can’t be cleared, rebuilding is usually the safer route.