⚡ Key Points: 1-Minute Summary
- Four Security Layers: Agentforce protects data using a strict four-layer model encompassing User Context, Field-Level Security (FLS), Sharing Rules, and the Einstein Trust Layer.
- The Trust Layer is Built-In: The Einstein Trust Layer operates at an architectural level. It handles zero-retention agreements, toxicity scoring, and PII masking automatically before data reaches external LLMs.
- Direct Apex Callouts Bypass Protections: If you build direct Apex callouts to external LLMs instead of using standard Agentforce actions, the Trust Layer is bypassed. You are solely responsible for data masking and audit logging.
- Never Bypass Sharing: Custom agent actions utilizing Apex should always enforce security using
with sharingandUSER_MODE.
๐ก️ The Four Security Layers of Agentforce
To fully grasp how Agentforce remains secure, you must understand how these four concepts stack together:
- Layer 1: User Context. Employee agents inherit the exact permissions of the logged-in user making the request. Customer-facing service agents operate under their own dedicated, heavily restricted integration user. This creates the absolute ceiling of access.
- Layer 2: Field-Level Security (FLS). The agent can only read or process fields the running user is explicitly granted permission to view.
- Layer 3: Sharing Rules. Record-level visibility works normally. If the user cannot see a record via Org-Wide Defaults, Role Hierarchy, or Sharing Rules, neither can the agent.
- Layer 4: Einstein Trust Layer. Before passing contextual data to an LLM, Salesforce strips PII, enforces zero-data-retention policies with model providers, runs toxicity checks, and logs a secure audit trail.
Here is how the hierarchy maps out in practice:
Four layers
├─ 1. USER CONTEXT employee = caller | service = own user
│ ← the hard ceiling
├─ 2. FLS field access, enforced normally
├─ 3. SHARING record access, enforced normally
└─ 4. TRUST LAYER zero retention, toxicity, audit trail
← architectural, not a toggle
Rule: Prove every layer by testing with restricted users and document the evidence. Never describe a security boundary you haven't successfully demonstrated in a sandbox.
Gain: Ironclad security audits. When you have screenshots of a restricted user being denied access by the agent, compliance teams cannot push back.
Price: Real administrative effort. Building highly restricted test personas and running thorough integration tests takes significant time.
Limits: There is no override. An Agentforce agent does not possess a "run-as-system" mode to bypass visibility rules on the fly.
Mirror: Instructing the agent via prompt engineering to "not share data" is the most common wrong answer in Agentforce architectural interviews.
At volume: Service agent profiles demand the strictest auditing because every permission grant extends your public attack surface.
๐ฌ Core Q&A
A: Always start by explaining the ceiling, because every other security control sits beneath it. The agent runs strictly within a user's permissions. For an internal employee agent, that is the actual person typing the prompt. For an external service agent, it utilizes a dedicated, scoped integration user.
Inside that ceiling, standard Field-Level Security and Sharing Rules apply. Any custom Apex actions you build for the agent must inherit these rules using with sharing and USER_MODE database queries.
Finally, the Einstein Trust Layer handles the external handoff. It enforces zero-retention policies with LLM providers, runs toxicity checks, masks PII, and captures an audit trail. A live demonstration is the best way to prove this: log in as a restricted user, ask the agent for an inaccessible record, and document the automated refusal.
A: This is a massive security risk. If you assign an Apex class running without sharing to an agent action, you are effectively bypassing the first three layers of Salesforce security. The agent will read and return records as the system, exposing data the invoking user should never see. Always use with sharing for agent-invoked code.
A: No. The Einstein Trust Layer handles PII masking and toxicity scoring specifically for the payload traveling outbound to the LLM. Internal data visibility between the user and the Salesforce database is governed entirely by standard profiles, permission sets, and sharing rules.