AQA 7517, section 4.9.3.2
Firewalls
A firewall is a security system that sits between a network and the Internet, and controls what traffic is allowed through, according to a set of rules. It may be hardware, software or both.
There are three main methods.
Packet filtering
The firewall examines the header of each packet, and allows or blocks it according to rules about the:
- source and destination IP address;
- port number (such as blocking port 23);
- protocol.
It is fast and simple, but it looks at each packet on its own, and doesn't look at the data, so it can be fooled.
Proxy server
A proxy server acts as a go-between. Internal users send requests to the proxy, which makes the request to the Internet on their behalf and passes back the reply. Outside systems only ever see the proxy's address, not the internal devices.
- It can filter content and block certain sites, and check the data.
- It can cache popular pages to speed up access.
- It hides the internal network.
Stateful inspection
A stateful firewall remembers the state of connections. It keeps a table of the connections that are in progress, and only allows incoming packets that are part of a conversation that an internal device started. An unexpected packet that doesn't belong to a known connection is blocked. It is more secure than packet filtering, as it understands the context.
| Method | Checks | Notes |
|---|---|---|
| Packet filtering | Each packet's header on its own | Fast, but limited |
| Proxy server | Requests are made on behalf of users | Hides the network and can filter content |
| Stateful inspection | Packets in the context of the connection | More secure |
Encryption
Encryption scrambles data so that only someone with the right key can read it (see 4.5.6.10). On the Internet, two types are used.
Symmetric encryption
In symmetric encryption, the same key is used to encrypt and decrypt.
- Fast, so good for large amounts of data.
- The problem is key exchange: the sender and receiver both need the same secret key, but how do you send it securely? If it is intercepted, the encryption is useless. And a separate key is needed for each pair of users.
Asymmetric (public/private key) encryption
In asymmetric encryption, each user has a pair of keys.
- A public key, which can be shared with anyone.
- A private key, which is kept secret by its owner.
What one key locks, only the other can unlock.
To send a secret message:
- The sender encrypts it using the receiver's public key.
- Only the receiver's private key can decrypt it.
- Solves the key exchange problem: the public key can be sent openly, and the private key never leaves its owner.
- It is slower and needs more computing power, so it's not used for large amounts of data.
Key exchange: combining the two
In practice, the two are combined, for example in HTTPS (TLS).
- The browser and server use asymmetric encryption to agree a secret key safely (the key exchange).
- They then use that key for fast symmetric encryption of the actual data for the rest of the session.
This gets the security of asymmetric and the speed of symmetric.
Digital signatures
A digital signature proves who sent a message and that it hasn't been changed.
- The sender makes a hash (a short fixed-size fingerprint) of the message.
- The sender encrypts the hash with their own private key. This is the signature, and is sent with the message.
- The receiver decrypts the signature using the sender's public key, and also calculates the hash of the message received.
- If the two hashes match, the message came from the owner of the private key (authentication) and was not altered (integrity).
Digital certificates
How do you know that a public key really belongs to who it claims? Anyone could pretend. A digital certificate solves this: it is an electronic document that links a public key to the identity of its owner (a person, website or company).
What it contains
- the owner's name (or domain name);
- the owner's public key;
- an expiry date;
- the name of the issuer;
- the issuer's digital signature.
How it is obtained
- The organisation generates a key pair and sends its public key, with details of its identity, to a certificate authority (CA), a trusted organisation.
- The CA checks the identity of the applicant.
- If satisfied, the CA creates the certificate and signs it with the CA's own private key, and issues it.
How it is used
When a browser connects to a secure website (HTTPS):
- The server sends its certificate.
- The browser checks the CA's signature, using the CA's public key (browsers already trust well-known CAs), and checks that the certificate hasn't expired and is for this site.
- If it is valid, the browser trusts the site's public key and starts the encrypted session. If not, it shows a warning.
The same applies to signing: a certificate lets you trust that a signature is from the person who claims it.
Malware: worms, trojans and viruses
| Type | What it is | How it spreads |
|---|---|---|
| Virus | Malicious code that attaches itself to a legitimate file or program, and spreads when that file is run or shared | Needs a user to run the infected file |
| Worm | A self-contained program that copies itself and spreads across networks on its own | Automatically, using network weaknesses, with no user action |
| Trojan | A program that pretends to be useful or harmless but contains something harmful | The user is tricked into installing it. It doesn't copy itself |
Effects can include deleting or stealing data, slowing the system, giving an attacker remote control, or making the computer part of a botnet.
Vulnerabilities they exploit
- Unpatched software with known security flaws.
- Poor code, such as buffer overflows (writing more data than a space can hold) and unchecked input.
- People: opening email attachments, clicking links, or installing software from untrusted sources (social engineering).
- Weak passwords, or open network ports and services that aren't needed.
- Using accounts with more privileges than needed.
Reducing the risk
Improving code quality:
- Validate all input, and check the length of data to prevent buffer overflows.
- Test thoroughly, including security testing and penetration testing.
- Use code reviews and secure coding practices, and keep the code simple.
- Provide updates and patches quickly when problems are found.
Monitoring:
- Intrusion detection systems and logs to spot unusual activity.
- Network monitoring to detect traffic from infected machines.
Protection:
- Antivirus and anti-malware software, kept up to date.
- A firewall.
- Installing updates (patching) promptly.
- Least privilege: users get only the access they need.
- Backups, so that data can be recovered.
- Educating users not to open unknown attachments or links.
Worked example
Task: explain how a customer can safely send their card details to an online shop.
- The browser connects using HTTPS, and the shop's server sends its digital certificate.
- The browser checks that the certificate is signed by a trusted CA, is not expired and matches the site, so it can trust the server's public key.
- Using asymmetric encryption, the browser and server agree a secret session key (key exchange).
- The card details are then encrypted with that key using symmetric encryption, which is fast.
- Anyone who intercepts the data sees only ciphertext.
Exam tip: know that symmetric has one key (fast, but the key must be shared) and asymmetric has a public and private pair (solves key exchange, but slow). Know that a digital signature uses the sender's private key, and a certificate is signed by a CA.
Check yourself
Name the three methods a firewall can use
Packet filtering, proxy server and stateful inspection.
What is the key exchange problem with symmetric encryption, and how does asymmetric encryption help?
Both parties need the same secret key, but sending it safely is hard. Asymmetric encryption can be used to agree or send the key securely, because the public key can be shared openly.
What is the purpose of a digital certificate?
It links a public key to the identity of its owner, so that others can trust that the key belongs to who it says. It is signed by a trusted certificate authority.
What is the main difference between a worm and a virus?
A virus attaches to a file and needs a user to run it. A worm is self-contained and spreads across networks automatically without user action.
Give two ways of reducing the risk from malware
Any two of: keeping software patched; validating input to prevent buffer overflows; antivirus software; a firewall; monitoring; least privilege; backups; user education.