Back to skill

Security audit

Salesforce AI Agentforce

Security checks for vulnerabilities and agentic risk

Overview

This is a documentation-only Salesforce Agentforce skill, but some examples can lead users to update CRM records or publish AI output without enough permission, data-handling, and review safeguards.

Review the Salesforce examples before using them in a real org. Treat the Apex snippets as drafts: add user-mode SOQL/DML or explicit CRUD/FLS checks, minimize and classify CRM data sent to models, isolate untrusted record text in prompts, validate generated output, and require human approval before posting to Chatter or writing business records. Use live-action preview only in an isolated test org unless you have confirmed the actions are safe to execute.

Vulnerability Patterns
  • Insecure Skill Coding PracticesFinds exploitable flaws such as hardcoded secrets or command injection
  • Skill Instruction HijackingAlters the agent's session goals or safety constraints when the skill loads
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
  • Embedded Malicious CodeShips malicious scripts inside the skill and executes them locally
Findings (2)

T09 · Insecure Skill Coding Practices

Warning
Location
references/models-api.md:143
Finding

Salesforce Apex examples perform database operations without consistent CRUD and field-level authorization enforcement

Content
View full analysis
cases = [ SELECT Id, Subject, Description FROM Case WHERE Id IN :caseIds WITH USER_MODE ]; List toUpdate = new List(); for (Case c : cases) { try { // Generate summary using Models API String summary = generateCaseSummary(c); if (String.isNotBlank(summary)) { c.AI_Summary__c = summary; toUpdate.add(c); } } catch (Exception e) { System.debug(LoggingLevel.ERROR, 'AI Summary Error for Case ' + c.Id + ': ' + e.getMessage()); } } // Update records if (!toUpdate.isEmpty()) { update toUpdate; } } ``` The Opportunity batch example performs both its query and update without user-mode enforcement: ```apex public Database.QueryLocator start(Database.BatchableContext bc) { // Query records needing AI summary return Database.getQueryLocator([ SELECT Id, Name, Description, StageName, Amount FROM Opportunity WHERE AI_Summary__c = null AND Description != null ORDER BY CreatedDate DESC ]); } public void execute(Database.BatchableContext bc, List scope) { List toUpdate = new List(); for (Opportunity opp : scope) { try { String summary = generateOpportunitySummary(opp); if (String.isNotBlank(summary)) { opp.AI_Summary__c = summary; toUpdate.add(opp); success ...[truncated 2744 chars]
Remediation
View remediation
opportunities = [ SELECT Id, Name, Description, StageName, Amount FROM Opportunity WHERE AI_Summary__c = null AND Description != null WITH USER_MODE ]; ``` 2. Use user-mode DML rather than default system-mode DML: ```apex Database.update(toUpdate, AccessLevel.USER_MODE); ``` 3. Where user-mode operations cannot be used, verify object and field permissions explicitly: ```apex if (!Schema.sObjectType.Case.isUpdateable() || !Schema.sObjectType.Case.fields.AI_Summary__c.isUpdateable()) { throw new SecurityException('Insufficient permission to update the AI summary.'); } ``` 4. Apply equivalent checks to every field read from Case, Opportunity, and Account. 5. Use `Security.stripInaccessible` as an additional defensive layer before DML or serialization. 6. Ensure every externally reachable entry point validates record identifiers and authorization before enqueuing asynchronous work. 7. Add negative authorization tests using users who lack access to the queried source fields and `AI_Summary__c`. ]]>

T09 · Insecure Skill Coding Practices

Warning
Location
references/models-api.md:176
Finding

Record-controlled text is inserted into model prompts without prompt-injection isolation or output validation

Content
View full analysis
Remediation
View remediation
\n' + 'Subject: ' + c.Subject + '\n' + 'Description: ' + c.Description + '\n' + ''; ``` 2. Prefer structured response formats with a fixed schema and strict length limits. 3. Validate generated output before storing or publishing it. Reject content that contains unexpected instructions, links, sensitive values, unsupported claims, or disallowed language. 4. Apply Salesforce trust, safety, grounding, and moderation features where available. 5. Do not automatically publish model output to Chatter. Store it as a draft and require review for externally visible or business-significant content. 6. Minimize prompt context and exclude sensitive or unnecessary fields. 7. Record provenance and clearly label generated content as unverified. 8. Add adversarial tests covering instructions embedded in descriptions, delimiter-breaking attempts, requests to reveal context, and misleading publication content. ]]>
Vulnerability Patterns
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
Findings (9)

Hidden Instructions

High
Category
Prompt Injection
Confidence
70% confidence
Finding

Hidden instructions were detected in comments or invisible text. These could contain malicious directives. Manual review is recommended.

Content

Scanner excerpt · references/custom-lightning-types.md (reported line 1)May include surrounding context.

md
<!-- Parent: sf-ai-agentforce/SKILL.md -->
<!-- TIER: 3 | DETAILED REFERENCE -->
<!-- Read after: SKILL.md -->
<!-- Purpose: LightningTypeBundle for custom agent action UIs (API 64.0+) -->

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
87% confidence
Finding

The manifest says this skill should trigger when maintaining Builder metadata, Prompt Builder templates, Models API items, and related metadata XML files, and explicitly excludes agent testing and Agent Script workflows. This reference file, however, documents shared lifecycle commands such as creating agent users and activating/deactivating agents, which are broader org/agent operational tasks rather than Builder metadata authoring itself.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The manifest frames the skill as the metadata path for Builder-managed topics/actions, Prompt Builder templates, GenAiFunction/GenAiPlugin, Models API, and custom Lightning types. This section documents sf agent create, sf agent generate agent-spec, and sf agent generate template, including spec-driven and packaging-oriented workflows that are not the Builder metadata files or configuration tasks described in the manifest.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
88% confidence
Finding

The preview documentation advertises --use-live-actions to execute real Apex/Flows but does not clearly warn that this can trigger actual side effects in the target org. In an agent skill context, users may reasonably treat preview as safe simulation, so omission of a strong warning increases the risk of unintended data changes, external calls, or operational actions during testing.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The example encourages sending case/opportunity descriptions and related business context directly to an AI model, but it does not place a prominent warning at the example site about data classification, customer confidentiality, retention, or organizational approval requirements. Even though the document later includes a general best-practices note about avoiding PII unless necessary, readers can easily copy this pattern as-is and expose sensitive customer or commercial data to AI processing without adequate review.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The Chatter example automatically posts AI-generated analysis to a record feed, which can broaden visibility of generated content and create downstream integrity risks if the model output is inaccurate, sensitive, or policy-violating. The example lacks a strong local warning that Chatter posts may be visible to multiple users and that AI output should be reviewed, sanitized, and access-scoped before publication.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Low
Category
Not specified by scanner
Confidence
84% confidence
Finding

The file header says its purpose is a CLI reference for Builder metadata workflows, shared lifecycle commands, and Agent Script handoff. Later, after stating Agent Script commands belong to another skill, it still provides a full command section with syntax and flags for sf agent generate authoring-bundle, which goes beyond a mere handoff and contradicts the stated intent.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
93% confidence
Finding

The renderer example sets currencyCode to USD, which imposes a specific locale/currency representation in user-facing output. The document does not indicate that this is optional, user-selectable, or limited to a US-specific use case, so it can conflict with language/locale policy expectations.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
84% confidence
Finding

The example schema limits country to United States, Canada, Mexico, and United Kingdom, which bakes a locale/geography constraint into a general customer-address example. Because the file presents this as a generic pattern rather than a region-specific implementation, it may violate policy requiring locale constraints to be justified or user-selectable.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.