SfSkills Domains Docs GitHub

Home / security / network-security-and-trusted-ips

network-security-and-trusted-ips

Configure and audit Salesforce network security controls — trusted IP ranges (org-wide Network Access), login IP ranges on profiles, CSP Trusted Sites for Lightning components, CORS allowlists for external JavaScript, and TLS requirements — and troubleshoot login-blocked-by-IP or CSP violation errors. NOT for per-profile login IP range policy, IP relaxation decisions, or their interaction with MFA and SSO — use security/ip-relaxation-and-restriction.

Open the skill folder on GitHub


Network Security and Trusted IPs

This skill activates when a practitioner needs to configure, audit, or troubleshoot Salesforce network-layer security controls: org-wide Trusted IP Ranges, profile-level Login IP Ranges, CSP Trusted Sites for Lightning components, CORS allowlists for external API callers, and My Domain TLS requirements. It covers all three operational modes — configuring from scratch, auditing existing restrictions, and diagnosing login failures or CSP violations caused by network controls.


Before Starting

Gather this context before working on anything in this domain:


Core Concepts

Concept 1 — Trusted IP Ranges (Org-Wide Network Access)

Location: Setup > Security > Network Access

Trusted IP Ranges define a set of IP addresses or CIDR blocks that Salesforce considers trusted for all users in the org. When a user logs in from a trusted IP:

Configuration: Setup > Security > Network Access > New. Provide a Start IP Address and End IP Address. IPv4 ranges are expressed as start/end pairs (e.g., 203.0.113.10 to 203.0.113.254). IPv6 is supported but must be entered in full expanded form — CIDR notation is not accepted directly in the UI for IPv6.

Limit: Salesforce does not publish a hard maximum for the number of trusted IP entries per org, but keep the list to the minimum needed for operational coverage.

Concept 2 — Login IP Ranges on Profiles

Location: Setup > Profiles > [Profile Name] > Login IP Ranges

Login IP Ranges are a profile-level hard restriction. Users on that profile cannot log in at all from an IP outside the configured range — they receive an error, not just an email challenge. This is the appropriate control for locking privileged profiles (e.g., System Administrator) to known office or VPN IP blocks.

Key distinctions from Trusted IP Ranges:

DimensionTrusted IP Ranges (Org-Wide)Login IP Ranges (Per Profile)
ScopeAll users, all profilesOnly users on the specific profile
EffectSkips email verification challengeHard deny — login refused outside range
MFANot affected — MFA still requiredNot affected — MFA still required
Audit trailLoginHistory SourceIp fieldLoginHistory Status = 'No Salesforce.com Access'
Config locationSetup > Security > Network AccessSetup > Profiles > [Profile] > Login IP Ranges

Important: If a profile has Login IP Ranges set and a user on that profile attempts to log in from outside those ranges, the login is denied with Status = 'No Salesforce.com Access' in LoginHistory. There is no email challenge fallback.

Concept 3 — CSP Trusted Sites for Lightning Components

Location: Setup > CSP Trusted Sites

Salesforce Lightning Experience enforces a Content Security Policy (CSP) that restricts what external resources can be loaded in Lightning pages. By default, Lightning blocks all external script-src, img-src, frame-src, font-src, connect-src, and style-src origins not already on Salesforce's internal allowlist.

When a Lightning component (LWC or Aura) loads an external resource — a CDN-hosted JS library, an external image, a web font, or a third-party iframe — the browser will block it with a CSP violation unless the source domain is added to the CSP Trusted Sites list.

Each CSP Trusted Site entry specifies:

Scope: CSP Trusted Sites apply to all Lightning pages in the org. There is no profile-level or component-level scoping — adding an entry allows that resource org-wide in Lightning.

Concept 4 — CORS Allowlist

Location: Setup > CORS

Cross-Origin Resource Sharing (CORS) governs which external web application origins are allowed to make JavaScript-initiated HTTP requests to Salesforce REST, SOAP, Bulk, and streaming APIs. This is relevant when a third-party web application (not hosted on Salesforce) makes API calls directly from the browser using JavaScript.

A CORS entry requires:

Without a CORS entry, the browser's preflight OPTIONS request will be denied and the API call will fail with a CORS error. Note: CORS only applies to browser-initiated calls — server-to-server API calls (cURL, Apex callouts, integration middleware) are not subject to CORS and do not need entries here.


Common Patterns

Mode 1: Configuring Network Security Controls from Scratch

When to use: A new org is being hardened pre-go-live, or an existing org has never had explicit network restrictions configured.

How it works:

  1. Identify IP requirements. Collect the office IP ranges, VPN exit nodes, and any CI/CD pipeline IP blocks that need to be trusted or restricted.
  2. Configure org-wide Trusted IP Ranges (skips email challenge for all users):
    • Setup > Security > Network Access > New
    • Enter Start IP and End IP for each range (one entry per range)
    • Repeat for each office location and VPN exit IP block
  3. Configure Login IP Ranges on privileged profiles (hard restrict by IP):
    • Setup > Profiles > System Administrator > Login IP Ranges > New
    • Enter Start IP and End IP for each allowed range
    • Repeat for any other privileged profiles (e.g., custom admin profiles)
    • Test from a known-good IP before saving, to avoid locking out your own session
  4. Configure CSP Trusted Sites for any external resources in Lightning:
    • Setup > CSP Trusted Sites > New
    • Enter the origin URL (e.g., https://cdn.jsdelivr.net)
    • Select the applicable CSP directives (most CDN JS libraries need script-src and connect-src)
  5. Configure CORS if any external web applications call the Salesforce API from a browser:
    • Setup > CORS > New
    • Enter the exact origin URL (e.g., https://portal.example.com)
  6. Verify My Domain is deployed: Setup > My Domain. Lightning security controls require My Domain.

Why not rely on org-wide trusted IPs alone for admin lockdown: Trusted IP Ranges bypass the email challenge but do not prevent logins from outside those IPs. Only Login IP Ranges on profiles provide hard login denial.

Mode 2: Auditing Existing Network Security Configuration

When to use: Pre-go-live review, post-incident investigation, or compliance audit requiring a full inventory of network restrictions.

How it works:

  1. Export Trusted IP Ranges: Setup > Security > Network Access. Review for stale ranges, overly broad CIDR blocks, or documentation gaps.
  2. Export Login IP Ranges per profile: For each profile with sensitive access (System Administrator, custom admin), review Setup > Profiles > [Profile] > Login IP Ranges. Check that every range is documented and intentional.
  3. Export CSP Trusted Sites: Setup > CSP Trusted Sites. Flag any script-src entries pointing to non-authoritative domains or entries added without a documented justification.
  4. Export CORS entries: Setup > CORS. Verify each origin is still an active application and that wildcard entries are justified.
  5. Cross-reference with LoginHistory for Status = 'No Salesforce.com Access' entries — these indicate users who were denied login due to IP restrictions. Unexpected denials may indicate a range misconfiguration.
    SELECT UserId, LoginTime, SourceIp, Status, LoginType
    FROM LoginHistory
    WHERE Status = 'No Salesforce.com Access'
      AND LoginTime >= LAST_N_DAYS:30
    ORDER BY LoginTime DESC
    LIMIT 500
  6. Document findings in the work template, noting any gaps, over-broad ranges, or undocumented entries.

Mode 3: Troubleshooting Login Blocked by IP or CSP Violations

When to use: A user reports they cannot log in, or a Lightning component is failing to load external resources.

How it works — Login IP restriction troubleshooting:

  1. Check the user's profile: Setup > Users > [User] > Profile. Navigate to that profile's Login IP Ranges.
  2. Confirm the user's current IP (ask them to visit whatismyip.com or check the SourceIp field in LoginHistory).
  3. If their IP is outside the configured ranges, either add a new range entry or move the user to a profile without Login IP Ranges.
  4. Check LoginHistory to confirm the denial:
    SELECT LoginTime, SourceIp, Status, LoginType
    FROM LoginHistory
    WHERE UserId = '005XXXXXXXXXXXXXXX'
    ORDER BY LoginTime DESC
    LIMIT 20
  5. For org-wide Trusted IP Range additions (to stop email verification challenges), add the IP range under Setup > Security > Network Access.

How it works — CSP violation troubleshooting:

  1. Open the browser Developer Tools (F12) > Console tab. CSP violations appear as red errors beginning with Content Security Policy.
  2. Identify the blocked origin from the error message (e.g., Refused to load script from 'https://cdn.example.com/...').
  3. Navigate to Setup > CSP Trusted Sites > New.
  4. Enter the blocked origin URL and select the appropriate directives based on the resource type:
    • External JS files → script-src
    • API calls from JS → connect-src
    • External CSS → style-src
    • Web fonts → font-src
    • Embedded iframes → frame-src
    • Images → img-src
  5. Save and reload the Lightning page. The browser cache may need clearing.

Decision Guidance

SituationRecommended ApproachReason
Skip email verification challenge for office network usersTrusted IP Ranges (Setup > Security > Network Access)These are org-wide and bypass email challenge only, not MFA
Prevent logins to the System Administrator profile from outside the VPNLogin IP Ranges on the System Administrator profileLogin IP Ranges enforce hard denial; Trusted IP Ranges do not
Allow a CDN-hosted JavaScript library in an LWCCSP Trusted Sites with script-src directiveCSP Trusted Sites is the correct Lightning-layer allowlist for resource loading
Allow an external portal to call Salesforce REST API from the browserCORS allowlist entry for the portal's originCORS governs browser-initiated cross-origin API calls
Block logins from unauthorized countries in real timeTransaction Security Policy (separate skill)Real-time enforcement requires the Event Monitoring add-on and is not a static IP range
Restrict a community or Experience Cloud user to specific IPsLogin IP Ranges on their profile (e.g., Customer Community User profile)Profile-level ranges work for all profile types including Experience Cloud
Audit all network restrictions before a security reviewMode 2 audit pattern: review Network Access, all profile Login IP Ranges, CSP Trusted Sites, and CORSNo single Setup page shows all four lists together

Step-by-step instructions for an AI agent or practitioner activating this skill:

  1. Gather context — confirm the org edition, relevant objects, and current configuration state
  2. Review official sources — check the references in this skill's well-architected.md before making changes
  3. Implement or advise — apply the patterns from Core Concepts and Common Patterns sections above
  4. Validate — run the skill's checker script and verify against the Review Checklist below
  5. Document — record any deviations from standard patterns and update the template if needed

Review Checklist

Run through these before marking work in this area complete:


Salesforce-Specific Gotchas

Non-obvious platform behaviors that cause real production problems:

  1. Trusted IP Ranges do not prevent logins from untrusted IPs — they only skip the email challenge — Many practitioners configure Trusted IP Ranges expecting them to restrict logins to those IPs. They do not. A user outside a Trusted IP range still logs in successfully; they just receive an email verification challenge first. To actually restrict login to specific IPs, use Login IP Ranges on the user's profile.
  2. Login IP Ranges on a profile lock out all users on that profile, including System Administrators — If you configure Login IP Ranges on the System Administrator profile and your own IP is not in the range, you will be locked out of your own session on next login. Always test from a confirmed IP-in-range browser session before saving profile-level IP restrictions.
  3. CSP Trusted Sites scope is org-wide — there is no component-level or profile-level scoping — Adding a CSP Trusted Site entry for a domain allows that resource to be loaded anywhere in Lightning for any user in the org. There is no way to restrict a CSP entry to specific pages, components, or user profiles.

Output Artifacts

ArtifactDescription
Trusted IP Range entriesOrg-wide Network Access IP ranges that bypass the email verification challenge
Profile Login IP Range entriesPer-profile hard-deny IP restrictions for one or more profiles
CSP Trusted Site recordsOrigin allowlist entries for Lightning component external resource loading
CORS allowlist entriesOrigin entries for external web applications making browser-initiated API calls
LoginHistory audit querySOQL to surface No Salesforce.com Access denials within a date range
Network security audit checklistInventory of all four control types across the org

Package files