Sub topic 1
How Salesforce Authenticates Users and What Attackers Target
Prerequisites
This chapter assumes you can do the following:
- Administer users, profiles, and permission sets in a Salesforce org.
- Navigate Setup and use Quick Find.
- Explain what a username and password are, and why they are called login credentials.
The Working Model: Authentication Before Authorization
Authentication answers "who is this person?" Authorization answers "what may this person do?" Salesforce checks authentication first. Only after a user is authenticated do profiles, permission sets, and sharing rules decide what the user can see and change.
A Salesforce login follows these steps:
- The user submits credentials to a login endpoint, such as the My Domain login page.
- Salesforce checks the credentials against its own user records, or hands the request to an external identity provider (IdP) when single sign-on (SSO) is configured.
- Salesforce applies the login restrictions that belong to the user's profile, such as login hours and login IP ranges.
- If MFA is required, Salesforce asks for a second proof of identity.
- Salesforce creates a session and returns a session ID. Later requests carry that ID, so the user does not log in again for each click.
Each failed or successful attempt is recorded in login history. A later chapter shows how to query it.
What Attackers Target
Attackers rarely break Salesforce itself. They go after the weakest link in the login process, which is usually the person or the credential.
| Attack | How it works | What it exploits |
|---|---|---|
| Phishing | A fake login page or email tricks the user into typing a password. | Human trust |
| Credential stuffing | Passwords leaked from other sites are tried against Salesforce logins. | Password reuse |
| Brute force and password spraying | Many guesses, or a few common passwords across many users. | Weak passwords |
| Session hijacking | A stolen session ID is replayed to act as the user. | Long or unprotected sessions |
| Integration credentials | A password and security token stored in a script or tool is stolen. | Shared, rarely rotated secrets |
Notice that a strong password stops only some of these. Phishing and credential stuffing succeed even when the password is long and complex, because the attacker ends up holding the correct password. A second factor that the attacker does not have limits the damage.
Layers You Control
Salesforce gives you several layers. No single layer is enough, and later chapters cover each one.
- MFA adds a second proof of identity at login.
- Password policies set length, complexity, expiration, and lockout rules.
- Session settings limit how long a session lasts and how strongly it is protected.
- Network restrictions allow logins only from approved IP ranges and during set hours.
- Monitoring shows suspicious logins after the fact.
A First Look at Login Data
You can see this process in your own org. This SOQL query lists logins from the last seven days, with the source IP address and the result of each attempt. Run it in the Developer Console Query Editor.
SELECT UserId, LoginTime, LoginType, SourceIp, Status, Application
FROM LoginHistory
WHERE LoginTime = LAST_N_DAYS:7
ORDER BY LoginTime DESC
LIMIT 200Look at the Status column. Repeated failures from one SourceIp, or failures across many users from one address, match the brute force and spraying patterns in the table above.
Common Errors
- Treating a complex password as sufficient. It does nothing against phishing or reused passwords.
- Confusing authentication with authorization. Tight permission sets do not help if an attacker logs in as a legitimate user.
- Forgetting non-human logins. Integration users often skip every protection that human users have.
Exercise
A user's password is 20 characters long and unique, yet an attacker logs in as that user after the user typed it into a fake login page. Which attack is this, and which layer from this chapter limits the damage?
Show answer
This is phishing. The attacker has the correct password, so password strength does not help. MFA limits the damage, because the attacker also needs the second factor. Login IP ranges and monitoring can also block or reveal the login.
Exercise
In the login flow described in this chapter, which step happens first: checking login hours and IP ranges, or creating the session?
Show answer
Salesforce checks login hours and IP ranges, and the MFA challenge if one is required, before it creates the session.