A shop's leak becomes a college's problem
An online shop is breached and its customers' emails and passwords are posted on a forum. A week later, a college's sign-in page gets thousands of attempts, each a different account, each tried once.
Nobody guessed anything. The attacker is betting that people used the same password at the shop and at college.
By the end of this lesson
Note
I can recognise credential stuffing in a sign-in log and choose defences that stop it.
Key words
| Word | What it means |
|---|---|
| Combo list | leaked pairs of email and password |
| Reuse | one password on more than one site |
| Throttling | refusing sign-ins after too many failures |
| Lockout | blocking one account after failures |
| Breached-password check | refusing a password seen in a leak |
| Failure ratio | failed sign-ins out of all sign-ins |
The cells students fill in are left blank in this preview.
Starter
Have a go
Starter
4 questionsThe rule for this lesson
Warning
Attack only your own lab's site. Its accounts, addresses and leaked list are made up, and your copy has no way out to the internet. Replaying leaked passwords against a real site without written permission is a crime under the Computer Misuse Act 1990.
Stuffing replays pairs leaked elsewhere
A combo list holds pairs leaked from other sites. A stuffing tool tries each pair once, spread over many addresses, often through hired proxies. Most fail, because most people's accounts are elsewhere or use a different password.
The few that work are reuse. Neither the password's length nor the site's hash helps, because the attacker already has the password.
Look at the leaked list
docker exec john head -3 combos.txtShown here, not run. Press Start lab to type it into your own lab’s terminal.
Replay the list against your site
docker exec john python3 steps/stuff.pyShown here, not run. Press Start lab to type it into your own lab’s terminal.
Worked example: the first replay
| What stuff.py printed | What it means |
|---|---|
| pairs tried: 30 | Every pair once |
| wrong 28 | Most pairs fail |
| ok 1, [email protected] | ben reused Liverpool1: the account is taken |
| need-code 1, [email protected] | amira reused sunshine, but her second factor held |
The cells students fill in are left blank in this preview.
Check
Have a go
Check
3 questionsThe log shows the pattern
Every attempt is a line in the site's log. One person who forgot a password fails a few times on one account. A stuffing run fails on many different accounts, from each address, nearly every time.
So count, per address, the attempts, the failures and the distinct accounts tried. A high failure ratio across many accounts is the signature.
Summarise the log by address
docker exec site python3 report.pyShown here, not run. Press Start lab to type it into your own lab’s terminal.
Read the last three log lines
docker exec site tail -3 site.logShown here, not run. Press Start lab to type it into your own lab’s terminal.
Check
Have a go
Check
3 questionsTry it: failures per address
# Failed sign-ins per address, and how many accounts each tried.
tried = {"10.9.0.11": [4, 4], "10.0.0.5": [3, 1]}
for address in tried:
failed = tried[address][0]
accounts = tried[address][1]
print(address, failed, "failed across", accounts, "accounts")
# Add a third address that failed 1 time on 1 account, then press Run.
Make a free account to save your work and track your progress.
Throttling alone does not stop it
Throttling refuses an address or an account after 5 failures. Stuffing tries each account once from 8 addresses, so neither limit is reached and ben is still taken. Sent from one address, the same run is throttled after 5 failures.
The breached check works differently: a correct password that is on a leaked list is refused until it is changed.
Switch throttling on
docker exec site python3 policy.py throttle onShown here, not run. Press Start lab to type it into your own lab’s terminal.
Replay over 8 addresses again
docker exec john python3 steps/stuff.pyShown here, not run. Press Start lab to type it into your own lab’s terminal.
Start the failure counts again
docker exec site python3 policy.pyShown here, not run. Press Start lab to type it into your own lab’s terminal.
Replay from one address
docker exec john python3 steps/stuff.py oneShown here, not run. Press Start lab to type it into your own lab’s terminal.
Switch the breached check on
docker exec site python3 policy.py breached onShown here, not run. Press Start lab to type it into your own lab’s terminal.
Replay with the breached check on
docker exec john python3 steps/stuff.pyShown here, not run. Press Start lab to type it into your own lab’s terminal.
A common mistake
Warning
Many people think locking an account after five failures stops credential stuffing. Stuffing tries each account once, so a lockout never fires; it mostly locks out real people. Use breached-password checks and MFA, and throttle by address as one layer.
The fix, and how to detect it
Fix: check passwords against breached lists at sign-up and sign-in, ask for MFA, and throttle by address with a bot check when failures climb. Tell users who reused a leaked password to change it.
Detect: alert when one address fails across many accounts, or when the site-wide failure ratio jumps. Watch for many accounts signing in from new places.
Check
Have a go
Check
3 questionsAssignment: find the stuffing
The lab site's log has one line per attempt, such as #4 10.0.0.5 [email protected] wrong: a number, the address, the account and the result. Write three functions. parse(line) returns [address, account, result]. by_source(lines) returns a dictionary from each address to {"attempts": ..., "failed": ..., "accounts": [...]}, where a result of "wrong" or "throttled" is a failure and accounts lists each account once, in the order first seen. suspects(lines, accounts_at_least, failed_share) returns, in sorted order, the addresses that tried at least that many accounts and whose failures divided by attempts are at least failed_share.
def parse(line):
return []
def by_source(lines):
return {}
def suspects(lines, accounts_at_least, failed_share):
return []
Make a free account to save your work and track your progress.
Exit quiz
Have a go