files/en-us/web/security/attacks/phishing/index.md
Phishing is a {{glossary("social engineering")}} attack in which a user is tricked into believing that they are interacting with a site with which they have an account, when in reality they are interacting with the attacker. The attacker convinces the user to enter their credentials on the fake site, and thereby steals the user's credentials.
Phishing is a very old but still very common attack, which has gone through many variations, both to evade defenses and to take advantage of new vulnerabilities. In a basic form, though:
my-bank.example.com, the attacker could register my-bank.examp1e.com.my-bank.example.com, giving some reason to ask the user to visit the site, and containing a link to the fake site my-bank.examp1e.com.Phishing attacks sometimes use different techniques to contact their victims, such as text messages or voice calls, and sometimes don't involve websites at all, convincing users to tell them passwords or PIN codes verbally.
Some phishing attacks are highly indiscriminate, sending out many messages to potential victims, in the hope that some will be tricked. In spear-phishing attacks, on the other hand, attackers research specific victims, gathering personal information about them to make the lure more convincing. For example, the email may purport to come from someone the victim knows, and even include private information.
Phishing attacks are not dependent on naive or inexperienced users: decades of experience has shown that even highly experienced and knowledgeable users can be vulnerable to phishing attacks, especially when they are busy, tired, or distracted.
One thing that makes phishing challenging for a website to defend against is that the target site is not involved at all in the attack. It's entirely dependent on the user being tricked by the attacker. In this section we will discuss some practices that can help, but the only one that is really effective is using passkeys instead of passwords.
Phishing emails often forge the sender address, to make the victim think that the email really came from the target website. Three {{glossary("DNS")}} records help email servers detect these forgeries, which helps ensure that phishing emails are marked as spam in the victim's email client, or are blocked entirely.
Return-Path header, and looks up the SPF record associated with that domain.From header (this essentially means that the domain names must match or the value in the From header must be a subdomain of the domain in the signature).You should set these DNS records for your domains, to help email servers recognize forged messages.
Password managers can provide some degree of protection against phishing attacks. They fulfill three main functions:
It's the last of these that can help against phishing. The user might not see the difference between the fake domain my-bank.examp1e.com and the real domain my-bank.example.com, but the password manager will, and as a result it will not automatically enter the real password on the fake site. With luck, this will be enough of a warning to the user that the login request is not legitimate.
As a web developer, you can't make your users use a password manager. But you can, if you are not careful, make it impossible for password managers to integrate with your site. The article Making password managers play ball with your login form is an excellent summary of practices to follow, and practices to avoid, if you want users to be able to use password managers on your site. It's also important to test your site with password managers, both those built into browsers and popular standalone applications.
Unfortunately, users have been trained to expect tools to fail sometimes, and to work around their failures. So even if a user has a password manager, and it works with your site, and it does not auto-fill the password during a phishing attempt, you still have no guarantee that the user will not just paste the password in manually.
Using {{glossary("multi-factor authentication", "multi-factor authentication (MFA)")}} to authenticate users makes phishing more difficult but, depending on the specific method used, does not prevent it.
In particular, in the most common MFA implementations, the user has to enter their password and another code, called a one-time password (OTP), which is unique to this login attempt. Two common variants are:
SMS-based OTP:
Time-based OTP (TOTP):
TOTP is considered more secure than SMS-based OTP, because it is possible for attackers to intercept SMS messages. However, from the point of view of phishing, both methods are vulnerable.
To phish a user who uses OTP as a second factor, the attacker's fake site is an active manipulator in the middle, between the user and the real site:
This is much more difficult than just phishing a password, because the attacker must operate in real time. However, phishing toolkits greatly reduce the complexity of accomplishing it.
The strongest technical defense against phishing is to authenticate users using passkeys.
A passkey is created when the user registers on the site, and is specific to the {{glossary("origin")}} for which it was originally created. The passkey is generated by, and stored in, a module called an authenticator, which is built into or attached to the user's device.
Unlike passwords or OTP codes, a user never manually enters a passkey on a site: in fact, the passkey is never transmitted to the site at all. When a website asks the user to authenticate using Web Authentication, the browser asks the authenticator for a passkey that matches the site's origin. If it can find one, the authenticator generates a token which the browser sends to the website. The website verifies the token and signs the user in.
Because the passkey is specific to the site's origin, if a passkey was created for the user's account at my-bank.example.com, the user will not be able to use it on my-bank.examp1e.com. The browser just won't consider it applicable to the fake site.
This makes passkeys an effective defense against phishing. Passkeys are a much newer authentication method than passwords or OTP, and the tooling surrounding them is less mature. However, this is changing, and passkeys may eventually displace passwords as the most common authentication method on the web.
Another phishing defense, which isn't often used any more, is for the website to display a secret message or image to the user on its login page.
The idea is that the attacker doesn't know what the secret is, so can't display it on the fake login page.
In a variation of this technique, the website uses a persistent cookie to decide which secret to display, instead of the username.
In practice there are a few difficulties with this technique:
As a result of these weaknesses, this defense is rarely used: both MFA and passkeys are considered to be stronger defenses.
SPF, DKIM, and DMARC DNS records for your domains.