Responding to a compromised Magento Open Source store

How to contain a compromised self-hosted Magento Open Source store, find skimmers and injected code, rotate credentials and patch before relaunch.

On this page

What to do first when a Magento Open Source store is compromised

The first move is to contain the store, preserve evidence, then remove the injected code and rebuild. Whether the trigger is a skimmer report from a customer, an alert from your payment processor, or an admin login nobody on your team made, the order matters. Changing files or restoring a backup before you have copied logs, the database and the web root can destroy the record you need to learn how the attacker got in. Adobe's security best practices list injected code in storefront headers and footers, client-side card skimmers and tampered payment forms among the signs to watch for, so check those locations first and capture them as they are.

Whether PCI DSS applies depends on your cardholder data environment (CDE), which is every system that stores, processes or transmits cardholder data or could affect its security. A skimmer on a checkout page or a modified payment form almost always puts the store inside that environment. The PCI Security Standards Council does not enforce compliance itself; your acquirer and the payment brands decide which obligations and validation steps apply and what happens next. Confirm with your processor, in writing, which version of PCI DSS and which assessment type (a Report on Compliance or a Self-Assessment Questionnaire) they expect you to complete, and ask who you must notify and by when. Do not assume the timeline from memory or from a third party's advice.

Containing a Magento store before anyone cleans it

The first hours after a suspected compromise should stop further damage, preserve evidence of how the attacker got in and what data they touched, and record who was told. Cleaning before that evidence is captured can destroy the trail needed to answer both questions.

  1. Restrict admin access and freeze changes

    Limit admin login to the people who must respond, and block or narrow access to the admin path at the web server or network edge. Ask the store team to stop deployments, extension installs, configuration edits and scheduled jobs that write to the store until the investigation says otherwise. Done when admin sessions have been reviewed, unknown sessions are ended, and the change freeze is written down with a named owner.

  2. Record who was notified and when

    Start an incident log with the time the suspicion was raised, who raised it, and who has been told since. Include the merchant's internal security and legal contacts, the payment acquirer or processor, the hosting provider and any agency staff with admin access. Notification duties depend on your contracts and the payment brands' rules, so confirm them with your acquirer and counsel rather than assuming. Done when the log lists every notification with a timestamp and the person responsible for each one.

  3. Take a forensic copy of files and database

    Before any cleanup, capture the web root, the Magento installation, the web server and PHP logs, and a full database export, ideally from a read-only snapshot or a copy made by someone outside the attacker's reach. Hash the archives and store them in a restricted location. Done when the copies are verified, the hashes are recorded in the incident log, and the copy process itself is documented so the evidence can be explained later.

  4. Disable suspicious payment methods and scripts

    Turn off any payment method, checkout script or third-party tag you cannot account for, and do this in a way that keeps the forensic copy intact. Where a card skimmer is suspected, consider taking the checkout offline or switching to a known-good payment page with the acquirer's guidance so that customer card data stops moving through the suspect code. Done when checkout is either verified clean or disabled, and the decision is recorded with its reason.

  5. Preserve logs before they rotate

    Copy access logs, admin action logs, cron and deployment history, and any web application firewall or CDN logs to the evidence store now, because routine log rotation can overwrite the record of the first unauthorized request. Note which log sources exist, their retention settings and any gaps. Done when each log source has been copied, its time range is recorded, and gaps are listed for the forensic team.

  6. Confirm scope before cleaning begins

    Use the preserved copies to answer two questions before anyone removes code: how the attacker got in, and which customer or card data could have been exposed. Pair a store engineer with a forensic or PCI-experienced reviewer to check injected content in headers, footers and payment forms against the copy. Done when the team has a written working hypothesis for the entry point and a list of data sets that may have been touched, both marked as provisional.

  7. Hand over to the cleanup and rotation plan

    Once the evidence is captured and scope is provisional, move to containment-to-cleanup work: removing injected code, rotating keys and credentials, and patching before relaunch. Confirm the handover in the incident log with the names of the people accepting each workstream. Done when the cleanup owner has the verified copies, the notification list and the open questions, and the team agrees that no cleanup has yet touched the production store.

Where injected scripts hide in headers, footers and payment forms

Header and footer output is assembled from layout XML and theme templates, so a skimmer or redirect loader often sits in markup that every page loads. Injected code here is usually small, placed near the closing body tag, and easy to miss in a visual review. Check the active theme and every module that touches the page shell.

  • Theme templates: Review header.phtml and footer.phtml and similar templates in the active theme under app/design for script tags, iframes or encoded strings that do not appear in your source control history.
  • Layout XML: Search default.xml and other layout files in custom and third-party modules for <referenceContainer> or <block> entries that add <script> or <link> tags without a clear business purpose.
  • Page types: Inspect the page source of the homepage, a category page and a product page separately, since some skimmers load only on selected page types or for selected visitors.
  • Overridden templates: Any template copied from Magento core or a vendor module into the theme is a candidate, because edits made to the copy do not show up in the original module code.

Compare the rendered HTML from a clean browser session with the output from a known-good build, and confirm that every external domain is one your team expects.

Deciding whether card data was exposed

Whether card data was exposed depends on a few facts about the incident: which pages carried the skimmer, how long it ran, and who handles payment on the store. The cards below cover the decisions that set your scope and the obligations that follow from them.

Which checkout pages loaded the script

Identify every template that loaded the injected code, including the cart, the one-page checkout, the payment step and any account pages that rendered card fields. Check the store's layout and template files, the payment method blocks and any CMS blocks that were edited. A skimmer on a single payment step exposes a different population of transactions than one in the global footer, so the page list drives the rest of the analysis. Ask your forensic team to record the exact paths and the timestamps when each was first seen.

The window the skimmer was active

The active window sets the number of transactions to review. Work from the earliest evidence of injection to the moment the code was removed, and treat gaps in logs as unknown time rather than clean time. Compare file modification times, deployment records, admin action logs and web server access logs to narrow the range. Every order placed inside that window on an affected page is a candidate for exposure.

Hosted or on-store payment handling

Confirm whether card data ever reached your servers. A payment page that hands the customer to a hosted payment provider through a redirect or an iframe usually keeps card entry off your store, while a custom form that posts card fields to your application keeps it on. Review the payment integration, the gateway settings and any custom checkout code. This answer determines whether a skimmer could read full card numbers or only the pages around them, and it shapes which PCI DSS requirements apply to your environment.

Logs that exist and what they show

List the logs that could confirm or rule out exposure: web server access logs, application logs, admin action logs, payment gateway records, and any file integrity or web application firewall logs. Check retention before assuming anything is gone, because rotation can remove the evidence within days. Logs kept on the same compromised server may have been altered, so confirm copies exist off the host. Record which logs are missing as well, since that gap shapes what you can state to the payment brands and your acquirer.

Who decides reporting and enforcement

The payment brands decide enforcement and reporting, not the PCI SSC. PCI DSS applies to entities that store, process or transmit cardholder data, and to those that could affect the security of the cardholder data environment, including merchants and service providers. The PCI Security Standards Council maintains the standard but does not enforce it or impose penalties. Notify your acquirer and payment brand contacts as your agreements require, and ask your acquirer which validation and reporting steps apply to your case.

PCI SSC enforcement FAQ

Which validation documents apply

Once scope is clear, confirm which assessment you owe: a Report on Compliance completed by a Qualified Security Assessor, or a Self-Assessment Questionnaire with an Attestation of Compliance. Certificates alone are not accepted as validation. The choice depends on your merchant level and your acquirer's requirements, which you should confirm in writing. Do not assume a scan or a clean hardening review satisfies the assessment; ask your QSA or acquirer what evidence they will require for the affected period.

Rotating keys, admin accounts and integration credentials

Once an attacker has held admin access, treat every secret that the store could read or that an admin session could reach as exposed. Start with the admin accounts and sessions: reset passwords for every admin user, including agency and former staff accounts, and end all active sessions so a stolen session cookie stops working. Then review the admin user list for accounts you do not recognize and for roles that were widened during the incident. The detailed steps for password policy, lockout and role clean-up sit in the sibling topics on securing the admin panel and on two-factor authentication, so confirm those settings before the store reopens.

The encryption key in env.php protects values stored in the database, including payment and integration credentials, so an attacker who had read access to the configuration may be able to decrypt them. Rotating it is a maintenance task with a documented command-line route from 2.4.8, and it has side effects on stored values and sessions. Confirm the exact command and sequence against Adobe's documentation for your installed version before you run it, and follow the sibling topic on rotating the encryption key. Rotate the API integration tokens for every ERP, PIM, marketplace and shipping connector as well, because integration tokens can persist after an admin password change.

The payment, ERP and hosting credentials are the ones most often missed. Rotate the payment gateway keys, the ERP and middleware service accounts, the mail relay password, the hosting control panel and SSH or deploy keys, and the database user passwords, including the read-only reporting account. Any secret that changed must then be updated in every connected system before relaunch, or orders, stock sync and payment capture will fail in ways that look like new incidents. Keep a written list of each credential, its owner and the systems that consume it, and do not relaunch until that list is fully checked off.

Patching and rebuilding the store before relaunch

Which Magento Open Source release line should a compromised store be rebuilt on?

Rebuild on a release line that still receives security patches for the months you expect to run it, and prefer the newest line your extensions and infrastructure support. Adobe's lifecycle policy gives each 2.4.x release three years of standard support from general availability. The documented end of regular support is August 11, 2026 for 2.4.6, May 31, 2027 for 2.4.7, May 31, 2028 for 2.4.8 and May 31, 2029 for 2.4.9. A store relaunched on 2.4.6 would be past its regular support window, so that line should not be chosen for a new build. Confirm each date against the Adobe Commerce lifecycle policy before you commit.

Which PHP, database and search versions does a rebuilt Magento store need?

The version you choose sets the whole stack, and Adobe supports only the listed combinations. For 2.4.9, Adobe's requirements list PHP 8.5, MySQL 8.4 or MariaDB 12.3 (recommended) or 11.8, OpenSearch 3, Redis or Valkey 9, RabbitMQ 4.3, Composer 2.10 and nginx 1.30 on Linux x86-64. For 2.4.8-p5 the list includes PHP 8.4 or 8.3, MySQL 8.4 or MariaDB 11.4 or 11.8, Redis or Valkey 8.1 and Varnish 8. Check the system requirements for your exact release, then build a clean server that matches it rather than carrying over an old PHP or database version.

Should a compromised Magento store be rebuilt from clean code or patched in place?

In most compromise cases, rebuild from clean code and migrate data back in after review. A modified installation may contain injected files, altered core or vendor code, or backdoors that a patch will not remove. Install the chosen release from Composer on new hosts, reapply only the custom modules and themes you have reviewed in source control, and treat the old database as untrusted until you have checked it. Any file that was not in your version control should be assumed suspect. Ask your team or partner to state how they will verify the rebuilt codebase against the official release before anything is restored.

What should be verified in the Content Security Policy after a rebuild?

Verify that CSP is enabled, that its rules match the scripts you actually use, and that payment pages enforce it. Adobe's developer documentation states that Magento supports Content Security Policy headers from 2.3.5, and from 2.4.7 CSP runs in restrict mode by default on storefront and admin payment pages. A CSP that is not enforced will not block a skimmer loading from an attacker domain. Check the policy in a browser's developer tools on checkout pages, confirm no unexpected external script hosts are allowed, and record the configuration as evidence. Review the Content Security Policies guide for the settings that apply to your release.

Why does Adobe recommend upgrading on every patch cycle after an incident?

Adobe recommends upgrading every patch cycle to stay secure and PCI compliant, and a store that was breached has already shown it is a target. Security patches are released at least annually for all supported release lines, and a full patch for the 2.4.x LTS line ships annually in May. Staying on a patched version means each future fix reaches you without a large catch-up project. Plan a recurring patch window, keep extensions on versions compatible with the new core, and use the Upgrade Compatibility Tool before each move. The upgrade guide overview lists the drivers of upgrade effort, including customizations, extension count and third-party integrations.

Is a Mage-OS build a safe alternative for a relaunch after an attack?

Use a Mage-OS build only when its security patch releases for your version are confirmed in writing and you have checked them against the Adobe patches. Mage-OS is a community-owned distribution built on Magento Open Source, run by the Mage-OS Association, and its site describes it as upstream compatible with Magento 2 extensions and lists releases that port Adobe security patches. Compatibility claims do not replace that check. Ask which Adobe patches each Mage-OS release includes, how quickly they arrive after Adobe publishes them, and who supports the build if an issue appears. The project information is on Mage-OS.

How much does rebuilding and patching a compromised store cost?

No price is set by a researched fact, so cost depends on the scope you agree. The main components are the forensic review, the clean build and hosting, the patching and upgrade work for extensions, the custom code review, the CSP and payment page checks, and retesting before relaunch. Recurring costs include hosting, patch windows, extension licenses and support. Ask any provider for a fixed-scope quote that lists each component, the release line chosen, the number of extensions and custom modules in scope, and what is delivered as evidence. DeployOpen agrees scope, deliverables and timelines in writing before work starts, and quotes follow from that written scope.

Can our own team rebuild and patch the store without a partner?

Yes, if your team has the Magento, PHP and server skills to run the build, and the time to verify each step. The work that most often goes wrong is verification: checking the rebuilt code against the official release, reviewing custom modules, confirming CSP enforcement and retesting checkout. Ask your team to document each decision, keep the old environment offline for review, and agree who signs off before relaunch. If the team lacks payment security or incident experience, bring in an outside reviewer for the verification steps, since a standard build can still reproduce an attacker's entry point.

Verifying the store is clean before reopening checkout

Reopening checkout is a decision, not a deadline. The checks below test whether the store is clean now, confirm that the attacker has no remaining foothold, and set up detection for the period after relaunch. Each check produces evidence that the incident team and any independent assessor can review.

Fresh file integrity comparison

Compare the codebase on disk against a known-good Magento Open Source release of the same version and patch level, plus your own vetted custom modules and themes. Flag any file that is new, modified or unexpectedly executable, including files inside app/code, app/design, pub and vendor. Treat anything the comparison cannot explain as suspect until it is reviewed. Confirm which release and patch the store actually runs before comparing, since a mismatch produces noise that hides real changes.

Current 2.4.x release
2.4.9
magento/magento2 repository

Rescan headers, footers and payment pages

Repeat the browser-level review you used during triage, this time against the rebuilt store. Inspect the rendered HTML of the header, footer, checkout, cart and payment pages, and review the script sources each page loads. Compare the results against an expected inventory of scripts, and confirm that payment forms post only to the intended processor endpoints. Run the scan from a clean browser profile and from more than one network location, since some skimmers show different content to different visitors.

Review admin users and roles

List every admin account, its role, its last login and its creation date, and remove any account nobody can account for. Check that each active admin has two-factor authentication enrolled, and review API integration tokens and their assigned resources. Reset all admin passwords after the incident, and confirm that the sessions of previously known accounts were ended. Record the reviewed list and the person who approved each remaining account.

Confirm the cache layer serves clean pages

If the store uses Varnish as its full-page cache, purge it completely and confirm that responses are generated from the rebuilt application. Infected HTML may persist in cache after the source is fixed, so a file-level clean does not prove the storefront is clean. Request key pages from outside the network and compare their content against your expected output. Check any CDN or reverse proxy in front of the store, and confirm that browser-side caching does not return older scripts.

Varnish cache guide

Content Security Policy baseline

Define the allowed script and form-action sources before relaunch, then enforce them. Magento Open Source supports Content Security Policy headers from version 2.3.5, and from 2.4.7 the policy runs in restrict mode by default on storefront and admin payment pages. Confirm that policy violations are logged or reported, and that any new external script requires an approved change. A tight policy makes a newly injected script visible when it first appears.

Content Security Policy docs

Monitoring plan for new script sources

Set up recurring checks that alert on change, not only on compromise. Schedule integrity comparisons of the codebase, automated scans of checkout and payment pages, and alerts on new admin logins and role changes. Route alerts to a named owner with an agreed response time. Document who reviews an alert, who can take the store offline, and how each finding is recorded for the post-incident report.

Questions buyers ask before bringing in outside help

What drives the cost of responding to a compromised Magento store?

Cost follows the amount of ground the responders must cover: how many storefront templates, headers, footers, checkout and payment pages are affected, how many extensions and custom modules run on the store, how many third-party integrations hold credentials, and how long the compromise ran before anyone noticed. Store size matters less than the number of places an attacker could have written code. Ask for a quote that lists each area as a separate line: triage, log review, code and template review, credential rotation, patching, and verification. Find out whether the quote includes a retest before relaunch and whether follow-up monitoring is separate. Our fees are set from the written scope, and we do not publish a price list.

How long does an incident response engagement take?

Duration depends on scope, not on a fixed number of days. The work moves through containment, evidence collection, finding injected scripts, rotating keys and credentials, patching, and verification before the store reopens. Logs that are complete and retained make the investigation shorter. A store with many custom modules, several payment pages and unclear access history takes longer to clear. Ask for a timeline in the written scope that names the decision points where your team must approve a step, such as taking the store offline or changing payment settings.

What do we need to give the responders?

Responders need working access to the affected environment, a named decision maker who can approve containment steps and customer communication, a maintenance window for taking the store offline or switching payment methods, and recent backups that predate the suspected compromise. Also provide admin user lists, web server and PHP logs, access logs for the admin panel, deployment history, and the list of installed extensions. Confirm early who holds the payment processor and acquirer contacts, because those parties may need to be informed under your merchant agreement.

Can our own team handle the response without outside help?

A team with Magento administration experience, server access and a clear incident process can handle containment and rotation alone, especially if the compromise is limited to one admin account. Outside help is most useful when the injected code is hidden across templates, when the attacker may still have server access, or when you must show a documented investigation to your payment processor or assessor. Check whether your team can review the web root, database content and logs without changing evidence, and whether anyone has handled a card skimming incident before.

How does a fixed-scope engagement get agreed?

The engagement is agreed in writing before work starts. The written scope names the systems covered, the deliverables such as an investigation summary, a list of removed code, a rotation record and a patching report, the timeline, the responsibilities on each side, and the points at which work pauses for your approval. Any change to scope is recorded in writing before the extra work begins. Ask that the document also state what evidence you will receive and in what format, so your assessor or payment processor can review it later.

Will the responders find every injected script?

No responder can promise that every injected script is found, and any contract that promises it should raise a concern. The work reduces the risk through structured review of headers, footers, checkout and payment templates, database content, cron jobs, and recently changed files, followed by a retest. Ask how the team records what was checked, what was removed and what remains open. Ask whether the verification plan includes a check of the payment pages from a clean browser session after relaunch.

How do PCI DSS obligations affect the response?

The PCI Security Standards Council owns PCI DSS, but the payment brands decide who must validate compliance and what happens after an incident. Your acquirer or processor may require a report of the incident and evidence of remediation, so confirm their expectations early. The current version is PCI DSS v4.0.1, which the council published on 11 June 2024. Responders can document the work in a way that supports your next assessment, but only a Qualified Security Assessor or your own completed assessment template produces a validation. Ask your payment partner which evidence they expect before the investigation begins.

How the response phases connect

The response starts when someone detects a skimmer or admin takeover, then moves in one direction: contain the store, preserve evidence before anything is changed, and assess scope. A decision point asks whether cardholder data exposure is confirmed. If it is, the path runs through notification and your assessor before cleaning and rebuilding. Credentials are rotated, the platform is patched, and the store is verified before relaunch and monitoring.

Response phases from detection to monitoring, with the cardholder data exposure branch.

How DeployOpen scopes and delivers a Magento incident response

DeployOpen approaches a compromised Magento Open Source store as a fixed-scope engagement that starts with containment and evidence, then moves to clean rebuild, credential rotation and a documented relaunch. The work runs inside your own infrastructure, so your team keeps control of the store, its logs and its data throughout.

How we scope

  • Scope is agreed in writing before work starts, covering affected hosts, storefront pages, admin accounts and payment flows.
  • Written scope names the evidence sources to collect, such as web server logs, admin action logs and file integrity results.
  • Ask for the scope to state which cardholder data environment components are in or out, and who decides that boundary.

How we build

  • We check headers, footers, checkout and payment form templates for injected scripts, and compare them against a known clean source.
  • Credentials, API tokens and encryption keys are rotated in a planned order so that integrations and cron jobs keep working.
  • The store is rebuilt on a supported 2.4.x release with current patches applied before any traffic returns to it.

How we hand over

  • You receive a written timeline of containment steps, the injected code found and the files or settings changed.
  • Retesting confirms that injected scripts are gone and that the admin, payment and API paths behave as the scope describes.
  • Runbook notes cover monitoring checks, alert owners and the patch cycle your team needs to keep running after handover.

How we support

  • Ongoing support, upgrades and continuous testing are available as retainers after the incident is closed.
  • A retainer can cover the next patch cycle, periodic checks of storefront scripts and review of admin access changes.
  • Confirm with DeployOpen what response times and support hours the retainer includes before you sign.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.