Sub topic 4
Applying least privilege to an agent
This chapter assumes you can create permission sets in Salesforce Setup, you know the difference between object permissions and field-level security, and you know that an Agentforce agent has topics and actions. Here you will apply the principle of least privilege to the user an agent runs as.
What least privilege means for an agent
Least privilege means giving an identity only the access it needs for its job, and nothing more. For an agent, the "identity" is the agent user, and the "job" is the set of topics and actions you have defined.
An agent differs from a human user in one important way. A person usually knows when a request is out of bounds. An agent follows instructions, but a customer can phrase a request in many ways, and the model may misread one. Instructions are a soft limit. Permissions are a hard limit, because the platform enforces them even when the agent's reasoning goes wrong. So you design permissions as if the agent will sometimes try to do something it should not.
Work from the actions, not from the profile
A common mistake is to clone a profile such as Standard User and then remove what looks risky. This starts from too much access. Work in the other direction.
- List the actions the agent can call.
- For each action, write down the objects and fields it reads or changes.
- Grant exactly those permissions, and no others.
Suppose an order-status agent has one action, "Get Order Status". Your list is short.
| Action | Object | Fields | Access needed |
|---|---|---|---|
| Get Order Status | Order | OrderNumber, Status | Read |
The agent needs no create, edit, or delete rights on Order. It also needs no access to Account, Contact, or Case unless an action uses them.
Build the permission set
Put the access in a custom permission set and assign it to the agent user. Do not edit the profile for this purpose. A permission set is easy to review, easy to remove, and easy to compare with the action list.
<?xml version="1.0" encoding="UTF-8"?>
<PermissionSet xmlns="http://soap.sforce.com/2006/04/metadata">
<label>Agent Order Read</label>
<description>Read-only access to orders for the service agent user</description>
<hasActivationRequired>false</hasActivationRequired>
<objectPermissions>
<allowCreate>false</allowCreate>
<allowDelete>false</allowDelete>
<allowEdit>false</allowEdit>
<allowRead>true</allowRead>
<modifyAllRecords>false</modifyAllRecords>
<object>Order</object>
<viewAllRecords>false</viewAllRecords>
</objectPermissions>
<fieldPermissions>
<editable>false</editable>
<field>Order.Status</field>
<readable>true</readable>
</fieldPermissions>
</PermissionSet>Read the file against the least-privilege checklist.
- Object access is read only. Create, edit, and delete are all
false. viewAllRecordsandmodifyAllRecordsarefalse. These two settings bypass sharing, so they are the most dangerous rights to grant by accident. Leave them off unless a topic truly requires them.- Field access is listed field by field. Only
Order.Statusis readable.
Common errors
- Granting View All "to make it work." If the agent cannot find an order, the cause is usually sharing or a missing field permission. View All makes the symptom disappear but exposes every order to the agent.
- Reusing a human permission set. A set built for a service representative often includes edit and delete rights. The agent inherits them.
- Treating instructions as the control. An instruction such as "never change orders" does not remove the edit permission. If the permission exists, a misrouted request can use it.
- Never revisiting access. When you add an action, you add a permission. When you remove an action, remove the permission too.
Check the result
After assigning the set, confirm that the agent user has no more access than you intended. Review the agent user's assigned permission sets, and use the "View Summary" option on the permission set to see the object and field rights it grants. Then test with a request the agent should refuse and a request for a record the agent user should not see.
Exercise
An agent's only action updates the Status field on a Case. A teammate proposes cloning the Standard User profile for the agent user "to save time." Describe the permission set you would build instead, and name one setting you would leave off.
Show answer
Create a custom permission set with Read and Edit on Case, plus read and edit field permissions for Case.Status (and read access to any other fields the action must see). Grant no create or delete rights and no other objects. Leave View All Records and Modify All Records off, because they bypass sharing. A cloned profile starts with broad access that the action does not need.