Skip to content

Why protect systems

Exercise why-protect-systems-annex.pdf · PDF

Friday, 12 May 2017. In England, ambulances are sent to other hospitals because the computers of some public hospitals have stopped working. In Madrid, Telefónica tells its staff to switch their PCs off. Nobody chose those hospitals as a target. So why were they hit?

"Nobody will attack us, we are too small" is the most expensive sentence in computing. Tramuntana Apps is a 12-person studio in Palma, and its office server now holds shares, a Git service and every employee's account. This page is about what can go wrong with it — attacks and accidents — and how you decide what to protect first.

What you will learn

  • Define confidentiality, integrity and availability, and say which one an incident hit
  • Tell a threat from a vulnerability and from a risk
  • Learn from five real incidents why "nobody will attack us" is wrong — and why not every incident is an attack
  • Name the control that would have reduced each incident
  • Read a hardening checklist and audit your own server with read-only commands
  • Why "updates are dangerous" and "we have backups, we are safe" are both traps

WannaCry: the update existed 59 days before

  • 14 March 2017. Microsoft publishes a security update, MS17-010. It fixes a flaw in SMB version 1 — the file-sharing protocol behind Samba shares, port 445.
  • April 2017. A group calling itself the Shadow Brokers leaks a tool that uses that flaw, EternalBlue. It had been written by the NSA, the United States intelligence agency.
  • Friday 12 May 2017. A program called WannaCry starts to spread. It is ransomware: it encrypts your files and asks for money, here 300 dollars in bitcoin. And it is a worm: it needs no click. It finds the next Windows machine with port 445 open and no update, and jumps.
  • The same day. More than 200,000 computers in about 150 countries. Telefónica tells its staff in Madrid to switch their computers off; hospitals of England's public health service (NHS) divert ambulances, and about 19,000 appointments are cancelled in the following days.
  • That afternoon. A British researcher, Marcus Hutchins, sees that the program asks for a web address that does not exist, and registers it. The program was written to stop if that address answers: a kill switch, found almost by accident. The spread slows down.

Ransomware is malware that locks (encrypts) your files and demands a payment. A worm is malware that spreads by itself from machine to machine, with no human help.

Nobody had to be a genius to be safe on 12 May. They had to have pressed "update" in March.

Careful: hackers do not only attack big companies

A worm does not choose. It tries every door. Automatic attacks scan the whole Internet, and a 12-person studio in Palma is one more address.

Three things to protect: the CIA triad

Go back to the kitchen of Unit 1 — now it is a restaurant with a secret recipe. Three different things can go wrong.

In the restaurant On the Tramuntana server
Confidentiality: only the right people can read it The recipe leaves the kitchen joan reads the salaries in admin
Integrity: nobody changed it without permission Someone changes "5 g of salt" to "50 g" A file in dev is altered or half-written
Availability: it is there when you need it The kitchen is closed at dinner time The share does not answer on Monday morning

The three initials make the CIA triad. Nothing to do with the spy agency.

Try it: a stolen laptop with the client list (C) · a power cut (A) · a student changes his mark in the database (I) · WannaCry (A: the files are still there, but nobody can use them) · a disk dies and there is no backup (A, then I).

Careful: security is not only about hackers

Two of the five cases below have no attacker at all. A mistake or a bad update breaks availability just as well.

Five case files

Case What happened Hit Attack? Weak point Would have helped
WannaCry, 12 May 2017 A worm spreads through port 445 and encrypts files A Yes Update not installed; port 445 reachable Updates; firewall; backups
Ajuntament de Calvià, 13 January 2024 The LockBit 3.0 group encrypts the town council's systems and demands 10 million euros. The council refuses to pay and rebuilds A Yes A vulnerability in one of the council's systems Updates; network split into zones; backups
Equifax, 2017 A fix for a flaw in Apache Struts is published on 7 March. One system is missed. Attackers copy the data of about 147 million people C Yes Fix available, not applied Updates; watching the logs
GitLab.com, 31 January 2017 A tired engineer deletes a folder on the main database server instead of the copy: about 300 GB gone. None of the backups works properly; six hours of data are lost A, I No A tired person, a command on the wrong server; backups never tested Tested backups; least privilege
CrowdStrike, 19 July 2024 A security company sends a faulty automatic update. About 8.5 million Windows computers show a blue screen and cannot start A No An update sent to everybody at once Updating in stages; a recovery plan

Calvià is our own town: many of the council's services stopped while it rebuilt its systems.

Two lessons from the table:

  • Updates appear on both sides. Not updating sank Equifax and the WannaCry victims; an update sank 8.5 million PCs. So: update, but keep a way back (snapshots).
  • A backup only counts if a restore has been tried. GitLab had several backup mechanisms, and none worked that night.

Ransomware also steals now

Ransomware first locks files: availability. Modern gangs often copy the files before encrypting them and threaten to publish them: confidentiality too.

Threat, vulnerability, risk, control

Stay in the restaurant.

Word Meaning In the restaurant
Threat What could cause harm A thief, a fire, a clumsy cook
Vulnerability The weak point a threat would use The back door does not lock
Risk How likely × how bad Door on a busy street + the till inside = high
Control What you do to lower the risk Fix the lock; empty the till at night

You cannot remove threats. You remove vulnerabilities and add controls. And you never rely on one control: defence in depth means several layers — a lock, an alarm and insurance — so that if one fails the next still stands.

flowchart LR
    T["<b>Threat</b><br>a worm scanning<br>the Internet"] -->|"uses"| V["<b>Vulnerability</b><br>port 445 open,<br>no update"]
    V -->|"likely × bad"| R["<b>Risk</b><br>files encrypted"]
    C["<b>Controls</b><br>update · firewall · backup"] -->|"lower"| R

The hardening checklist

Hardening means making a system harder to break: removing what it does not need and closing what is open by default.

  1. Updates installed, and automatic for security fixes.
  2. Only the services you need are running; only their ports are open.
  3. A firewall that denies by default.
  4. Remote access with keys, not passwords; no direct root login.
  5. Least privilege: few administrators; folders open to groups, not to everybody.
  6. Strong passwords and a lockout policy.
  7. Backups that follow the 3-2-1 rule and have been restored once.
  8. Somebody reads the logs — or a program does.

Each line answers at least one case file. Line 1: WannaCry, Equifax. Line 7: GitLab. Line 3: WannaCry again.

Audit your own server

Now look at ubu-srv (ssh srv) with read-only commands. Today you change nothing: you only look, write what you find and mark OK or RISK. The checks are on the Exercise sheet.

Check Command What to look for
Updates sudo apt update then apt list --upgradable Pending packages, especially security ones
Open ports sudo ss -tlnp Can you name the service behind every port?
Firewall sudo ufw status Status: inactive is a RISK
SSH The sshd -T line below passwordauthentication no; permitrootlogin no or without-password
Administrators getent group sudo Only your own account
Shares ls -ld /srv/samba/* Can "others" (the last three letters) enter any folder?
Backup — Where is the last backup of /srv/samba? From which day?
Failures systemctl --failed Any failed service

The SSH check prints the settings the SSH server is really using, filtered to the two that matter:

sudo sshd -T | grep -Ei 'passwordauth|permitroot'

What a typical project server shows: port 22 (SSH), 139 and 445 (Samba), 2049 and 111 (NFS), 631 (printing), 8080 and 2222 (Tramuntana Git). The database, port 5432, is not in the list, because the compose file gives it no ports line: that is a good finding. The firewall is inactive, and almost nobody has a backup of the server — the top risk for most.

Finish by ranking your three biggest risks, the worst first, with what you will do about each. The next page fixes them.

Key takeaways

  • The CIA triad: confidentiality (only the right people read it), integrity (nobody changed it), availability (it is there when needed).
  • WannaCry (12 May 2017) hit more than 200,000 computers through an SMB flaw fixed 59 days earlier: automatic attacks do not choose their victims.
  • Not every incident is an attack: GitLab (a mistake) and CrowdStrike (a bad update) broke availability with no attacker.
  • A threat uses a vulnerability; risk is how likely × how bad; controls lower it, in layers (defence in depth).
  • Hardening: update, close what you do not need, deny by default, keys not passwords, least privilege, tested backups, read the logs.
  • Update with a way back, and a backup only counts if a restore has been tried.

Quick check

1. joan, from design, manages to read the salaries in the admin share. What was broken?
  • Confidentiality
  • Availability
  • Integrity
  • Nothing, because he works in the company

Confidentiality means only the right people can read the data. Working in the company is not enough: the salaries are for admin only.

2. Why did WannaCry reach more than 200,000 computers in one day?
  • It spread by itself to machines without an update that existed since March
  • Thousands of people opened the same infected email
  • The passwords of those computers were weak
  • Antivirus programs had been switched off that day

WannaCry was a worm: no click needed. It jumped to any Windows machine with port 445 open and without MS17-010, published on 14 March 2017.

3. Which case shows that an incident does not need an attacker?
  • GitLab 2017
  • WannaCry 2017
  • Equifax 2017
  • Calvià 2024

At GitLab a tired engineer ran a delete command on the wrong server, and the backups failed. No attacker, still a serious loss of availability and integrity.

4. The database port is open to the whole network. That is...
  • A vulnerability
  • A threat
  • A control
  • A risk

It is a weak point a threat could use: a vulnerability. The threat would be whoever tries to use it; the risk combines how likely and how bad.

5. What does defence in depth mean?
  • Several controls, so that if one fails another still stands
  • Buying the most expensive firewall on the market
  • Hiding the server in the basement of the building
  • Changing every password once a week

Defence in depth layers controls: updates, a firewall and tested backups together. No single control is perfect.

6. After CrowdStrike, a colleague says Tramuntana should stop installing updates. What is the better answer?
  • Keep updating, but with a way back such as a snapshot
  • Agree, because updates cause more incidents than attacks
  • Install updates only once a year, all together
  • Update only the Windows PCs, never the server

Not updating is what sank WannaCry's victims and Equifax. The lesson of CrowdStrike is to update in stages and keep a way back, not to stop.

7. Your audit of ubu-srv shows these findings. Select the two that are risks.
  • sudo ufw status answers Status: inactive
  • There is no backup of /srv/samba anywhere
  • Port 5432 of the database does not appear in ss -tlnp
  • sshd -T shows passwordauthentication no

No firewall and no backup are risks. A database that publishes no port and SSH without passwords are good findings: they are controls already in place.

You have your list of the three worst risks. Next, you install the tools that fix them and evaluate what each one really stops — Basic security utilities.