sf-security
Implement Salesforce Commerce security — SLAS OAuth 2.1, session management, CSRF tokens, XSS prevention (isprint encoding in ISML), PCI compliance, RBAC in Business Manager, OWASP Top 10 protections, and Salesforce Shield for B2B. Use when implementing authentication or security controls.
Best use case
sf-security is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Implement Salesforce Commerce security — SLAS OAuth 2.1, session management, CSRF tokens, XSS prevention (isprint encoding in ISML), PCI compliance, RBAC in Business Manager, OWASP Top 10 protections, and Salesforce Shield for B2B. Use when implementing authentication or security controls.
Teams using sf-security should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/sf-security/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How sf-security Compares
| Feature / Agent | sf-security | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Implement Salesforce Commerce security — SLAS OAuth 2.1, session management, CSRF tokens, XSS prevention (isprint encoding in ISML), PCI compliance, RBAC in Business Manager, OWASP Top 10 protections, and Salesforce Shield for B2B. Use when implementing authentication or security controls.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# sf-security
Implement Salesforce Commerce security across B2C and B2B platforms.
## Before Writing Code
Always fetch the latest official documentation BEFORE implementing security controls:
- **SLAS Security**: WebSearch "Salesforce SLAS OAuth 2.1 security guide 2026" and WebFetch official Commerce API docs
- **B2C Commerce Security**: WebSearch "Salesforce B2C Commerce security best practices 2026" and WebFetch the security reference
- **Salesforce Security Guide**: WebSearch "Salesforce security guide OWASP 2026" and WebFetch official documentation
- **PCI DSS Requirements**: WebSearch "PCI DSS v4 requirements ecommerce 2026" for current compliance standards
**Why:** OAuth flows, CSRF protection patterns, encoding modes, and PCI requirements evolve. Live docs ensure correct implementation of current security standards.
## Conceptual Architecture
### Authentication
**SLAS (B2C Commerce) -- OAuth 2.1 with PKCE:**
| Client Type | Flow | Use Case |
|-------------|------|----------|
| Public (browser/PWA Kit) | `authorization_code_pkce` | Guest and registered users |
| Private (server-side) | `client_credentials` | Guest sessions |
| Private (server-side) | `authorization_code` | Registered users |
| Any | Refresh token | Session extension |
PKCE (Proof Key for Code Exchange) is required for all public client flows. Guest tokens enable anonymous shopping before login.
**Salesforce OAuth (B2B Commerce):**
| Flow | Use Case |
|------|----------|
| Connected Apps | OAuth application registration |
| JWT Bearer | Server-to-server authentication |
| Web Server Flow | User authorization with redirect |
**Session Management:**
- Secure, random, unpredictable session IDs
- Token expiration with renewal handling
- Secure cookies: HttpOnly, Secure, SameSite attributes
- Session invalidation on logout, timeout, or security events
**Token Lifecycle:**
| Token | Typical TTL | Storage |
|-------|-------------|---------|
| Access Token | 30 minutes | Memory or httpOnly cookie |
| Refresh Token | 30 days | httpOnly cookie (never localStorage) |
| CSRF Token | Per request | Hidden form field or custom header |
### XSS Prevention
**B2C Commerce (ISML):**
| Encoding Mode | Context |
|---------------|---------|
| `htmlcontent` | HTML body text |
| `htmlsinglequote` / `htmldoublequote` | HTML attributes |
| `jshtml` | JavaScript strings in HTML |
| `jsonvalue` | JSON data |
| `uricomponent` | URL parameters |
Always use `<isprint>` with explicit encoding. Never use raw `${variable}` for user-controlled data. Set Content Security Policy headers to restrict script sources.
**B2B Commerce (LWC):**
- Automatic encoding in Lightning template expressions
- Lightning Web Security (LWS) replaces Locker Service (Spring '23+)
- Use `textContent` instead of `innerHTML` in JavaScript
- Use `lightning-formatted-*` components for safe rendering
### Content Security Policy
| Directive | Purpose |
|-----------|---------|
| `default-src` | Fallback for all resource types |
| `script-src` | Allowed script sources (restrict to self and trusted CDNs) |
| `style-src` | Allowed stylesheet sources |
| `img-src` | Allowed image sources |
| `connect-src` | Allowed API/fetch targets |
| `frame-ancestors` | Clickjacking protection |
Configure CSP headers in Business Manager or via server configuration. Use `nonce` or `hash` for inline scripts rather than `unsafe-inline`.
### CSRF Protection
**B2C Commerce:** Validate tokens with `CSRFProtection.validateRequest()` in controllers. Generate tokens with `CSRFProtection.generateToken()`. Include hidden token fields in all state-changing forms. Use double-submit cookie pattern for AJAX.
**B2B Commerce:** Built-in Salesforce CSRF protection. `<lightning-input>` includes tokens automatically. `@AuraEnabled` Apex methods have CSRF protection.
### Input Validation
| Layer | Technique |
|-------|-----------|
| Client-side | HTML5 validation, JavaScript checks (UX only, not security) |
| Server-side | Whitelist validation, type checking, length limits |
| Form definitions | SFCC XML form definitions with validation rules |
| Query API | Parameterized queries -- never string concatenation |
Always validate on the server. Client-side validation is a convenience, not a security measure.
### PCI Compliance
| Requirement | Implementation |
|-------------|---------------|
| Tokenization | Never store raw card numbers; use tokenized payment methods |
| SAQ-A Scope | Use hosted payment fields to minimize PCI scope |
| TLS 1.2+ | Enforce for all API communication and payment processing |
| Log Masking | No card data in application logs |
| Gateway | Use Salesforce Commerce Payments or validated third-party processors |
### RBAC (Role-Based Access Control)
**B2C Commerce:** Business Manager roles (Admin, Merchant, Content) with granular, site-specific permissions. Custom roles for organization-specific needs.
**B2B Commerce:** Salesforce profiles and permission sets. Buyer permissions control ordering (browse, cart, checkout, approve). Account hierarchy restricts visibility based on relationships.
**B2B Sharing Rules:**
- Organization-wide defaults set baseline visibility
- Sharing rules grant additional access to specific groups
- Account hierarchies provide implicit sharing up the chain
- Manual sharing for ad-hoc access grants
### OWASP Top 10 Protections
| Threat | Mitigation |
|--------|------------|
| Injection | Parameterized queries via Query API; input whitelisting |
| Broken Auth | SLAS/OAuth best practices; MFA where available; strong password policies |
| Sensitive Data Exposure | Salesforce Shield encryption at rest (B2B); TLS in transit; log masking |
| Security Misconfiguration | Disable dev features in production; change default credentials; suppress stack traces |
| Access Control | Authorization checks on every request; least privilege principle |
| Monitoring | Log authentication events, failed logins, suspicious activity |
## Best Practices
### Implementation
- Always encode output using the correct mode for context (HTML, JS, URL, JSON).
- Validate input at the boundary -- whitelist acceptable values, reject everything else.
- Implement CSRF protection on all state-changing operations.
- Enforce TLS 1.2+ for all communications.
### Credentials and Access
- Rotate API keys, client secrets, and certificates on a regular schedule.
- Grant minimum necessary permissions (least privilege).
- Restrict customer data access to authorized users and systems only.
- Store credentials in Business Manager services or Salesforce Named Credentials, never in code.
### Operations
- Log authentication events, failed login attempts, and suspicious activity.
- Audit code for security issues regularly; conduct penetration testing.
- Keep dependencies updated; scan for known vulnerabilities.
- Maintain an incident response plan for security breaches.
---
Fetch the SLAS OAuth 2.1 guide, B2C Commerce security reference, and Salesforce OWASP documentation for exact token flows, encoding specifications, and compliance requirements before implementing.Related Skills
woo-security
Implement WooCommerce security — nonces, capabilities, input sanitization, output escaping, data validation, PCI compliance considerations, and WordPress security best practices. Use when hardening a WooCommerce store or reviewing security posture.
webmcp-security
Implement WebMCP security best practices — permission model, data minimization, honest descriptions, input validation, fingerprinting prevention, and fraud mitigation. Use when auditing or hardening WebMCP tool implementations.
spree-security
Secure a Spree deployment — Rails credentials and env-var hygiene, Devise auth (Spree v5 ships it in-core; `spree_auth_devise` is archived), CanCanCan authorization rules, Doorkeeper OAuth2 scopes, Storefront publishable key vs admin API key, webhook HMAC verification, OWASP Top 10 for Rails (mass assignment, CSRF, SQL injection via Ransack, XSS, IDOR through prefixed IDs), PCI scope (Spree never touches raw cards thanks to gateway tokenization), and multi-store data isolation. Use when auditing a Spree app, hardening a deploy, or addressing a security incident.
shopify-security
Secure Shopify applications — HMAC webhook verification, session token validation, OAuth scope management, Content Security Policy, GDPR mandatory webhooks, input validation, and secure coding practices. Use when implementing Shopify security features.
saleor-security
Secure Saleor applications — JWT authentication, OIDC integration, App tokens, permission model, rate limiting, CORS, and security headers. Use when configuring Saleor security.
medusa-security
Secure Medusa v2 applications — authentication strategies, API key types (publishable vs secret), CORS configuration, JWT and cookie secrets, admin vs store auth, and session management. Use when configuring security.
magento-security
Implement Magento 2 security — CSP, 2FA, CSRF protection, ACL, admin security configuration, input validation, and security best practices. Use when hardening a Magento installation or reviewing security posture.
bc-security
Implement BigCommerce security — OAuth token management, API authentication, webhook verification, CSP, input validation, PCI compliance, and app security best practices. Use when hardening integrations or reviewing security posture.
woo-testing
Test WooCommerce extensions — PHPUnit unit/integration tests, WP test suite, WooCommerce test helpers, E2E with Playwright, and WP-CLI test scaffolding. Use when writing tests for WooCommerce plugins or setting up a test environment.
woo-shipping
Build WooCommerce shipping methods — WC_Shipping_Method, shipping zones, shipping classes, rate calculation, tracking, and integration with carriers. Use when creating custom shipping integrations or configuring shipping logic.
woo-setup
Install WooCommerce, configure the development stack, and set up a local dev environment with WP-CLI, Docker, or wp-env. Use when setting up a new WooCommerce project or development environment.
woo-plugin-dev
Create WooCommerce extensions/plugins — file structure, main plugin file, activation/deactivation hooks, custom database tables, autoloading, and WordPress plugin API. Use when building new WooCommerce extensions or structuring plugin code.