Uncategorised
Magento 2 Security: 25 rules you must apply NOW
Patches, firewall, 2FA, security headers, admin access restrictions, log auditing.
Published 2026-07-15 • Category: Security • Reading time: 10 min
Why now
In 2026 Magento remains one of the most frequently attacked CMSes: 32% of all recorded webshell incidents in 2025 were on Magento stores. The cause — code customisation and slow patch application.
25 critical rules
- Latest Composer patch installed within 30 days of release
- 2FA enabled for every admin account (Magento_TwoFactorAuth)
- Admin URL changed from /admin
- Rate limit on /customer/account/login (10 requests/min)
- IP whitelist for /admin (Nginx geo block)
- Content Security Policy with strict-dynamic
- HSTS with max-age ≥ 1 year
- X-Frame-Options: SAMEORIGIN
- Referrer-Policy: strict-origin-when-cross-origin
- HTTPS everywhere, automatic HTTP redirect
- Permissions-Policy for camera/mic/geo
- Filesystem: 755 for directories, 644 for files
- app/etc/env.php — 400, web user only
- No Composer dev-dependencies in prod
- The magento MySQL user holds GRANTs only to its own DB
- Monthly backup verification (restore drill)
- Logs retained > 90 days
- Admin login monitoring (Slack alert)
- Disable SOAP API if unused
- Disable REST API GET endpoints for sensitive resources
- Magecart protection patch (Yireo_Checkout or Mageplaza_Security)
- Regular malware scan (Sucuri, MageReport)
- Antivirus on server files
- Auto-block IPs after 10× 404 in 10 s (fail2ban rule)
- Monthly pen-test in a production-like environment
What to do during an incident
- Block /admin by IP
- Review recent deploys and merges
- Scan for webshells (clamav + manual search for the
eval(base64_pattern) - Invalidate every admin session
- Rotate: DB password, API keys, OAuth tokens
- Notify customers if there’s any sign of data exposure
Leave a Reply