How to Install Magento 2 Security Patches?

How to Install Magento 2 Security Patches?

Security patches are released to protect Magento stores from possible attacks.
Around 62% of Magento stores may have at least one security issue.

The common issues are caused by outdated versions and not installing security patches.

The Magento team quickly develops a patch to fix the version when a vulnerability is found.

This tutorial explains how to install security patches in Magento 2.

Best Magento Hosting now

What Is Magento Security Patch?

What Is Magento Security Patch

A Magento security patch is a piece of code that fixes security loopholes.

The patch acts as a software upgrade to fix bugs and improve security.

Installing the Magento patch ensures the site is protected against potential exploits.

Magento releases updates quarterly for Magento Commerce and Magento Open Source.

You can also expect quick releases for high-security threats based on priority.

There are two types of Patches in Magento:

  • Official Patches - patches published on Magento Security Center.
  • Custom Patches -These patches are available to download from a git commit.

What is a SUPEE Patch

SUPEE Security Timeline

A Decade of Defending Magento Stores Against Evolution of Threats

9 Years
Version Coverage
3+ Critical
Vulnerabilities Per Patch
0 Margin
For Error
June 22, 2020
M1 EOL

SUPEE-11346

Final major security patch coinciding with Magento 1 end-of-life, addressing multiple critical vulnerabilities

XSS Attacks
Cross-site scripting vulnerabilities
Code Execution
Arbitrary code execution risks
Data Breaches
Sensitive data exposure
HTTPS Security
Request security hardening
Affects:
1.5.0.0
1.9.4.4
8 Month Gap
October 8, 2019
Pre-EOL Critical

SUPEE-11219

Critical security update addressing triple threat vulnerability combination

Triple Threat Combo

CSRF
Request Forgery
RCE
Remote Code Execution
XSS
Cross-Site Scripting
Affects:
1.5.0.0
1.9.4.4
Continuing Pattern Since 2011
!

Critical Insight

These patches cover versions from 2011's 1.5.0.0 to 2020's 1.9.4.4, meaning thousands of legacy Magento 1 stores still in operation are vulnerable without them. With Magento 1's end-of-life status, no new patches are forthcoming—making these final updates critical for any remaining M1 installations.

What is a SUPEE Patch

A SUPEE patch has a self-installing script that contains updates to all the security issues.

The SUPEE patch comes with a number at the end, such as SUPEE -11346.

The patch details are posted on Magento’s official website. It describes what the patch does for the version and the vulnerability it solves.

The patch files contain the code to update the existing Magento code files.

Why are Magento 2 Security Patches Essential

4 Horsemen of Unpatched Magento

From Customer Theft to Total Blackout - Each Threat Can Trigger Business Failure

CRITICAL RISK LEVEL
CC

Payment Data Theft

Credit Cards, PayPal, Stripe Integration Compromise

RISK LEVEL CRITICAL

PCI fines: $5,000-$100,000/month

RS

Ransomware Encryption

Complete System Lockout Until Ransom Paid

RISK LEVEL CRITICAL

Double extortion: Data theft + encryption

BOT

Traffic Bot Flooding

Legitimate Customers Blocked by Attack Traffic

RISK LEVEL HIGH

Revenue loss: $20K-$40K per hour

MW

Search Engine Blacklist

Google Blocks 10,000 Sites Daily for Malware

RISK LEVEL HIGH

Recovery time: Weeks of zero organic traffic

Average Retail Data Breach Cost: $3.86 Million

Quarterly patches leave stores exposed 25-50% of each quarter when delayed 30-60 days

PATCH IMMEDIATELY - NOT OPTIONAL

Security patches act as a first-line defense against several cyber attacks. Without the patches, your store is at high risk for data breaches like-

1. Credit card information

Customers can get their credit card data stolen. Payment integrations like PayPal and Stripe and other third-party Magento 2 extensions are susceptible to attacks.

2. Ransomware

Ransomware is malicious software that encrypts your code. It denies access to your system until you pay the hackers.

3. Web server attacks

The server hosting your website can get compromised by hackers. It can be sending traffic bots to block genuine traffic, spamming, and so on.

4. Malware

Malware damaging your site as well as the visitors. The website can get blocked by search engines until the security is restored.

It can lead to profit loss and brand reputation damage. Or in critical cases, you may lose sensitive customer data.

Security patches ensure that your site is not vulnerable to such attacks.

Steps to Install Magento Security Patch

Choose Your Patch Path

From 1-Click Safety to Full Integration – Match Method to Urgency

Without SSH

1 Step

Direct upload of pre-patched files to server. Perfect for urgent fixes and shared hosting environments.

Complexity Level 20%
Requirements: File upload access only
Best for: Emergency patches, shared hosting

GitHub Method

3 Steps

Version-controlled patching through GitHub repository. Ideal for development teams using Git workflows.

Complexity Level 60%
Requirements: Git access, repository setup
Best for: Team environments, version control

SSH Method

4 Steps

Traditional command-line patching with direct server access. Standard approach for most installations.

Complexity Level 80%
Requirements: SSH access, command line skills
Best for: Standard installations, experienced users

Composer Method

5 Steps

Complete dependency management integration. Most comprehensive but ensures long-term patch tracking.

Complexity Level 100%
Requirements: Composer access, dependency knowledge
Best for: Long-term maintenance, systematic updates

Pro Tip: Choose based on urgency – Without SSH for immediate threats, Composer for systematic long-term security

1. Using SSH

  1. Upload the local patch file into the <Magento_root> on the server.

  2. Log in to the server and verify that the file is located in the correct directory.

  3. In the command-line interface, run the following commands.

patch < patch_file_name.patch 

The command assumes that the file to be patched is located relative to the patch file.

If you see “File to patch” in the command line, it may not be located in the intended file.

The command line terminal will display a box with the required file. You can copy and paste the file into the File to patch.

  1. Refresh the cache in the Admin under System > Tools > Cache Management

2. Using Composer

It is essential to perform testing before deploying any custom patch. Once the patch is tested, you can use the following steps to apply the patch.

  1. From the command line, access your project directory.

  2. Add the cweagans/composer-patches module to the composer.json file.

composer require cweagans/composer-patches 
  1. Edit the composer.json file and add the following:
  • Module - magento/module-payment
  • Title - “MAGETWO-56934: Checkout page freezes when ordering with Authorize. net with invalid credit card”
  • Path to patch - “patches/composer/github-issue-6474.diff”

For example:

 "extra": {
      "composer-exit-on-patch-failure": true,
      "patches": {
          "magento/module-payment": {
              "MAGETWO-56934: Checkout page freezes when ordering with Authorize.net with invalid credit card": "patches/composer/github-issue-6474.diff"
          }
      }
  }

If a patch affects specific modules, you have to create several patch files for different modules.

  1. Apply the patch with the following command. The -v can be used to see the details on debugging.
composer -v install 
  1. Update the composer.lock file. The lock file records which patches are applied to each Composer package.
composer update --lock 

3. Github

  1. Create a directory for patches -

    Go to the website’s working directory and create a patch directory for storing the Magento security patches.

  2. Copy the required patches to the generated directory.

    You can use SSH, FTP-client, and other tools that are suitable.

  3. Create a patch file - Run the following command.

git diff > ./patches/patchForModule.patch.

4. Without Using SSH

Extract the pre-patched files and upload them to the Magento root folder. There are also Pre-Patched files available on GitHub.

Some of the pre-patched files are shown below-

Magento SUPEE Patch Release Date Affected Versions Issue Details
Magento SUPEE 11346 June 22, 2020. 1.5.0.0-1.9.4.4 Security improvements to protect online stores from cross-site scripting, arbitrary code execution, and sensitive data breaches.
Magento SUPEE 11346 June 22, 2020. 1.5.0.0-1.9.4.4 Logging and monitoring issues. Protect sensitive data in HTTPS requests.
Magento SUPEE 11219 October 8, 2019. 1.5.0.0-1.9.4.2 Request forgery, remote code execution, cross-site scripting, etc.

Reverting an Installed Patch

You may have to revert the security patches installed if there are any issues.

You can use the same patch you used for reverting the patch and save the result.

You can use it with the -R flag and the following command.

sh patch_file_name.sh -R

Before Applying Magento 2 Security Patches

Critical Security Protocol

Zero-Downtime Patch Protocol

3 Phases, 15 Checkpoints, 100% Confidence

70%
Time in Pre-Installation
95%
Failure Prevention Rate
90%
Reduced Failed Attempts
Overall Readiness 15 Checkpoints
Phase 1: Pre-Install Phase 2: Testing Phase 3: Site Audit
1

Phase 1: Pre-Installation

3 Critical Steps • Est. 15 minutes

MANDATORY
Test in Staging Environment
Essential validation in non-production to prevent checkout failures and gateway disconnections
Create Backup Strategy
Choose: System (30-60min), DB+Media (15-30min), or DB only (5-10min)
Enable Maintenance Mode
Prevents data corruption during schema changes for high-traffic stores
2

Phase 2: Testing Validation

5 Validation Points • Est. 30 minutes

COMPREHENSIVE
Review Patch Release Notes
Known conflicts
System Impact Analysis
Performance impacts
Frontend Functionality Test
Visual breaks
Backend Admin Panel Check
Admin issues
Run Magento Security Scan
Auto-detection
3

Phase 3: Final Site Audit

7 Audit Criteria • Est. 20 minutes

FINAL CHECK
1
Site Speed
Load performance
2
JS Console
Error check
3
3rd Party
Module compat
4
Checkout
Flow test
5
Payment
Gateway check
6
Admin
Panel access
7
Security
Final scan
!
Critical Impact for High-Traffic Stores
Stores processing 100+ transactions hourly risk data corruption without proper maintenance mode. The 3-phase protocol reduces failed patches by 90% and ensures business continuity during critical security updates.

1. Test Patches

It is essential to test all patches in a staging or development environment. Check if the Magento system is working well after applying the patch.

Testing the patches includes-

  • Reviewing patch release notes
  • Analyze the effect of the patch on your system
  • Frontend and backend changes
  • Test if the patch is applied successfully
  • Use Magento Security Scan to detect issues.

2. Backup Database

Magento backups prevent data loss while adding new patches.

If there is any damage to the website, you can revert quickly with database backups.

Magento archives file system, database, media files. Store admins can access the feature from the backend.

To create a database backup-

  1. Log in to the Magento Admin panel and go to System => Tools => Backups

Magento Database Backup -Before Applying Magento 2 Security Patches

  1. Choose the type of backup you would like to create.

  2. Click on one - System Backup, Database, and Media Backup or Database Backup.

3. Enable Maintenance Mode

The Maintenance mode temporarily disables your Magento store. It is usually enabled for testing the site before going live.

You can use it for activities like security updates and bug fixes.

Enable maintenance mode before applying the released patches. Visitors on your websites will see a “Service Temporarily Unavailable.” sign.

Site Audit and Maintenance

Site audits help evaluate the status of your store after the patches are applied. Any bug could affect traffic, sales, and search engine ranking.

Site audits allow you to detect the current performance of the store.

To perform a site audit, consider the following aspects-

  • Site Speed.
  • Core code integrity.
  • Third-party module code.
  • JS console errors.
  • Code validation.
  • Usability.
  • Security.

Conclusion

Attackers are constantly looking for loopholes in your system.

An outdated system is an easy target for hackers to compromise your data.

Ensure that your store is secure with the latest security patches. We strongly recommend installing them as soon as they are released.

This tutorial covered methods to install the Magento security patches. Use the command line or directly apply pre-patched files.

Get more insights about the Magento platform on MGT-Commerce tutorials.

Nikita S.
Nikita S.
Lead Technical Writer

As a lead technical writer, Nikita S. is experienced in crafting well-researched articles that simplify complex information and promote technical communication. She has expertise in cloud computing and holds a specialization in SEO and digital marketing.


Get the fastest Magento Hosting! Get Started