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.

17 stars

Best use case

magento-security is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

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.

Teams using magento-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

$curl -o ~/.claude/skills/magento-security/SKILL.md --create-dirs "https://raw.githubusercontent.com/OrcaQubits/agentic-commerce-skills-plugins/main/dist/antigravity/magento2-commerce/.agent/skills/magento-security/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/magento-security/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How magento-security Compares

Feature / Agentmagento-securityStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

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.

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

# Magento 2 Security

## Before writing code

**Fetch live docs**:
1. Web-search `site:experienceleague.adobe.com commerce security` for security best practices
2. Web-search `site:developer.adobe.com commerce php development security` for developer security guide
3. Web-search `magento 2 security patches latest` for recent security updates

## Content Security Policy (CSP)

### What It Does

Protects against XSS and code injection by restricting which resources (scripts, styles, images, fonts) can load.

### Configuration

- `etc/csp_whitelist.xml` — whitelist external domains per CSP directive
- Modes: **report-only** (logs violations) and **restrict** (blocks violations)
- Directives: `script-src`, `style-src`, `img-src`, `font-src`, `connect-src`, `frame-src`

### Adding Allowed Sources

Whitelist third-party domains for payment gateways, analytics, CDNs:
- Declare in `csp_whitelist.xml` under the appropriate directive
- Use `report-only` mode first to identify missing whitelists

## Two-Factor Authentication (2FA)

- **Mandatory** for all admin users since Magento 2.4.0
- Supported providers: Google Authenticator, Duo Security, Authy, U2F keys
- Rate limiting on OTP validation (configurable retry limit and lockout)
- Cannot be disabled in production (security requirement)

## CSRF Protection

- `form_key` — 16-character token included in all admin forms
- Validated on every POST request in admin
- **SameSite** cookie attribute prevents cross-site request forgery
- Admin Secret Key in URLs adds additional protection

## Admin Security Configuration

Available at Stores > Settings > Configuration > Advanced > Admin > Security:
- Custom admin URL path (obscure the `/admin` path)
- Add Secret Key to URLs
- Password lifetime (force periodic changes)
- Max login failures before lockout
- Lockout duration
- Session lifetime
- Allowed countries for admin access

## Input Validation and Output Escaping

### Input Validation

- Validate all user input on the server side
- Use Magento's validation classes and form validators
- Never trust client-side validation alone
- Validate types, lengths, formats, and allowed values

### Output Escaping (XSS Prevention)

In PHTML templates, always escape output:
- `$escaper->escapeHtml($value)` — HTML context
- `$escaper->escapeUrl($url)` — URL context
- `$escaper->escapeJs($value)` — JavaScript context
- `$escaper->escapeHtmlAttr($value)` — HTML attribute context
- `$escaper->escapeCss($value)` — CSS context
- Never use `echo $value` directly in templates

## reCAPTCHA

- Native Google reCAPTCHA v2/v3 support since 2.3
- Configurable per form: login, registration, forgot password, checkout, contact
- Admin configuration at Stores > Configuration > Security > reCAPTCHA

## API Security

- Bearer token authentication for REST/SOAP
- ACL-based authorization for all endpoints
- Rate limiting on authentication endpoints
- OAuth 1.0a for third-party integrations

## Best Practices

- Apply security patches promptly — subscribe to Adobe Security Bulletins
- Use a custom admin URL (not `/admin`)
- Enable 2FA for all admin accounts
- Set strong password policies (length, complexity, expiry)
- Use HTTPS everywhere (frontend + admin)
- Restrict admin access by IP where possible
- Enable CSP in restrict mode (not just report-only)
- Escape all output in templates
- Keep Magento and all extensions up to date
- Run periodic security scans (Adobe Security Scan Tool)
- Review third-party extensions for security before installing

Fetch the security documentation for current CSP directives, 2FA configuration options, and latest security patches before implementing.

Related Skills

woo-security

17
from OrcaQubits/agentic-commerce-skills-plugins

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

17
from OrcaQubits/agentic-commerce-skills-plugins

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

17
from OrcaQubits/agentic-commerce-skills-plugins

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

17
from OrcaQubits/agentic-commerce-skills-plugins

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.

sf-security

17
from OrcaQubits/agentic-commerce-skills-plugins

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.

saleor-security

17
from OrcaQubits/agentic-commerce-skills-plugins

Secure Saleor applications — JWT authentication, OIDC integration, App tokens, permission model, rate limiting, CORS, and security headers. Use when configuring Saleor security.

medusa-security

17
from OrcaQubits/agentic-commerce-skills-plugins

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-testing

17
from OrcaQubits/agentic-commerce-skills-plugins

Write tests for Magento 2 — PHPUnit unit tests, integration tests, MFTF functional tests, and API tests. Use when implementing test coverage for modules, debugging, or setting up CI/CD test pipelines.

magento-setup

17
from OrcaQubits/agentic-commerce-skills-plugins

Set up a Magento 2 Open Source project — installation, Composer setup, system requirements verification, and initial configuration. Use when starting a new Magento project or setting up a development environment.

magento-service-contracts

17
from OrcaQubits/agentic-commerce-skills-plugins

Implement Magento 2 service contracts — repository interfaces, data interfaces, SearchCriteria, and the repository pattern. Use when building module APIs, data access layers, or integrating with Magento's Web API.

magento-plugins-interceptors

17
from OrcaQubits/agentic-commerce-skills-plugins

Implement Magento 2 plugins (interceptors) — before, after, and around methods for modifying class behavior without inheritance. Use when extending core or third-party module functionality.

magento-performance

17
from OrcaQubits/agentic-commerce-skills-plugins

Optimize Magento 2 performance — full page cache (Varnish), Redis, indexer tuning, JavaScript/CSS optimization, database optimization, and profiling. Use when diagnosing slow pages, optimizing load times, or configuring caching.