Latest news about Bitcoin and all cryptocurrencies. Your daily crypto news habit.
This case study was developed by Jscramblerâs Research team.
During the past few weeks, weâve been seeing an alarming number of attacks targeting several eCommerce and ticketing companies, stealing their clientsâ credit card data.
Behind these attacks, we find a group of hackers named âMagecartâ. In June 2018, the group attacked Ticketmaster and breached credit card data of 40,000 customers; two major attacks followed in September, affecting 380,000 British Airways customers and an unknown number of Newegg customers.
The modus operandi behind this series of attacks was very similar: injecting malicious JavaScript code which acts as a credit card skimmer. This code actively listens for events that happen on the web pages and triggers an action whenever credit card details are submitted (event hijacking). As so, Magecart was able to intercept this credit card data that users were inputting in the checkout pages and send it to the hackersâ servers.
While the result of these attacks was the same, Magecart used distinct approaches: in Neweggâs case, it directly compromised the eCommerce websiteâs server; in all others, it compromised a third-party tool that they were using.
With so many unanswered questions surrounding these attacks, we decided to delve into the topic. In this article, we clarify what happened and what could be done to minimize the impact of these and similar attacks.
How Can the Source Code Be Modified?
One key aspect of every Magecart attack is their ability to inject their own malicious code into JavaScript code that is running (or being loaded) in companiesâ websites.
While this may seem like a complicated taskâââgiven the variety of security systems that most companies have in placeâââthere are actually multiple ways to modify code, either directly in the server or in intermediary services (e.g. CDNs).
Compromising the Server
The most direct way of compromising the source code is directly accessing the server and modifying the files there. This can be achieved by gaining access to the server (either using stolen access credentials or brute forcing the authentication mechanism) or by exploiting server vulnerabilities leading to Remote Code Execution (e.g. known CMS vulnerabilities, outdated components, vulnerable plugins, among others).
Compromising In-transit Code
While the code is being sent from the server to the website, itâs also susceptible to modification. This can happen via Man-in-the-Middle attacks (not very frequent now due to HTTPS adoption), subdomain takeover and web cache poisoning.
Cache poisoning is especially relevant, given that it targets Content Delivery Networks (CDNs), which are widely used nowadays. When source code is loaded from a CDN, an attacker can craft a request that tricks the origin into producing a malicious version of the script with the same cache key as an innocuous request. This script may get cached and served to end-users.
Compromising Repositories
Developers rely on an assortment of repositories during their workflow. While this is the status quo of the development process, it can also serve as a vehicle for injections. There have been cases of exploits in NPM packages (Node Package Manager) and Chrome Web Store extensions.
How Does This Compromise Companies?
Both Ticketmaster and British Airways were attacked via a third-party module. This is a very common scenarioâââthese third-party modules are part of a typical integration scenario and are usually employed to add/extend functionalities. Analytics, Ads, and UX tools are some of the most widely used. Specifically, Ticketmaster was loading a module from company Inbenta, while British Airways was loading âModernizrâ, a JavaScript library.
When Magecart was able to inject their credit card skimmer code on these third-party modules, all websites that were loading them became immediately infected. As so, they started unknowingly serving the infected code to end-users, which could then steal their credit card data.
Itâs here that we identify the major cause for concern: companies have had zero control and visibility over this code and thatâs why it takes them several weeksâââor even monthsâââto identify these attacks.
The attack on Newegg had a different approach. It wasnât due to a compromised third-party tool or library: Magecart managed to compromise the companyâs server itself. Unlike the previous two cases, where the malicious code was being run in every web page, Magecart was able to inject the 15 lines of malicious JavaScript directly in the HTML of Neweggâs checkout page.
Even though Newegg is fully in control of this code, it still had zero visibility over the attack, that spanned for a full month. Itâs likely that Newegg has several security systems in place, and yet they failed to prevent and detect the attack in a proper timeframe.
Prevention Strategies
After understanding how these attacks were perpetrated, itâs possible to identify some prevention strategies. Below, we highlight two security standards that should be considered against Magecart (and similar)Â attacks.
We will also detail how Magecart can evolve to become more dangerous and present a single strategy to address Magecart and âMagecart 2.0â.
1âââSubresource Integrity
A first security standard to be considered would be to add Subresource Integrity (SRI) attributes to the script elements loading the external scripts.
By checking the file integrity, the website will not load scripts that are different from the original ones. As so, malicious scripts wonât be loaded from third-parties. If we frame this to the Magecart attacks we analyzed before, weâre led to the conclusion that the third-party scripts would be stopped the minute they became compromised. Neweggâs case is different, as there was no script tag loading an external JavaScript re
Disclaimer
The views and opinions expressed in this article are solely those of the authors and do not reflect the views of Bitcoin Insider. Every investment and trading move involves risk - this is especially true for cryptocurrencies given their volatility. We strongly advise our readers to conduct their own research when making a decision.