The right address, the wrong bank
Aisha types her bank's address correctly. The page looks perfect. She logs in. A week later, her money is gone.
She never clicked a bad link. The attack happened on the road between her phone and the bank.
Four attacks work on the way. They are a changed address book, a person in the middle, an open Wi-Fi hotspot and a data door with no lock. By the end of this lesson: I can match each of these attacks to its fix.
Key words
| Word | What it means | Example |
|---|---|---|
| Network | Computers and devices joined to share data. | The college Wi-Fi |
| Router | A device that joins networks and sends data the right way. | A home router |
| DNS | Domain name system: it turns a name into an IP address. | Like an address book for the internet |
| IP address | A number that names a device on a network. | 203.0.113.5 |
| Man-in-the-middle | An attacker between two sides who reads or changes what they send. | A fake Wi-Fi hotspot |
| Encryption | Scrambling data so only the right people can read it. | HTTPS |
| HTTPS | Encrypted web traffic, shown by https and a padlock. | A bank site |
| API | A door that lets one program ask another for data. | A weather app asking a server |
| API key | A secret code that proves who is asking an API. | A long string of letters |
| Impact | The bad thing that happens after an attack. | stolen money |
| VPN | Virtual private network: a private, encrypted tunnel across the internet. | Used on public Wi-Fi |
The cells students fill in are left blank in this preview.
Quick check: on the way
Have a go
Quick check: on the way
3 questionsDNS attacks: a changed address book
Your phone asks DNS: "What is the number for mybank.com?" DNS answers with a number.
In a DNS attack, the attacker changes the answer, so the number points to a fake site. The traffic is sent to the wrong place (redirected). The fake page looks the same and steals your password.
Impact: stolen logins and money. Fixes: use a trusted DNS service, check for the padlock, and keep your router updated.
Try it: an address book that is changed
address_book = {"mybank.com": "203.0.113.5", "news.com": "203.0.113.9"}
print("Before:", address_book["mybank.com"])
# The attacker changes one line. Now the name leads to a fake site.
address_book["mybank.com"] = "198.51.100.66"
print("After:", address_book["mybank.com"])
# Same name, different place. The user sees no difference.
Make a free account to save your work and track your progress.
A stranger sits between you and the bank
In a man-in-the-middle attack, the attacker sits between you and the bank. You think you talk to the bank. The bank thinks it talks to you. The attacker reads, and may change, every message.
Impact: stolen passwords, changed payments. Fixes: use HTTPS, so the messages are scrambled. Do not click past a warning. Use a VPN on a network you do not trust.
Put the attack in order
Have a go
Put the attack in order
3 questionsAnyone can join and watch open Wi-Fi
Open Wi-Fi has no password. Anyone can join. Other people on it may watch the traffic, and attackers may set up fake copies of it.
Impact: stolen data and fake sites. Fixes: put a strong password on your own Wi-Fi. On a public network, only use HTTPS sites and a VPN, and do no banking.
An insecure API is an unlocked door
An API is a door that lets programs ask for data. An insecure API has no lock, or a weak one.
Anyone who finds the address can ask for all the customer records. An API key proves who is asking. Impact: a large leak of data. Fixes: require a key for every request. Limit what each key may do. Switch off keys that are lost.
Try it: an API with a lock
valid_keys = ["k-1111", "k-2222"]
customers = ["Aisha", "Tom", "Mei"]
def ask(key):
if key in valid_keys:
return customers
return "denied"
print(ask("k-1111"))
print(ask("guess"))
# Remove the if line and see what a stranger gets.
Make a free account to save your work and track your progress.
Four attacks at a glance
| Attack | What happens | Impact | Fix |
|---|---|---|---|
| DNS attack | A name leads to a fake address | Stolen logins | Trusted DNS, padlock check, updated router |
| Man-in-the-middle | An attacker sits between two sides | Read or changed messages | HTTPS, VPN, obey browser warnings |
| Open Wi-Fi | Anyone can join and watch | Stolen data | Password on Wi-Fi, VPN, avoid banking |
| Insecure API | No lock on a data door | Large data leak | API keys, limits on each key |
The cells students fill in are left blank in this preview.
Match the attack to its best fix
Have a go
Loading…
Your answers are marked here and are not kept. A college account keeps every student’s marks.
Your turn: lock the door
Write two functions. api_reply gets a key, the list of valid keys and some data. It gives back the data when the key is valid, and "denied" when it is not. wifi_advice gets two True or False values: does the network have a password, and does the site use https. Give back "safe" if both are true, "careful" if one is true and "avoid" if neither is. Press Run Tests to check.
def api_reply(key, valid_keys, wanted):
# An API holds some data. It must only answer a caller with a valid key.
# Give back the data in wanted if key is in valid_keys.
# If not, give back the word "denied".
return ""
def wifi_advice(has_password, uses_https):
# Give back one word of advice for a person on a Wi-Fi network:
# "safe" if the network has a password AND the site uses https
# "careful" if only one of the two is true
# "avoid" if neither is true
return ""
Make a free account to save your work, or press Start lab to work through the whole lesson.
Key words crossword
Have a go
Loading…
Your answers are marked here and are not kept. A college account keeps every student’s marks.
Final check
Have a go