Agentic AI Security: Tool Poisoning and Audit Trails
Explore agentic AI security risks, including MCP tool poisoning, and learn how governance, permissions, approvals, and audit trails reduce exposure.
Salesforce provides a robust security model to protect data, ensuring that users have access only to the data they need. Apex, Salesforce’s proprietary programming language, follows this model to enforce security and sharing rules. Understanding Apex security best practices is crucial for developing secure and compliant applications.
Apex operates in system context, meaning it runs with elevated privileges by default. However, developers should enforce security checks to prevent unauthorized data access.
Example:
public with sharing class AccountHandler { public List<Account> getUserAccounts() { return [SELECT Id, Name FROM Account]; } }
Even with sharing settings, users may not have permission to view certain fields or objects. Apex code must respect these permissions using:
Apex does not automatically enforce CRUD (Create, Read, Update, Delete) and FLS (Field-Level Security). Always validate access before querying or modifying records.
if (Schema.sObjectType.Account.isUpdateable()) {
Account acc = [SELECT Id FROM Account LIMIT 1];
acc.Name = ‘Updated Name’;
update acc;
}
Record sharing in Salesforce is determined by:
If declarative sharing is not sufficient, Apex Managed Sharing allows programmatic record access using the Share object.
Example:
AccountShare accShare = new AccountShare();
accShare.AccountId = ‘001XXXXXXXXXXXXXXX’;
accShare.UserOrGroupId = ‘005XXXXXXXXXXXXXXX’;
accShare.AccessLevel = ‘Read’;
insert accShare;
Retrieve the current user’s ID:
Id currentUserId = UserInfo.getUserId();
Check profile or role:
String userProfile = [SELECT Profile.Name FROM User WHERE Id = :currentUserId].Profile.Name;
Security is a crucial aspect of Apex development in Salesforce. By enforcing user permissions, adhering to record-sharing rules, and following best practices, developers can build secure applications that align with Salesforce’s robust security framework.
Get Started
Share a few details about your goals: a Mirketa consultant will follow up within one business day.