Click a node to navigate. Scroll to zoom. Drag to pan.
Loading graph...
Security Best Practices & Anti-Patterns
For CTA scenarios, demonstrating awareness of anti-patterns is just as valuable as knowing best practices. The board often presents scenarios with built-in anti-patterns to test whether you identify and correct them.
Sharing Model Best Practices
Best Practices
Practice
Why It Matters
Start with Private OWD for all objects, then open up
You can add access but never remove it below OWD. Starting open is irreversible without changing OWD.
Design role hierarchy for data access, not HR org chart
The hierarchy controls record visibility, not reporting. An org chart hierarchy creates unnecessary sharing.
Prefer criteria-based sharing rules over ownership-based when possible
Criteria rules are based on field values (stable), not record ownership (changes frequently).
Limit sharing rules to 50 per object as a practical maximum
More than 50 indicates the OWD or hierarchy design is wrong. Sharing recalculation time increases linearly.
Use public groups to abstract sharing targets
Groups can be managed without modifying sharing rules. Share with “West Region Team” not individual roles.
Document every sharing mechanism and its justification
The CTA board will ask why you chose each mechanism. Future admins need to understand the design.
Test sharing with different user profiles before go-live
Create test users at each hierarchy level and verify record visibility matches requirements.
Anti-Patterns
Anti-Pattern
Risk
Correct Approach
Setting OWD to Public Read/Write “because it’s simpler”
Cannot restrict access for any user; no audit trail of access decisions
Start Private; open up with sharing rules
Mirroring the HR org chart in role hierarchy
Creates deep hierarchies (10+ levels); performance degradation; unnecessary visibility
Design for data access patterns; keep 5-7 levels max
Using manual sharing for systematic access
Manual shares are deleted on ownership change; cannot be audited at scale
Use sharing rules or Apex managed sharing
Creating hundreds of sharing rules
Sharing recalculation takes hours; performance degrades; impossible to audit
Redesign role hierarchy or OWD
Giving View All / Modify All to bypass sharing issues
Completely bypasses the sharing model; equivalent to admin access on that object
Fix the underlying sharing design
Ignoring external OWD
External users may see other companies’ data
Set external OWD separately (usually Private)
Not considering LDV impact
Private OWD on 100M+ record objects causes massive share tables
Evaluate sharing set size; consider HVCP sharing sets
Decoupled from Salesforce username; survives username changes and org migrations
Implement JIT provisioning (custom handler when possible)
Eliminates manual user creation; keeps user attributes synchronized with IdP
Always enable MFA for direct login and validate IdP MFA for SSO
Salesforce requires MFA; IdP-based MFA satisfies the requirement for SSO logins
Use Named Credentials for all callout authentication
Keeps credentials out of code and version control; platform manages token lifecycle
Configure Single Logout for security-sensitive environments
Prevents orphaned sessions; user logs out everywhere when they log out anywhere
Grant minimum OAuth scopes
Each scope is an attack surface; “full” scope is rarely needed
Rotate Connected App secrets and certificates on a schedule
Limits the exposure window if credentials are compromised
Anti-Patterns
Anti-Pattern
Risk
Correct Approach
Hardcoding credentials in Apex
Credentials in version control; visible to all developers
Use Named Credentials
Using Username-Password OAuth flow
Blocked by default since Spring ‘23; credentials sent in the request body (over TLS, but still higher risk than token-based flows); Salesforce recommends alternate flows
Use JWT Bearer or Client Credentials for S2S
Not implementing Single Logout
User logs out of IdP but Salesforce session remains active
Configure SLO in SAML settings
Using “full” OAuth scope for all Connected Apps
Over-privileged access; any compromise gives complete access
Grant minimum scopes per integration
Skipping MFA “because we have SSO”
SSO without IdP MFA means single-factor authentication
Verify IdP enforces MFA or add Salesforce MFA
Multiple SSO configurations without clear routing
Users confused about which login button to use; support burden
Use Login Discovery to route users automatically
Not revoking Connected App access when integrations are decommissioned
Users cannot search or filter on the field; workflow rules may break
Choose scheme based on functional requirements
Not testing encrypted field impact on reports
Reports that filter or sort on encrypted fields fail silently
Test every report that references encrypted fields
Enabling encryption without a key rotation plan
Stale keys increase risk; compliance audits require rotation evidence
Establish key rotation cadence before go-live
Forgetting to encrypt the search index
Encrypted field values may appear in the search index unencrypted
Enable search index encryption alongside field encryption
Portal Security Best Practices
Best Practices
Practice
Why It Matters
Set External OWD to Private for most objects
Default assumption: external users should not see other companies’ data
Audit guest user profile quarterly
Guest user permissions creep; Salesforce tightens rules regularly
Use Sharing Sets for HVCP users instead of sharing rules
Sharing Sets are optimized for high volume; sharing rules don’t apply to HVCP
Test with each external license type
Different licenses have different sharing behaviors; verify each one
Remove all unnecessary object permissions from guest user
Guest users should have explicit opt-in access only
Never expose PII to guest users
Data breach risk for unauthenticated visitors
Use “Secure guest user record access” setting
Ensures records created by guest users are owned by the site’s default owner
Anti-Patterns
Anti-Pattern
Risk
Correct Approach
Using same OWD for internal and external
External users may see data from other companies
Set External OWD separately
Giving guest users API access
Unauthenticated API access enables data scraping
Disable guest API access unless specifically justified
Using Customer Community Plus when Community suffices
Unnecessary cost; adds role hierarchy complexity
Start with Community; upgrade only if reporting/hierarchy needed
Not testing implicit sharing for portal users
Portal users may see parent Account data unintentionally
Audit implicit sharing paths for each external user type
Sharing too broadly via Sharing Sets
Records from one customer’s Account visible to another customer
Use the narrowest possible lookup match
Programmatic Security Best Practices
Best Practices
Practice
Why It Matters
Default to with sharing on all Apex classes
Enforces the running user’s sharing model; secure by default
Use USER_MODE for SOQL and DML
Enforces CRUD + FLS + sharing in one call
Always use bind variables in SOQL
Prevents SOQL injection; parameterized queries
Use Named Credentials for all callouts
Keeps secrets out of code; platform manages authentication
Never log sensitive data (PII, credentials, tokens)
Logs are accessible to admins; may be exported
Use inherited sharing for utility classes
Safe default that inherits the caller’s context
Document every without sharing usage
Each bypass must be justified and reviewed
Anti-Patterns
Anti-Pattern
Risk
Correct Approach
No sharing keyword on Apex classes
Defaults to without sharing at the entry point of a transaction; inherits context when called from another class. Either way, intent is unclear.
Always specify with sharing or inherited sharing
Using string concatenation in SOQL
SOQL injection vulnerability
Use bind variables or String.escapeSingleQuotes()
Trusting page layout to hide fields (no FLS check in Apex)
API access bypasses page layouts; users see all fields
Enforce FLS with USER_MODE or stripInaccessible()
Storing OAuth tokens in Custom Settings/Custom Metadata
Visible to all admins; in version control
Use Named Credentials
Using without sharing on controllers
All users see all records regardless of sharing model
Use with sharing on controllers; without sharing only in narrow service methods
Security Architecture Review Checklist
Use this visual checklist when reviewing any CTA scenario to ensure every layer of the security model is addressed.
Figure 1. Security review follows four independent columns: authentication (who you are), authorization (what you can do), data protection (how data is safeguarded at rest), and integration security (how external systems connect). All four must be addressed in a CTA scenario response.
Governance Best Practices
Practice
Description
Frequency
Security Health Check
Run Salesforce Health Check; address all critical/high findings
Monthly
Permission audit
Review all profiles, Permission Sets, and Permission Set Groups
Quarterly
Sharing rule review
Verify all sharing rules are still needed; remove obsolete rules
Quarterly
Guest user audit
Review guest user profile, sharing rules, and accessible data
Quarterly
Connected App audit
Review all Connected Apps; revoke unused integrations
Quarterly
Encryption key rotation
Rotate encryption keys per compliance requirements
Per policy (annually minimum)
Event Monitoring review
Review login anomalies, data export events, API patterns
Weekly/Monthly
User deprovisioning
Verify SSO-deprovisioned users are deactivated in Salesforce