Sub topic 12
Protecting Accounts with Strong Passwords and Multi-Factor Authentication
Prerequisites and scope
This chapter assumes you already use online banking, email, and payment apps, and that you can recognize phishing messages (covered earlier in the tutorial). It focuses on the controls that stop an attacker from taking over an account, even when your password has leaked or you have been tricked once.
Account takeover is the end goal of many scams. A scammer who controls your email can reset the password on your bank, your payment apps, and your online shops. Account security is therefore a defense against fraud itself, not only a technical chore.
How attackers get into accounts
Knowing the attack paths shows which defenses matter.
| Attack | How it works | What stops it |
|---|---|---|
| Credential stuffing | Attackers take email and password pairs leaked from one site and try them on many others. | A unique password for every account. |
| Password guessing | Automated tools try common passwords and variations of known ones. | Long, random passwords and lockout limits. |
| Phishing | You type your password into a fake login page. | Phishing-resistant MFA, a password manager that checks the site, and verification habits. |
| Malware | A keylogger or info-stealer captures passwords and session cookies. | Updated devices, no untrusted software, and MFA. |
| SIM swapping | An attacker convinces your mobile carrier to move your number to their SIM, then receives your text codes. | Non-SMS MFA and a carrier account PIN. |
| Social engineering of support staff | The attacker impersonates you to a help desk and gets a password reset. | Strong account recovery settings and alerts. |
Credential stuffing is the most common route for ordinary people. It works because people reuse passwords. One breach at a small forum can expose the password you also use for your bank.
What makes a password strong
Length and unpredictability matter. Complexity rules, such as "one capital letter and one symbol," matter much less. Attackers test passwords by guessing the most likely candidates first, so a password is weak if a person would plausibly choose it.
Guidelines that hold up:
- Use at least 14 characters for ordinary accounts. Use 16 or more for email and financial accounts.
- Make each password unique. Never reuse one across accounts.
- Prefer randomly generated passwords or passphrases of four to six unrelated words.
- Do not use personal details such as birthdays, pet names, or addresses. Scammers can often find these.
- Do not apply predictable changes such as
Summer2026!followed byAutumn2026!. - Change a password when you have a reason, such as a breach or a suspected compromise. Forced periodic changes tend to produce weaker passwords.
A passphrase such as copper-lantern-orbit-pickle-dune is long and easy to type. A random 20-character string from a password manager is stronger and needs no memory effort, because the manager fills it in.
Why length beats cleverness
Each extra character multiplies the number of guesses an attacker needs. A random 8-character password drawn from about 94 typeable characters has roughly 94^8 combinations. A random 16-character one has 94^16, which is about 94^8 times larger again. A humanly invented password, however, has far fewer real possibilities than its length suggests, because people follow patterns. The following script estimates the search space for random choices. It shows why random generation matters.
import math
import secrets
import string
def entropy_bits(pool_size: int, length: int) -> float:
"""Entropy in bits of a password chosen uniformly at random."""
return length * math.log2(pool_size)
def random_password(length: int = 20) -> str:
"""Generate a random password with a cryptographically secure generator."""
alphabet = string.ascii_letters + string.digits + "!@#$%^&*-_"
return "".join(secrets.choice(alphabet) for _ in range(length))
print(f"8 chars, 94 symbols: {entropy_bits(94, 8):.0f} bits")
print(f"16 chars, 94 symbols: {entropy_bits(94, 16):.0f} bits")
print(f"Five random words from a 7776-word list: {entropy_bits(7776, 5):.0f} bits")
print("Example:", random_password())The output shows about 52 bits for 8 characters, 105 bits for 16 characters, and 65 bits for five random words. These figures apply only when the choice is truly random. The script uses secrets, not random, because random is not designed to resist prediction.
Password managers
A password manager is an app that stores your passwords in an encrypted vault, generates new ones, and fills them in for you. You remember one strong master passphrase, and the manager handles the rest.
Benefits for fraud prevention:
- It makes unique passwords practical. Without one, most people reuse.
- It fills credentials only on the matching website address. If you land on a lookalike domain, the manager usually does not offer your login. That silence is a warning sign.
- It can flag reused, weak, or breached passwords.
Set it up carefully:
- Choose a reputable manager, either built into your operating system or a well-reviewed standalone product.
- Create a long master passphrase that you use nowhere else.
- Turn on MFA for the manager itself.
- Save the recovery information (a recovery key or code) offline, for example printed and stored in a safe place.
- Move your most important accounts first: email, banking, payment apps, and mobile carrier.
Multi-factor authentication
Multi-factor authentication (MFA) requires two or more kinds of proof before you log in. The kinds are something you know (a password), something you have (a phone or security key), and something you are (a fingerprint or face). Even if an attacker has your password, they still lack the second factor.
Types of second factors, from weakest to strongest
| Method | How it works | Main weakness |
|---|---|---|
| SMS code | A code arrives by text message. | SIM swapping, message interception, and easy phishing. |
| Email code | A code arrives in your inbox. | Only as safe as your email account. |
| Authenticator app (TOTP) | An app generates a six-digit code that changes about every 30 seconds. | You can still be tricked into typing the code into a fake site. |
| Push approval | Your phone asks you to approve a login. | Prompt bombing: attackers send repeated requests until you tap "approve." |
| Passkey or security key | Your device proves your identity with a cryptographic key tied to the real website address. | Needs setup and a backup plan. Not supported everywhere yet. |
Any MFA is much better than none. Still, the differences matter against modern scams. A code typed into a fake page can be passed to the real site by the attacker within seconds. Passkeys and hardware security keys resist this, because the browser or device releases the proof only to the genuine website address. A fake domain gets nothing.
How a one-time code works
An authenticator app and the website share a secret key when you scan the setup QR code. Each side combines that secret with the current time to compute the same short code. The code is never sent to you; both sides calculate it independently. This explains two practical points. Your phone clock must be roughly correct, and anyone who photographs your setup QR code can generate your codes, so do not share it.
Rules for using MFA well
- Enable it first on email, banking, investment, payment apps, your mobile carrier, and your password manager.
- Choose the strongest option each service offers, in this order: passkey or security key, authenticator app, then SMS.
- Never give a one-time code to anyone who contacts you. Banks and agencies do not ask for codes by phone, text, or chat. A person who asks is attempting a takeover, and the code you read out is the key they are missing.
- Treat an unexpected approval request as an attack in progress. Deny it, and change your password.
- Save backup codes offline. Without them, losing your phone can lock you out.
Account recovery and other weak points
Attackers often skip the login and go through recovery instead.
- Security questions. Answers such as your mother's maiden name or first school are easy to research. Treat them as extra passwords: enter random text and store it in your manager.
- Recovery email and phone. Keep them current and protected. An old, abandoned recovery address can be taken over and used to reset your account.
- Carrier protection. Ask your mobile carrier to add a number-transfer PIN or port-out lock to block SIM swaps.
- Sign-in alerts. Turn on notifications for new logins, password changes, and new payees. These give early warning.
- Linked devices and sessions. Review which devices are logged in and remove ones you do not recognize.
- Public Wi-Fi and shared devices. Avoid banking on them, and sign out when finished.
Detecting and responding to a compromise
Signs of takeover include login alerts you did not trigger, password reset emails you did not request, MFA prompts you did not start, changed account details, and unfamiliar transactions.
If you see them:
- Change the password of the affected account from a device you trust. Do it first on email, if email may be affected.
- Sign out all other sessions and revoke unknown devices.
- Review and reset MFA methods and recovery details, which attackers sometimes change.
- Change passwords on other accounts where you reused the same one.
- Contact the financial institution through its official number if money may be at risk.
- Run a malware scan on your devices.
You can check whether an email address appeared in known breaches using a reputable breach-notification service. If it did, change the password on that site and anywhere it was reused.
Common mistakes
- Reusing one "strong" password everywhere. One breach exposes all accounts.
- Relying on SMS codes alone for high-value accounts when a stronger option exists.
- Approving a login prompt "just to make it stop."
- Storing the only copy of backup codes in the same account they protect.
- Skipping email security while securing the bank.
- Sharing a code with a caller who claims to be from fraud prevention.
Checking a link before you log in
A password manager helps, but you can also verify the web address yourself. The key point is that the real host name decides who owns a page. A trusted name placed at the start of a longer domain, or before an @ sign, does not make the link official.
from urllib.parse import urlparse
def is_official_link(url: str, official_domain: str) -> bool:
"""Return True only if the link's host is the official domain or one of its subdomains."""
host = (urlparse(url).hostname or "").lower()
return host == official_domain or host.endswith("." + official_domain)
print(is_official_link("https://www.example-bank.com/login", "example-bank.com"))
print(is_official_link("https://example-bank.com.login-verify.net/", "example-bank.com"))
print(is_official_link("https://[email protected]/", "example-bank.com"))The output is True, False, False. The second link belongs to login-verify.net. The third link's real host is evil.test, because text before @ is treated as a username. Passkeys and password managers perform this same kind of check automatically, which is why they resist fake sites better than human attention does.
Putting it together
Layered protection works because no single control is perfect. A unique password limits the damage of a breach. A password manager checks the site for you. Strong MFA covers a stolen password. Recovery hardening and alerts close the side doors, and a response plan limits harm when something still goes wrong.
Exercise
A caller says they are from your bank's fraud team. They tell you a code is about to arrive by text and ask you to read it back to "cancel a suspicious transfer." Which attack is this, and what should you do?
Show answer
This is an account takeover attempt using social engineering. The code is the second factor the attacker needs after obtaining or guessing your password, or it may approve a new device or payee. Do not read the code. Hang up, then call the number printed on your card or on the bank's official website, and ask whether there is a real issue. If you shared the code, change your password at once, sign out other sessions, and tell the bank.
Exercise
Rank these from weakest to strongest for protecting a bank account: passkey, SMS code, authenticator app. Explain why the weakest is weak and why the strongest resists a fake login page.
Show answer
Weakest to strongest: SMS code, authenticator app, passkey. SMS codes can be diverted by SIM swapping or intercepted, and they can be typed into a fake page. Authenticator codes avoid the phone network but can still be typed into a fake page and relayed. A passkey is bound to the genuine website address, so the browser will not supply it to a lookalike domain.
Exercise
Your email address appears in a breach notification for a shopping site where you used the same password as your bank. List the steps you take, in order.
Show answer
First change the bank password to a new unique one, and check that MFA is on. Change the password on the shopping site and on your email account if it shared the password. Sign out other sessions and review recent activity and alerts. Then move all of these passwords into a password manager and replace any other reused passwords.