A2.4 · Book pp. 144–165
Network security
No single tool keeps a network safe. Real protection comes from layers, so that one failure does not become a disaster.
What you need to know
| Point | Topic | Level |
|---|---|---|
| A2.4.1 | The effectiveness of firewalls | SL + HL |
| A2.4.2 | Common network vulnerabilities | HL |
| A2.4.3 | Common network countermeasures | HL |
| A2.4.4 | Encryption and digital certificates | SL + HL |
⚠️ Use this responsibly
Only test systems that you own or have permission to test. Trying these ideas on real networks, including the school’s, can be illegal.
A2.4.1 Firewalls
A firewall inspects packets and filters them using rules. Allow lists and deny lists hold IP addresses or ranges, and often port numbers. Each packet is checked against the rules until one matches.
Stateful inspection tracks active connections, so packets in an allowed connection can keep flowing until it closes. Firewalls also log traffic, which helps to detect suspicious activity.
Limits of firewalls
- They are weak against insiders, or attackers who get onto the internal Wi-Fi.
- Most do not inspect content, so harmful data can reach a legitimate destination.
- Sophisticated attacks can mimic normal traffic.
- They are only as good as their configuration and updates.
NAT and security
NAT hides internal addresses, which makes internal systems harder to reach directly. It was not designed for security, so treat it as a bonus: security by obscurity, not a defence by itself.
HL A2.4.2 Common vulnerabilities
| Vulnerability | What happens | Countermeasure |
|---|---|---|
| DDoS | Many compromised devices flood a target until it cannot serve real users | Rate limiting, traffic analysis, cloud protection services |
| Insecure protocols | HTTP, FTP and Telnet send data unencrypted | Use HTTPS, SFTP and SSH |
| Malware | Viruses, worms, trojans and ransomware harm devices and spread | Endpoint protection, updates, email filtering, backups |
| Man-in-the-middle | An attacker secretly intercepts or alters traffic | Encrypted protocols, certificates, VPNs |
| Phishing | A fake message tricks a victim into giving away details | Email filtering, training, multifactor authentication |
| SQL injection | Input is run as a database command | Input validation and parameterized queries |
| Cross-site scripting (XSS) | Injected code runs in other users’ browsers | Input validation and a content security policy |
| Unpatched software | Known holes are left open, and updates advertise them | Apply updates quickly |
| Weak authentication | Poor password storage or easily guessed logins | Hashing and salting, multifactor authentication, tested login systems |
| Zero-day exploit | A flaw is attacked before a patch exists | Layered defence, intrusion detection, regular testing |
✍️ Try it safely on your own computer
This Python uses a temporary database in memory.
import sqlite3
db = sqlite3.connect(":memory:")
db.execute("CREATE TABLE users (name TEXT, secret TEXT)")
db.execute("INSERT INTO users VALUES ('mali', 'blue-42')")
typed = "x' OR '1'='1"
# Unsafe: the input becomes part of the command
unsafe = "SELECT * FROM users WHERE name = '" + typed + "'"
print(db.execute(unsafe).fetchall()) # every row!
# Safe: the input is only ever data
print(db.execute("SELECT * FROM users WHERE name = ?", (typed,)).fetchall()) # [] HL A2.4.3 Countermeasures
| Countermeasure | What it does |
|---|---|
| Content security policy | An HTTP header listing the allowed sources of content |
| Password policies and passkeys | Longer passwords, fewer of them, and passkeys that use biometrics, a PIN or a pattern |
| DDoS mitigation | Rate limits, traffic analysis and cloud services |
| Email filtering | Scans for malicious attachments, phishing and spam |
| Encrypted protocols | HTTPS, SFTP and SSH instead of HTTP, FTP and Telnet |
| Input validation | Presence, length, type and format checks |
| IDS and IPS | An intrusion detection system watches and alerts. An intrusion prevention system also blocks |
| Multifactor authentication | Two of: something you know, have or are |
| TLS certificates | Prove a website’s identity and support encryption |
| Software updates | Apply security patches as soon as possible |
| VPNs | Encrypted remote access to a private network |
| Testing and training | Penetration tests, assessments and regular staff training |
| Wireless security | Strong encryption, plus a MAC allow-list as a basic extra step |
| Secured backups | Regular, encrypted copies kept away from the main system |
✏️ Book note
The book lists MAC allow-lists as a wireless measure. Remember that MAC addresses can be copied, so this only adds a little friction. Use it alongside strong Wi-Fi encryption.
⚠️ Common mistake
“Install anti-malware” or “use encryption” is too vague for full marks. Match a specific countermeasure to the specific threat and say how it helps.
A2.4.4 Encryption and digital certificates
Encryption turns data into a form that unauthorized people cannot understand. A key is the value fed into the algorithm.
| Symmetric | Asymmetric | |
|---|---|---|
| Keys | One shared key | Public key encrypts, private key decrypts |
| Speed | Fast, good for large files | Much slower |
| Problem | Sharing the key safely | Proving a public key is genuine |
| Used for | The bulk of a session | Agreeing a symmetric key, and signing |
Diffie-Hellman key exchange
Two people can agree a secret in public. Think of mixing paint: combining colours is easy, but unmixing them is almost impossible.
✏️ Book correction
The book says Diffie-Hellman relies on the difficulty of finding prime factors. That is RSA. Diffie-Hellman relies on the discrete logarithm problem: from the public result, it is very hard to work out the secret exponent.
Digital signatures
The sender hashes the data, then encrypts the hash with their private key. The receiver decrypts it with the public key and compares it with their own hash. This proves who sent it and that it was not altered. The sender cannot later deny it, which is called non-repudiation.
Digital certificates
Encryption is little use if you are talking to an imposter. A certificate links a public key to an identity.
- The bank generates a key pair and keeps the private key secret.
- It sends the public key to a certificate authority (CA).
- The CA checks the identity, then signs the certificate with the CA’s private key.
- Browsers already trust the CA, so they can verify that signature with the CA’s public key.
Key pairs also allow SSH login without passwords. Your private key works like a password, so it must be stored safely.
✏️ Book corrections
- The book warns against mixing up signatures and certificates, then says certificates are part of cryptocurrency. Blockchains use digital signatures and hashes, and usually no certificates.
- It describes TLS certificates as a way for developers to sign software. That is code signing. A TLS certificate identifies a website.
- “SSL” is the older name. Current systems use TLS.
Optional project: a Raspberry Pi network
Build a small network as a class, using a separate network from the school’s. Each group runs one role on a Raspberry Pi.
| Role | Software | Task |
|---|---|---|
| Router and firewall | nftables | Turn on IP forwarding, then allow only HTTP, HTTPS and established traffic |
| Wireless access point | hostapd | Create a network with a strong passphrase |
| DHCP server | isc-dhcp-server | Give out 192.168.1.10 to 192.168.1.100, with fixed addresses for servers |
| Web server | nginx | Host a page from /var/www/html |
| Proxy server | squid | Cache pages and block a test URL |
| DNS server (optional) | bind9 | Create a local domain such as myhome.local |
✏️ Book note
The book gives the default login as pi / raspberry. Current Raspberry Pi OS makes you create your own user when you set it up. Follow the official guides for each tool, since settings change between versions.
Quick quiz
HL Extra questions
Exam-style questions
These are written for this site in the style of Paper 1. Answer on paper first, then open the mark points.
-
Discuss whether a firewall alone is enough to protect a company network. [3]
Mark points
- A firewall filters traffic by addresses and ports [1].
- It may not inspect content, so malicious data to a legitimate destination can pass [1].
- It does not stop insiders, so other measures are needed as well [1].
-
Distinguish between symmetric and asymmetric encryption. [3]
Mark points
- Symmetric encryption uses one shared key [1].
- Asymmetric uses a public key to encrypt and a private key to decrypt [1].
- Symmetric is faster, while asymmetric solves the problem of sharing a key [1].
-
Describe how NAT contributes to network security. [2]
Mark points
- It replaces internal addresses with a public one [1].
- So attackers cannot see or directly reach internal devices [1].
-
Explain how a web browser can trust a bank’s website. [4]
Mark points
- The bank obtains a certificate from a certificate authority [1].
- The CA verifies the bank and signs its public key with the CA’s private key [1].
- The browser verifies that signature using the CA’s public key [1].
- So it knows the public key belongs to the bank, not an imposter [1].
-
Explain how a digital signature proves a document has not been changed. [3]
Mark points
- A hash of the document is encrypted with the sender’s private key [1].
- The receiver decrypts it with the public key and hashes the document [1].
- If the two hashes match, it has not been altered [1].
HL Exam-style questions
-
Describe SQL injection and its effect on a website. [3]
Mark points
- The attacker enters SQL commands into an input field [1].
- Unvalidated input is joined into a query and executed [1].
- Data can be read, changed or deleted [1].
-
Describe one vulnerability and a matching countermeasure for each of phishing and unpatched software. [4]
Mark points
- Phishing tricks users into revealing details [1].
- Staff training and email filtering reduce this [1].
- Unpatched software has publicly known flaws [1].
- Applying security updates promptly closes them [1].