Sub topic 11
Common over-privilege mistakes
This chapter assumes you can create users, profiles, and permission sets, and that you know the basics of OAuth and SOQL. It covers the mistakes that most often give an integration user more access than it needs, and how to spot each one.
Why these mistakes happen
Salesforce combines access from several places: the profile, every assigned permission set, field-level security, and sharing. The user gets the union of all of them. A single broad grant in any one place defeats the restrictions everywhere else. Most over-privilege comes from a shortcut taken to make an error go away.
Mistake 1: Using a standard profile with broad rights
Cloning or reusing the System Administrator profile is the most common shortcut. It works immediately, and it grants Modify All Data, View All Data, and Author Apex. Start from a minimal profile instead and add access only through permission sets.
Mistake 2: Granting View All or Modify All
Developers often add View All Records or Modify All Records on an object to fix an "insufficient access" error. These flags bypass sharing for that object. The same applies to the system permissions View All Data and Modify All Data, which bypass sharing for every object.
If the integration cannot see a record, find out why it is hidden. The cause is usually the sharing model or field-level security. Fix that specific cause.
Mistake 3: Granting Delete or Edit "just in case"
Check each permission against the requirements list you wrote earlier. A read-only reporting integration has no need for Create, Edit, or Delete. Leaving them on turns a bug or a stolen token into data loss.
Mistake 4: Sharing a human user as the integration user
If the integration runs as a named employee, its access changes whenever that person changes roles. The account may be frozen or deactivated when they leave, which breaks the integration. Audit logs also mix human and system activity. Use a dedicated user.
Mistake 5: Forgetting field-level security
Object permission does not mean every field is open. Some teams grant access to all fields because it is faster than listing them. This exposes fields such as tax IDs or internal notes. Grant only the fields the integration reads or writes.
Mistake 6: Leaving permission sets stacked
Over time, people add permission sets to fix one-off problems and never remove them. The user ends up with grants nobody remembers. Use the query below to list everything assigned to the user.
SELECT PermissionSet.Name, PermissionSet.Label, PermissionSet.IsOwnedByProfile
FROM PermissionSetAssignment
WHERE AssigneeId = '005XXXXXXXXXXXXXXX'Then inspect each permission set for dangerous flags.
SELECT SobjectType, PermissionsRead, PermissionsCreate, PermissionsEdit, PermissionsDelete, PermissionsViewAllRecords, PermissionsModifyAllRecords
FROM ObjectPermissions
WHERE Parent.Name = 'Integration_Account_Read'Any row with PermissionsDelete, PermissionsViewAllRecords, or PermissionsModifyAllRecords set to true needs a written reason.
Mistake 7: No network or session restrictions
A user with no login IP ranges can authenticate from anywhere. If the credentials leak, an attacker can use them from any network. Set login IP ranges where the integration has a fixed address, and keep the session settings tight.
Quick reference
| Mistake | Risk | Fix |
|---|---|---|
| System Administrator profile | Full org access | Minimal profile plus permission set |
| View All / Modify All | Bypasses sharing | Fix the sharing or field cause |
| Extra Create/Edit/Delete | Data loss | Grant only what the requirements list shows |
| Shared human account | Unstable access, unclear audit trail | Dedicated user |
| All fields open | Sensitive data exposure | List fields explicitly |
| Stacked permission sets | Hidden grants | Review assignments regularly |
| No IP restriction | Leaked credentials usable anywhere | Login IP ranges |
A least-privilege baseline
The permission set below grants API access and read-only access to one object and one field. It sets no View All or Modify All flags.
<?xml version="1.0" encoding="UTF-8"?>
<PermissionSet xmlns="http://soap.sforce.com/2006/04/metadata">
<description>Read-only access to Account for the integration user</description>
<fieldPermissions>
<editable>false</editable>
<field>Account.Industry</field>
<readable>true</readable>
</fieldPermissions>
<hasActivationRequired>false</hasActivationRequired>
<label>Integration Account Read</label>
<objectPermissions>
<allowCreate>false</allowCreate>
<allowDelete>false</allowDelete>
<allowEdit>false</allowEdit>
<allowRead>true</allowRead>
<modifyAllRecords>false</modifyAllRecords>
<object>Account</object>
<viewAllRecords>false</viewAllRecords>
</objectPermissions>
<userPermissions>
<enabled>true</enabled>
<name>ApiEnabled</name>
</userPermissions>
</PermissionSet>Exercise
An integration gets "insufficient access" when reading Contact records it should see. A colleague suggests enabling View All Data on the user. What should you check first, and why is the suggestion a poor fix?
Show answer
Check the Contact object permission, field-level security, and the sharing model (such as the organization-wide default and sharing rules) to find the specific cause. View All Data bypasses sharing for every object in the org, so it fixes this error by granting far more access than the integration needs.
Exercise
Which two SOQL queries help you find unexpected grants on an integration user, and what do they return?
Show answer
Query PermissionSetAssignment by AssigneeId to list every permission set and profile-owned permission set assigned to the user. Then query ObjectPermissions by the permission set name to see Delete, View All, and Modify All flags on each object.