Backups and ransomware resilience
لم يُترجم بعد؛ يُعرض باللغة الإنجليزية
عن هذا الدرس
No defence stops every attack, so resilient organisations plan to recover. Follow one small shop that backs up its orders file by the 3-2-1 rule, saves a SHA-256 fingerprint with an eleven-line Python program, and keeps one copy offline. Ransomware then encrypts the server and the always-connected backup, but cannot reach the offline vault. Watch the shop isolate, rebuild, restore, check the fingerprint and practise against its recovery point and recovery time objectives (RPO and RTO).
Plan to recover
No defence stops every attack, so resilient organisations plan to recover. A backup is a separate copy of data you can restore from. Our example: a small shop keeps orders.csv on its server, with a network drive (NAS) and an offline vault.
resilience keep working, and recover when
something gets through
backup a separate copy you can restore from
server orders.csv (the primary copy)
NAS network drive, always connected
vault a drive kept offline and off-siteاقرأ الدرس خطوة بخطوة
Plan to recover
No defence stops every attack, so resilient organisations plan to recover. A backup is a separate copy of data you can restore from. Our example: a small shop keeps orders.csv on its server, with a network drive (NAS) and an offline vault.
resilience keep working, and recover when something gets through backup a separate copy you can restore from server orders.csv (the primary copy) NAS network drive, always connected vault a drive kept offline and off-siteThe 3-2-1 rule
A classic rule from US-CERT, now part of CISA: keep 3 copies of important data (1 primary, 2 backups), on 2 different media types, with 1 copy off-site. Here: the server, the NAS, and a vault drive kept elsewhere.
3 copies of important data: 1 primary and 2 backups here: server · NAS · vault 2 different media types here: NAS disks · removable vault drive 1 copy off-site here: the vault, kept away from the shopLines 2–6: save a fingerprint
Lines 2 to 5 define sha(): read a file's bytes and return its SHA-256 digest, a fingerprint that changes if any byte changes. Line 6 saves the fingerprint of orders.csv before the backup: 6d2443d8…
def sha(path) open in binary ("rb"), read the bytes, return SHA-256 as 64 hex characters saved = sha("orders.csv") 6d2443d8289cdf768dccade37c9a423e 053c001a314c414c253704738b9e2db2 (for the example file: order,item,qty / 1001,coffee,2)Lines 7–8: copy, then unplug
Line 7 makes the vault folder; line 8 copies the file into it. The NAS gets a copy over the network too. Then the vault is unplugged: an offline copy has no connection, so nothing on the network can reach it.
os.makedirs("vault", exist_ok=True) ok if it exists shutil.copy2("orders.csv", "vault") bytes + timestamps NAS copy over the network (stays connected) vault copy over a cable, then unplugged = offlineRPO and RTO
Two targets from NIST SP 800-34. Recovery point objective (RPO): the point in time data must be recovered to. Recovery time objective (RTO): how long recovery may take. Backing up nightly means up to 24 hours of changes can be lost.
RPO the point in time to which data must be recovered (how much data you may lose) RTO how long recovery may take before the business is harmed here nightly backup → RPO 24 h · RTO 8 h more frequent backups → smaller RPORansomware locks the server
Ransomware is malicious software that encrypts files and demands payment to unlock them. At 14:00 it lands on the server, often through a stolen password or an unpatched flaw. orders.csv is now unreadable.
ransomware encrypts files, demands a payment (availability lost) common ways in stolen passwords, unpatched flaws, phishing (see the earlier lessons) 14:00 orders.csv → unreadable since 02:00 12 h of new orders exist only hereIt hunts for backups
CISA warns that many ransomware variants find and delete or encrypt any backups they can reach. The NAS is always connected, so its copy is locked too. The vault has no cable: there is no path to it.
reachable backups get locked too NAS connected → locked vault unplugged → untouched also a copy that syncs every change copies the damage (US-CERT: rolling backups propagate corruption)Isolate first
First, contain it. CISA's checklist says to work out which systems are affected and isolate them at once, for example by unplugging them from the network. Then wipe and rebuild the server from clean software before restoring any data.
1 find the affected systems 2 isolate them now (unplug from the network) 3 report it and keep evidence 4 wipe and rebuild from clean software 5 only then restore dataLine 10: restore from the vault
Line 9 marks the incident. Line 10 copies the clean file from the vault back onto the rebuilt server. CISA advises restoring from offline backups, most critical services first. Orders after 02:00 are lost: the RPO in action.
shutil.copy2("vault/orders.csv", ".") vault copy → ./orders.csv (overwrites it) order most critical services first lost orders between 02:00 and 14:00 12 h, inside the 24 h RPOLine 11: check the fingerprint
Line 11 hashes the restored file and compares it with the fingerprint saved at backup time. Equal digests print True: the bytes are exactly what was saved. NIST CSF 2.0 asks for this check (RC.RP-03) before restored data is trusted.
print(sha("orders.csv") == saved) restored 6d2443d8… saved 6d2443d8… output True → the bytes are unchanged False → do not trust this copy; try anotherPractise the restore
A backup is only proven by a restore. CISA says to test backups regularly, and NIST CSF 2.0 says backups are created, protected, maintained and tested (PR.DS-11). Time each practice restore: 3 hours here, within the 8-hour RTO.
PR.DS-11 backups are created, protected, maintained and tested drill restore to a spare machine, check digests, time it: 3 h ≤ RTO 8 h repeat on a schedule, and after big changes
أسئلة سريعة: 5
اختر إجابة واحدة لكل سؤال. يمكنك تغيير اختياراتك قبل التحقق منها.
01A shop keeps its data on a server and one backup on a network drive that is always connected. Which part of the 3-2-1 rule is missing?
3-2-1 asks for 3 copies (1 primary, 2 backups), on 2 media types, with 1 off-site. Here there are only 2 copies, both on site, and the backup is reachable from the network.
02Why did the ransomware in the figure lock the NAS copy but not the vault copy?
CISA warns that many ransomware variants look for backups they can reach and delete or encrypt them. A copy with no connection (offline), or one that cannot be changed (immutable), is out of reach.
03Backups run every night at 02:00. Ransomware strikes at 14:00 and the shop restores the 02:00 backup. How much data is lost?
Everything changed between the last good backup (02:00) and the attack (14:00) is lost: 12 hours. With nightly backups the worst case is about 24 hours, which is the RPO this schedule can meet.
04In the program, what does the last line, print(sha("orders.csv") == saved), prove when it prints True?
Equal SHA-256 digests mean the restored bytes match the saved ones. It says nothing about whether the attacker is gone (that is isolation and rebuilding) or how long recovery took (that is the RTO).
05Which practice shows a backup will actually work when it is needed?
CISA says to test backups regularly, and NIST CSF 2.0 (PR.DS-11) says backups are created, protected, maintained and tested. Only a real restore proves the data is usable and shows how long recovery takes.
المسرد
- Resilience
- The ability to keep working through an incident and to recover afterwards, because no defence stops every attack.
- Backup and 3-2-1 rule
- A backup is a separate copy of data you can restore from. The 3-2-1 rule: keep 3 copies (1 primary, 2 backups), on 2 different media types, with 1 copy off-site.
- Offline and immutable backups
- An offline backup has no connection to the network except while a copy is made. An immutable backup cannot be changed or deleted for a set time. Both keep a copy out of an attacker's reach.
- Ransomware
- Malicious software that encrypts an organisation's files and demands payment to unlock them. Many variants also look for backups they can reach and delete or encrypt them.
- RPO (recovery point objective)
- The point in time to which data must be recovered after an outage (NIST SP 800-34). In practice: how much recent data you can afford to lose. Backup frequency sets it.
- RTO (recovery time objective)
- How long a system can be in recovery before the business is harmed (NIST SP 800-34). Restore drills show whether it can be met.
- SHA-256 fingerprint
- The 64-hex-character digest of a file. If any byte of the file changes, the digest changes, so comparing digests shows whether a restored file is identical to what was saved.
- Isolation
- Cutting affected systems off from the network, for example by unplugging them, so an incident cannot spread. CISA lists it as one of the first response steps.
الملاحظات والمصادر
- The times are one worked example, not a standard: a nightly backup at 02:00, an attack at 14:00, an RTO of 8 hours and a 3-hour drill. Real targets come from how much loss and downtime each business process can bear.
- Offline is one way to keep a copy out of reach. CISA also mentions immutable cloud storage (copies that cannot be changed or deleted for a set time) and cloud-to-cloud backups; each still needs testing.
- A fingerprint saved next to the backup can be changed by whoever can change the backup. Keep the saved digests somewhere separate and protected, and encrypt backups, as CISA and OWASP advise.
- The program runs as is with Python 3 next to a file called orders.csv. Real backup tools add schedules, many versions, encryption and logs; the idea is the same.
- This course is about defence. Ransomware is described only by what it does to data; the lesson never shows how to attack a system.
- CISA and MS-ISAC: #StopRansomware Guide
- US-CERT (CISA): Data Backup Options (Ruggiero and Heckathorn, 2012)
- NIST SP 800-34 Rev. 1: Contingency Planning Guide for Federal Information Systems
- NIST CSRC Glossary: recovery point objective
- NIST CSRC Glossary: recovery time objective
- NIST CSWP 29: The NIST Cybersecurity Framework (CSF) 2.0
- NIST IR 8374: Ransomware Risk Management, a Cybersecurity Framework Profile
- NIST SP 1800-11: Data Integrity, Recovering from Ransomware and Other Destructive Events
- OWASP Database Security Cheat Sheet
- NIST FIPS 180-4: Secure Hash Standard
- Python docs: hashlib
- Python docs: shutil.copy2
اختبار يتاح بعد الخطوة الأخيرة.