Sub topic 13
Security review and publishing on AppExchange
This chapter assumes you can already build and promote a package version with the Salesforce CLI. It also assumes you know Apex security basics (sharing, CRUD, and field-level security). It covers what Salesforce checks before it lets you list a managed package on AppExchange, how to prepare for that check, and what happens after approval.
What the security review is
The security review is a mandatory assessment of your package by the Salesforce AppExchange Security Review team. You need it to list a solution publicly on AppExchange. It is separate from installing the package. A promoted (released) version can be installed in any org by anyone who has the install URL or package ID, even if the package never passed review. Review controls only whether Salesforce will list it and promote it as a trusted solution.
The review looks at three things:
- Your code and components. Apex, Lightning components, Visualforce, and other metadata are scanned and checked by hand.
- Your external services. If your app calls a web service you operate, such as a backend API or hosted web app, that service is tested too.
- Your documentation and supporting material. You supply test credentials, architecture notes, and answers to security questionnaires.
Prerequisites before you submit
Complete these before you open the submission.
- A promoted, released managed 2GP version. Beta versions cannot be submitted. Promotion is covered in an earlier chapter.
- A Partner Community membership, and a Partner Business Org (PBO) tied to your company.
- An AppExchange listing started in the Partner Console. The listing is the record that holds your marketing text, screenshots, pricing model, and the package you are submitting.
- Your package linked to the listing. You connect the Dev Hub that owns the package to the Partner Console so it can see your package and its versions.
- Clean scan results. Salesforce runs its own scans, but you should fix problems first.
- A demo or test org where reviewers can run the app, and credentials for any external service.
The details of the Partner Console screens change between releases. Check the current Partner Console and ISV documentation for exact menu names and the current fee schedule before you plan a launch date.
Scan your own code first
Reviewers run scanners against your package. Running comparable tools yourself catches most of the problems that would otherwise cause a failed review. Salesforce Code Analyzer is a CLI plugin that bundles static analysis engines, including PMD for Apex and ESLint for JavaScript.
sf plugins install code-analyzer
sf code-analyzer run --workspace force-app --rule-selector AppExchange --output-file results.htmlThe AppExchange selector limits the run to rules that match the review's expectations. Rule selectors and flags differ between Code Analyzer major versions, so run sf code-analyzer run --help if the command above is rejected. Treat a clean local scan as necessary but not sufficient. Reviewers also test behavior by hand, which a static scan cannot do.
The issues that most often fail a review
Most findings fall into a small set of categories.
| Category | What reviewers look for | Typical fix |
|---|---|---|
| CRUD and field-level security | Apex that reads or writes records without checking the running user's permissions | Use `WITH USER_MODE` in SOQL, `AccessLevel.USER_MODE` in DML, or `Security.stripInaccessible` |
| Sharing | Classes declared without a sharing keyword, or `without sharing` with no justification | Declare `with sharing` by default and document any exception |
| Injection | SOQL, SOSL, or dynamic Apex built from unescaped user input | Use bind variables or `String.escapeSingleQuotes` |
| Cross-site scripting | Unescaped output in Visualforce or unsafe DOM writes in JavaScript | Use platform escaping and avoid `innerHTML` and `lwc:dom="manual"` with untrusted data |
| Secrets in code | API keys, passwords, or tokens in Apex, static resources, or custom settings shipped in the package | Use Named Credentials or protected custom metadata that the subscriber fills in |
| External services | Weak TLS, missing authentication, or outdated libraries on servers you operate | Patch, harden, and supply a test account |
The permission fixes are the most common, so here is a pattern that passes.
public with sharing class AccountService {
public static List<Account> findByName(String searchTerm) {
String pattern = '%' + String.escapeSingleQuotes(searchTerm) + '%';
return [
SELECT Id, Name, Industry
FROM Account
WHERE Name LIKE :pattern
WITH USER_MODE
LIMIT 200
];
}
public static void rename(Id accountId, String newName) {
Account acc = new Account(Id = accountId, Name = newName);
Database.update(acc, AccessLevel.USER_MODE);
}
}WITH USER_MODE enforces object permissions, field-level security, and sharing rules for the running user. The bind variable :pattern already prevents injection. The escapeSingleQuotes call matters only if you later switch to dynamic SOQL. It is shown here because reviewers look for it wherever user input reaches a query string.
Submission and the review cycle
Submit through the Partner Security Portal, which you reach from the Partner Console. You select the package version, attach test credentials, and answer the questionnaire. Salesforce queues the submission, then returns a report of findings. If anything fails, you receive a list of issues with severity and location.
The loop for fixing failures follows the package workflow you already know:
- Fix the code in your source project.
- Build a new package version with
sf package version create. - Promote it with
sf package version promote. - Resubmit the new version in the portal.
Every fix needs a new version, because released versions are immutable. Plan your version numbers so that rejected builds do not consume the version you intended to ship. For example, reserve the minor version for the release and let the build number absorb the retries.
A review that passes applies to the package. For later versions, Salesforce may require a new review depending on how much changed, and it re-reviews listed solutions periodically. Keep your scan results and your documentation current instead of rebuilding them each time.
Publishing the listing
After approval, you finish and publish the listing.
- Complete the listing content: description, screenshots, a demo video or trial option, support contact, and legal links.
- Select the approved package version as the one customers install.
- Choose the pricing and licensing model. Paid or per-user licensed apps connect to the License Management App, covered in the next chapter.
- Submit the listing for the AppExchange team's content review.
- Publish it. The listing becomes visible to customers on AppExchange.
Publishing a new version later means updating the listing to point at the newer approved version. Subscribers do not move automatically. They upgrade through the install flow, or through a push upgrade if you use one.
Common mistakes
- Submitting a beta version. Promote first.
- Skipping the self-scan. Findings you could have caught locally cost you a full review cycle.
- Missing test credentials. Reviewers cannot test what they cannot log into, and the submission stalls.
- Unreviewed external services. A secure package that calls an unpatched server still fails.
- Treating review as a one-time event. Later versions and periodic re-reviews apply.
Exercise
Your security review came back with a CRUD/FLS finding in an Apex class. You fixed the class locally. List the steps needed to get the fix in front of reviewers, and explain why you cannot just edit the version you submitted.
Show answer
Build a new package version from the fixed source with sf package version create, promote it with sf package version promote, then resubmit that new released version in the Partner Security Portal. You cannot edit the submitted version because released package versions are immutable. The code in a version is fixed when it is built, so any change requires a new version.