/b2c-cli:b2c-securityfrom b2c-cli
Scans B2C Commerce cartridge JavaScript and site data for security issues using the b2c CLI. Covers open redirects, object query injection, CSRF, weak crypto, hardcoded credentials, insecure cookies, mass assignment, and OCAPI demo client ID.
Ships in b2c-cli. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Use b2c security scan (preview) to find security problems in B2C Commerce cartridge code, then triage and fix them. The scan runs locally on the working tree, needs no instance or credentials, and takes well under a second for a typical storefront.
Tip: If
b2cis not installed globally, usenpx @salesforce/b2c-cliinstead.
MCP parity: If the
b2c-dx-mcpserver is connected,security_scancoversb2c security scanwith the same rules, suppressions, and baseline. Route findings depend on cartridge order: checkcartridgePathSourceand passsiteIdto use a site's path from the instance.
# Scan all cartridges under the current directory (folders with a .project file)
b2c security scan
# Scan one cartridge or file
b2c security scan cartridges/app_custom
# Structured output for analysis (prefer this when you will read the results)
b2c security scan --json
# List the rules and what they find
b2c security rules
Findings in SFRA and SiteGenesis base cartridges (app_storefront_base, modules, app_storefront_controllers, ...) are reported with referenceCartridge set. They are real for any storefront that deploys those cartridges; fix them from the project's own cartridge (for example server.prepend()), not by editing the base. --exclude-reference-cartridges leaves them out.
Site data in the project (such as a site_template folder) is checked too: services.xml, preferences.xml, attribute definitions, csrf-whitelists.xml, and OCAPI settings JSON. Server-side .js and .ds files are scanned; cartridge/client/, cartridge/static/, node_modules/, and minified files are skipped. Legacy .ds files with type annotations can't be parsed yet and are reported under errors.
Each finding in --json output has ruleId, severity, confidence, message, location (file, startLine, startColumn), snippet, remediation, and docsUrl.
confidence: high findings as real unless the code proves otherwise.medium and low confidence, check what the rule could not see: whether a redirect target is validated in a helper, whether a "secret" is a test value, whether a query value is constant.Rule references, with examples and fixes: b2c docs search "security rules" or the docsUrl on each finding.
| Rule | Fix |
|---|---|
object-query-injection | Use {0} placeholders and pass values as arguments: queryCustomObject(type, 'custom.email = {0}', email) |
file-path-from-request | Return a directory from the processMultipart() callback (the platform names the file), or generate the name (UUID) with an allowlisted extension; return null for unexpected fields |
open-redirect | Redirect to URLUtils URLs, or check the target against an allowlist before res.redirect() |
hardcoded-credentials | Move the value to a service credential (read via LocalServiceRegistry) or a password site preference; rotate it |
weak-crypto | Cipher with AES/GCM/NoPadding; MessageDigest/Mac with SHA-256 or stronger; avoid the Weak* classes |
insecure-cookie | cookie.setSecure(true) and cookie.setHttpOnly(true) before response.addHttpCookie(cookie) |
ocapi-demo-client-id | Replace the demo client ID aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa with a dedicated Account Manager client; remove it from OCAPI settings on every instance |
ocapi-broad-access | Grant specific resources and methods; allow only your own HTTPS origins |
service-credential-password / preference-secret-value | Remove the value from site data; set it per instance in Business Manager; rotate it |
service-insecure-url | Use the service's https:// endpoint |
secret-attribute-not-password | Change the attribute <type> to password |
csrf-allowlist | Remove unneeded Business Manager CSRF exemptions; prefer single start nodes; no production user agents |
sfra-post-without-csrf | Add csrfProtection.validateAjaxRequest/validateRequest; for base routes, server.extend(module.superModule) then server.prepend('Route', csrfProtection.validateAjaxRequest) |
webhook-without-verification | Verify the caller before acting: provider signature (HMAC of the raw body) or a shared token from a site preference; if the browser calls it, add a CSRF check |
sg-post-without-csrf | Add the 'csrf' filter to guard.ensure([...]) and the token field to the form |
sfra-replace-drops-middleware | Repeat server.middleware.post/https, login, and CSRF middleware in server.replace(), or use server.append() |
get-mutates-state | Make the route POST with a CSRF check; don't store request input in a GET |
mass-assignment | Assign expected fields by name, or check keys against an allowlist |
pii-in-logs | Log identifiers (customer or order number), not personal data |
dynamic-code | Replace eval/new Function; map known names to static require() calls |
Re-run b2c security scan --rule <rule-id> <file> after a fix to confirm the finding is gone.
Only when the user agrees the code is safe, suppress it on the line with a comment that names the rule and gives a reason:
// b2c-dx-disable-next-line open-redirect -- target checked by isAllowedRedirect()
res.redirect(target);
To adopt scanning on an existing codebase without fixing everything first, record current findings in a baseline (committed to the repo); later scans report only new findings:
b2c security baseline
b2c security scan
To turn a rule off, change its severity, or leave out paths for the whole project (for example a Business Manager tools cartridge), propose a committed .b2c-security.json (or the same settings under security in dw.json) rather than many inline comments; --exclude-rule and --ignore do the same for one run:
{"ignore": ["cartridges/bm_tools"], "rules": {"pii-in-logs": "off", "weak-crypto": "low"}}
# Fail on high and critical findings; write SARIF for GitHub code scanning
b2c security scan --fail-on high --format sarif --output security.sarif
--fail-on (default low) sets the severity that makes the command exit with status 1; --fail-on none never fails. --severity hides findings below a level.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub salesforcecommercecloud/b2c-developer-tooling --plugin b2c-cli28 skills in this plugin
/b2c-amManage Account Manager resources including API clients, users, roles, and organizations. Use this skill whenever the user needs to create or update API clients, onboard or offboard developers, assign Account Manager roles scoped to tenants, audit user permissions, look up organizations, or provision API clients for CI/CD pipelines. Also use when managing AM role assignments or querying Account Manager data — even if they just say "add a new developer" or "set up an API client". For instance-level Business Manager administration (BM roles, BM users, BM access keys, BM whoami), defer to the `b2c-cli:b2c-bm-users-roles` skill./b2c-bm-users-rolesManage Business Manager users, access roles, role permissions, and per-user access keys on a B2C Commerce instance using the b2c CLI. Use this skill whenever the user needs to list or search BM users on a sandbox or production instance, identify which BM user an OAuth token resolves to ("whoami"), assign or revoke instance-level access roles, edit role permissions, look up a user's WebDAV / OCAPI / Storefront access key, or rotate access keys for SSO-managed users. Also use when the user asks "what's my BM login on sandbox X", "rotate my WebDAV password", "how do I make a custom BM role", "audit BM users on this instance", or "delete a stale BM user from a sandbox".Other plugins' skills for the same job