Sub topic 1
How Salesforce Authenticates Users and What Attackers Target
Prerequisites
This chapter assumes you already have the following:
- Basic Salesforce administration skills: you know what users, profiles, and permission sets are.
- Familiarity with Setup navigation, including the Quick Find box.
- A general idea of usernames and passwords as login credentials.
You do not need to know anything about multi-factor authentication (MFA) yet. Later chapters cover it.
Authentication and authorization
Two words come up constantly in login security, and they mean different things.
- Authentication answers the question "who are you?" It happens at login.
- Authorization answers the question "what are you allowed to do?" Profiles, permission sets, and sharing rules handle this after login.
This tutorial is almost entirely about authentication. A strong login does not fix a badly configured permission model. A strong permission model does not help if an attacker can sign in as your system administrator. You need both, but a stolen identity bypasses most of what you built for authorization.
A credential is a piece of evidence that a user presents to prove identity. The most common credential is a username and password pair. A factor is a category of evidence. There are three well-known categories:
| Factor category | Meaning | Examples |
|---|---|---|
| Something you know | A secret held in memory | Password, PIN |
| Something you have | A physical or digital item | Phone with an authenticator app, security key |
| Something you are | A body trait | Fingerprint, face scan |
Logging in with a username and a password uses one factor category only: something you know. That limit explains most of the risks described later in this chapter.
The ways a user can authenticate to Salesforce
Salesforce supports several login paths. Each one has different risks and different controls.
- Username and password at the Salesforce login page. This is the default. The user types credentials at
login.salesforce.com, at a My Domain URL, or at a Experience Cloud site login page. - Single sign-on (SSO). The user signs in at another system, called an identity provider, and Salesforce trusts the result. SAML and OpenID Connect are the common protocols. Chapter 6 of this tutorial covers SSO in detail.
- Social or third-party login. An authentication provider such as Google or another OpenID Connect provider supplies the identity. This is common for Experience Cloud sites.
- API and integration logins. A program signs in instead of a person. This can use OAuth flows, or a username and password with a security token in older integrations.
- Mobile app and desktop client logins. These use OAuth in the background but still lead back to one of the paths above.
A My Domain is a custom subdomain for your org, such as yourcompany.my.salesforce.com. It gives you a login URL that belongs to your org alone. It is also a requirement for several login features, including SSO setup, login page branding, and some MFA behavior.
What happens when a user logs in
The sequence below is simplified, but it shows where each control you will configure fits in.
Key points about this flow:
- The password check happens first. If it fails, Salesforce counts a failed attempt toward the lockout limit.
- Network and time restrictions apply to the profile. They can block a login even when the password is correct.
- MFA adds a second proof after the password. Without it, a correct password is enough.
- Every attempt, successful or not, produces a record in login history. This record is your main source of evidence when you investigate an incident.
- A successful login creates a session. A session is a temporary state, identified by a session ID, that lets the browser or client make requests without sending the password each time.
The last point matters for security. After login, the session ID acts as proof of identity. Anyone who obtains a valid session ID can act as that user until the session ends. Chapter 8 covers session settings.
What attackers target
Attackers rarely break Salesforce itself. They go after the people and credentials around it. The following attacks account for most real incidents against Salesforce orgs.
Phishing
Phishing is a message that tricks a user into entering credentials on a fake page. The page often copies the Salesforce login screen. The attacker collects the username and password as the user types them.
Phishing works against passwords because the password is a secret that the user can be talked into handing over. Strong passwords do not help here. The user gives away the strong password just as easily as a weak one.
A related attack is vishing, which is phishing by phone. An attacker calls a user, pretends to be IT support, and asks the user to approve a login prompt or to connect a malicious app to the org.
Credential stuffing
Credential stuffing is an automated attack that takes username and password pairs leaked from other websites and tries them against Salesforce. It succeeds because many people reuse passwords across services. A breach at an unrelated service can become a breach of your org.
Signs of credential stuffing in login history include many failed logins across many different usernames, often from the same few IP addresses, in a short time.
Password spraying and brute force
A brute-force attack tries many passwords against one account. Account lockout limits this attack well.
A password spray tries one or a few common passwords, such as Summer2026!, against many accounts. Because each account sees only one or two failures, lockout thresholds are rarely reached. Spraying is harder to spot in per-account counts and easier to spot when you look at failures across the whole org.
Session hijacking
In session hijacking, an attacker obtains a valid session ID and uses it instead of logging in. They can steal it from malware on the user's computer, from an insecure network, or from a malicious browser extension. The attacker never needs the password, and in many cases never triggers MFA, because MFA ran earlier in the session creation.
Over-permissioned and shared accounts
Some risk comes from your own configuration:
- Shared accounts, where several people use one username, make it impossible to tell who did what. They also make MFA impractical, because only one device can hold the verification method.
- Integration users with full administrator rights give an attacker a powerful target with weak protection.
- Dormant active users, such as former employees whose accounts are not deactivated, give attackers a quiet entry point.
Malicious or over-trusted connected apps
A connected app is a registration that lets an external application sign in to Salesforce through OAuth. If a user approves a malicious app, that app can receive tokens that work without the password. Review connected app usage regularly, and limit who can approve new apps.
Why passwords alone are not enough
The attacks above share one property: each of them defeats the "something you know" factor, or goes around it.
| Attack | Defeats the password how | Would a second factor help? |
|---|---|---|
| Phishing | User types the password into a fake page | Yes, strongly with phishing-resistant methods such as security keys. Partly with codes, which a live attacker can relay. |
| Credential stuffing | Reused password is already known | Yes. The attacker lacks the second factor. |
| Password spray | A weak password is guessed | Yes. A correct guess still fails without the second factor. |
| Session hijacking | The password is bypassed entirely | No, MFA does not stop it. Session settings and device controls do. |
| Malicious connected app | OAuth token replaces the password | No, unless the user's approval step is controlled. |
The table shows that MFA is not a complete answer. It handles the largest group of attacks, the ones that depend on a stolen or guessed password. It does not replace session controls, network restrictions, and monitoring. That is why this tutorial covers all of them.
Layered defenses and where they fit
Security specialists call the combination of overlapping controls defense in depth. If one control fails, another can still stop the attacker. The table maps each layer to the chapter that covers it.
| Layer | What it controls | Covered in |
|---|---|---|
| Password policies | Strength, expiration, lockout | Chapter 7 |
| MFA | Proof beyond the password | Chapters 2 to 5 |
| SSO | Central control of identity | Chapter 6 |
| Session settings | How long and how strongly a session is trusted | Chapter 8 |
| IP ranges and login hours | Where and when logins are allowed | Chapter 9 |
| Login flows | Extra custom steps at login | Chapter 13 |
| Login history monitoring | Detection and investigation | Chapter 11 |
| Recovery and rollout | Keeping users productive and protected | Chapters 10 and 14 |
Looking at your own org's login data
Before you change anything, look at what is happening now. Salesforce records each login attempt in the LoginHistory object. Run the following query in Developer Console, in the Query Editor tab, or in Workbench.
SELECT UserId, LoginTime, LoginType, SourceIp, Status, Application
FROM LoginHistory
WHERE LoginTime = LAST_N_DAYS:7
ORDER BY LoginTime DESC
LIMIT 200Read the results with these questions in mind:
- Are there many rows with a
Statusthat is notSuccess? Group them bySourceIpand byUserIdto separate one forgetful user from an attack. - Does
SourceIpshow countries where you have no employees or customers? - Does
LoginTypeshow unexpected values, such as anApplicationlogin for a user who should only use a browser? - Does the same
UserIdlog in from two distant places within minutes?
Keep in mind that the LoginHistory object holds recent records only, roughly the last six months, so export the data if you need a long history.
You can also find out which active users have no registered verification method. This query uses TwoFactorInfo, an object that records which users registered a method.
SELECT Id, Name, Username
FROM User
WHERE IsActive = true
AND Id NOT IN (SELECT UserId FROM TwoFactorInfo)The result is a first approximation of your exposure. Each row is an active user whose only protection is a password. Save the count. It becomes the baseline you improve during rollout in Chapter 14.
Common mistakes at this stage
- Treating a strong password policy as enough. Policies reduce guessing but do nothing against phishing or reuse.
- Ignoring integration users. They often hold broad permissions, and many cannot answer an MFA prompt. Chapter 12 covers how to protect them.
- Leaving former staff active. Deactivate users promptly. A frozen or deactivated account cannot log in, which removes a whole class of risk.
- Reviewing login history only after an incident. Review it before you need it, so you know what normal looks like.
- Assuming MFA stops every attack. It does not stop session hijacking, and it can be bypassed by users who approve prompts they did not start.
Summary of the model
Salesforce authenticates a user through one of several paths, checks restrictions tied to the profile, optionally asks for a second proof, and then creates a session. Attackers aim at the weakest link in that chain: usually the password, sometimes the session, and sometimes an over-trusted integration. The rest of this tutorial adds a control for each link.
Exercise
A security analyst sees 4,000 failed logins in one hour, spread across 3,500 different usernames, with only one or two failures per username and all from a small group of IP addresses. No account is locked. Which attack does this pattern most likely show, why did lockout not trigger, and which two fields of LoginHistory would you use to confirm it?
Show answer
This pattern most likely shows a password spray or credential stuffing attack. Each account has only one or two failures, which stays below the lockout threshold, so no lockout triggers. Spreading attempts across many accounts is the way these attacks avoid lockout. To confirm, group the results by SourceIp to see the small set of addresses behind the failures, and filter or group by Status to count the failures per UserId. LoginTime helps show that the attempts came in a short window.
Exercise
Name two attacks from this chapter that a second verification factor would not stop, and give one control from the layered defense table that addresses each.
Show answer
Session hijacking is not stopped by MFA, because the attacker uses an already valid session ID. Session settings (Chapter 8) address it, for example by shortening session timeouts and raising the session security level. A malicious connected app is also not stopped, because OAuth tokens replace the password. Reviewing connected app usage and controlling who can approve apps address it. Login history monitoring (Chapter 11) helps detect both.