{"id":7441,"date":"2018-09-19T17:14:40","date_gmt":"2018-09-19T21:14:40","guid":{"rendered":"https:\/\/www.thesslstore.com\/blog\/?p=7441"},"modified":"2020-08-25T10:18:28","modified_gmt":"2020-08-25T14:18:28","slug":"magecart-newegg-breach","status":"publish","type":"post","link":"https:\/\/www.thesslstore.com\/blog\/magecart-newegg-breach\/","title":{"rendered":"Magecart: Javascript Injection used to breach Newegg, steal PCI"},"content":{"rendered":"<h2>Magecart, the same group that stole 380,000 records from British Airways, strikes again&#8230;<\/h2>\n<p>Today we\u2019re going to talk about the sophisticated group of hackers behind Magecart.<\/p>\n<p>But first, cybercrime has never been more rampant. We say that so much that at this point it\u2019s become more of a platitude than a warning. But it\u2019s true.<a href=\"https:\/\/www.thesslstore.com\/blog\/1-4-million-new-phishing-websites-created-every-month\/\"> 1.4 million phishing sites are created every month<\/a>. In 2017, <a href=\"https:\/\/www.thesslstore.com\/blog\/2017-year-of-the-phish\/\">90% of Enterprise businesses and 74% of SMBs reported being attacked<\/a>. <a href=\"https:\/\/www.thesslstore.com\/blog\/2018-cybercrime-statistics\/\">Cybercrime is a $1.5 trillion dollar industry<\/a>.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-3436\" src=\"https:\/\/www.thesslstore.com\/blog\/wp-content\/uploads\/2017\/01\/img-consider-this.png\" alt=\"year of the phish, phishing, 2017\" width=\"960\" height=\"240\" srcset=\"https:\/\/www.thesslstore.com\/blog\/wp-content\/uploads\/2017\/01\/img-consider-this.png 960w, https:\/\/www.thesslstore.com\/blog\/wp-content\/uploads\/2017\/01\/img-consider-this-300x75.png 300w, https:\/\/www.thesslstore.com\/blog\/wp-content\/uploads\/2017\/01\/img-consider-this-768x192.png 768w\" sizes=\"auto, (max-width: 960px) 100vw, 960px\" \/><\/p>\n<p>Groups like the one behind Magecart are <a href=\"https:\/\/www.thesslstore.com\/blog\/2018-cybercrime-statistics\/\">making a small fortune<\/a> by injecting Javascript that steals Personal Data and Payment Card Information (PCI). Today we\u2019re going to talk about what Magecart is, how it\u2019s evolving and what exactly makes it so sophisticated in the first place.<\/p>\n<p>So, how did Magecart attack Newegg for over a month without anyone noticing?<\/p>\n<p>Let\u2019s hash it out\u2026<span id=\"newline\"><\/span><\/p>\n<h2><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-medium wp-image-7445\" src=\"https:\/\/www.thesslstore.com\/blog\/wp-content\/uploads\/2018\/09\/Magecart-e1537390523548-300x300.jpg\" alt=\"Magecart\" width=\"300\" height=\"300\" srcset=\"https:\/\/www.thesslstore.com\/blog\/wp-content\/uploads\/2018\/09\/Magecart-e1537390523548-300x300.jpg 300w, https:\/\/www.thesslstore.com\/blog\/wp-content\/uploads\/2018\/09\/Magecart-e1537390523548.jpg 400w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/>What is Magecart?<\/h2>\n<p>Let\u2019s start with discussing card skimming, because the concept is going to be illuminating once we get into what Magecart does. A card skimmer is traditionally just a device that scans and stores payment card information. They can be used to exploit ATMs, gas pumps or pretty much any machine that accepts credit or debit cards.<\/p>\n<p>Magecart has taken that concept digital.<\/p>\n<p><a href=\"https:\/\/www.riskiq.com\/blog\/labs\/magecart-british-airways-breach\/\">RiskIQ has been tracking the group behind Magecart since 2015<\/a>. There seems to be a little disagreement on nomenclature. RiskIQ refers to the group itself as Magecart, <a href=\"https:\/\/www.volexity.com\/blog\/2018\/09\/19\/magecart-strikes-again-newegg\/\">Volexity<\/a> \u2013 the group that discovered the Newegg breach \u2013 refers to Magecart as the attack and references the group behind it. For the sake of clarity, we\u2019re going to refer to the group as Magecart moving forward.<\/p>\n<span style=\"--tl-form-height-m:150.25px;--tl-form-height-t:121.4583px;--tl-form-height-d:121.4583px;\" class=\"tl-placeholder-f-type-shortcode_12753 tl-preload-form\"><span><\/span><\/span>\n<p>Magecart has been ramping up its attacks over the course of 2018. It uses a tactic similar to Cross Site Scripting (XSS), injecting malicious javascript that sends stolen data to an external server via an HTTPS connection (the big difference is the method of injection, conceptually the same thing is accomplished though). Back in June, the group was able to <a href=\"https:\/\/www.riskiq.com\/blog\/labs\/magecart-ticketmaster-breach\/\">compromise Inbenta<\/a>, a Ticketmaster partner, and steal information from Ticketmaster International (specifically in Ireland, Turkey, New Zealand and Australia), Ticketmaster UK, GETMEIN! and TicketWeb.<\/p>\n<p>Then, earlier this month, Risk IQ identified another breach, <a href=\"https:\/\/www.riskiq.com\/blog\/labs\/magecart-british-airways-breach\/\">this time at British Airways<\/a> where around 380K customers were affected. Now, this morning, Volexity has issued its report on Magecart\u2019s attack on Newegg.<\/p>\n<p>Newegg is a popular computer hardware and electronics e-commerce retailer.<\/p>\n<h2>How did Magecart attack Newegg?<\/h2>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignright size-medium wp-image-7446\" src=\"https:\/\/www.thesslstore.com\/blog\/wp-content\/uploads\/2018\/09\/javascript-injection-e1537390553295-300x300.jpg\" alt=\"Magecart\" width=\"300\" height=\"300\" srcset=\"https:\/\/www.thesslstore.com\/blog\/wp-content\/uploads\/2018\/09\/javascript-injection-e1537390553295-300x300.jpg 300w, https:\/\/www.thesslstore.com\/blog\/wp-content\/uploads\/2018\/09\/javascript-injection-e1537390553295.jpg 400w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/>Let\u2019s start with a conceptual explanation and then we\u2019ll get into specifics. What Magecart is actually doing is basically Cross Site Scripting, which is when an attacker injects a malicious script into an otherwise legitimate web page. XSS is one of the most common attack vectors used by cybercriminals, it&#8217;s even represented in the OWASP 10. Magecart managed to inject its script into the page a bit differently than your standard XSS fare. It uses a Javascript injection to accomplish its illicit goals. Javascript is one of the most common file types for transmitting malware and performing other attacks. <a href=\"https:\/\/www.thesslstore.com\/blog\/1-out-of-every-101-emails-malicious\/\">21.4% of all malware is Javascript-based<\/a>.<\/p>\n<p>In the Newegg breach, Magecart was able to inject its poisoned Javascript on to a page hosted on &#8220;secure.newegg.com&#8221; that was presented during the checkout process. The malicious code appeared when moving to the billing page while checking out. The page (URL: https:\/\/secure.newegg.com\/GlobalShopping\/CheckoutStep2.aspx) collected form data and sent it back to the domain &#8220;neweggstats.com&#8221; via an HTTPS connection.<\/p>\n<p>There\u2019s a lot to unwrap here, everything from how the Javascript worked to how SSL\/TLS aided the attackers in exfiltrating the stolen data.<\/p>\n<p>Let\u2019s start with the code. This is the snippet that was responsible for the PCI theft:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-7443\" src=\"https:\/\/www.thesslstore.com\/blog\/wp-content\/uploads\/2018\/09\/newegg_4.png\" alt=\"Magecart\" width=\"1686\" height=\"250\" srcset=\"https:\/\/www.thesslstore.com\/blog\/wp-content\/uploads\/2018\/09\/newegg_4.png 1686w, https:\/\/www.thesslstore.com\/blog\/wp-content\/uploads\/2018\/09\/newegg_4-300x44.png 300w, https:\/\/www.thesslstore.com\/blog\/wp-content\/uploads\/2018\/09\/newegg_4-768x114.png 768w, https:\/\/www.thesslstore.com\/blog\/wp-content\/uploads\/2018\/09\/newegg_4-1024x152.png 1024w\" sizes=\"auto, (max-width: 1686px) 100vw, 1686px\" \/><\/p>\n<p>There are a few fascinating things about this Javscript, perhaps the biggest being that it\u2019s a vivid display of Magecart\u2019s continued growth in terms of its level of sophistication. While all of the XSS injections are conceptually similar, each one is customized to its respective target and the code keeps getting more and more refined. In the British Airways breach earlier this month the injection was 22 lines. Less than a month later, the Newegg Javascript is just 8 lines (15 if you beautify it, which is just a fancy way of saying you made the code look fancy).<\/p>\n<p>I\u2019m not going to go line-by-line through it, I&#8217;ll just focus on three. The first line dictates that all page elements should load before execution. The second line handles what data will be transmitted and when that transmission occurs, which is when a mouse button is released or a touch screen button is touched and released (accounting for the high volume of mobile users). The final line shows where the stolen data is being transmitted to.<\/p>\n<p>Here is <a href=\"https:\/\/www.volexity.com\/blog\/2018\/09\/19\/magecart-strikes-again-newegg\/\">Volexity\u2019s description of how the script worked<\/a>:<\/p>\n<ol>\n<li>Create a variable named <strong>dati<\/strong> containing all information entered within a form titled <strong>checkout<\/strong>.<\/li>\n<li>Take the data captured within the <strong>dati<\/strong> variable and create an array by serializing the form field names and values with the <a href=\"https:\/\/www.w3schools.com\/jquery\/ajax_serializearray.asp\">serializeArray()<\/a> method.<\/li>\n<li>Takes the array of data and convert it to a JSON formatted string with the <a href=\"https:\/\/www.w3schools.com\/js\/js_json_stringify.asp\">JSON.stringify()<\/a> method.<\/li>\n<li>Submit the JSON string to the URL\u00a0<strong>https:\/\/neweggstats.com\/GlobalData\/ <\/strong>within a POST request.<\/li>\n<\/ol>\n<p>The attack lasted from August 16th until September 18th, when the malicious Javascript was finally removed.<\/p>\n<h2>Magecart hid its data exfiltration in encrypted traffic<\/h2>\n<p>The domain that was being used to collect the stolen PCI was registered with Namecheap on August 13<sup>th<\/sup>, three days before the attack is confirmed to have started. <a href=\"https:\/\/censys.io\/ipv4\/217.23.4.11\/table#443\">The attackers also installed an SSL certificate on the domain<\/a>. This allowed it to form HTTPS connections and obfuscate the data that was being sent.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-7442\" src=\"https:\/\/www.thesslstore.com\/blog\/wp-content\/uploads\/2018\/09\/newegg_3.png\" alt=\"Magecart\" width=\"1356\" height=\"794\" srcset=\"https:\/\/www.thesslstore.com\/blog\/wp-content\/uploads\/2018\/09\/newegg_3.png 1356w, https:\/\/www.thesslstore.com\/blog\/wp-content\/uploads\/2018\/09\/newegg_3-300x176.png 300w, https:\/\/www.thesslstore.com\/blog\/wp-content\/uploads\/2018\/09\/newegg_3-768x450.png 768w, https:\/\/www.thesslstore.com\/blog\/wp-content\/uploads\/2018\/09\/newegg_3-1024x600.png 1024w\" sizes=\"auto, (max-width: 1356px) 100vw, 1356px\" \/><\/p>\n<p>This is common practice for Magecart, it regularly registers target-specific domains and uses them to hide within the normal encrypted traffic for their targets\u2019 sites.<\/p>\n<p>This one of those places where <a href=\"https:\/\/www.thesslstore.com\/blog\/ssl-inspection\/\">HTTPS interception<\/a> could have potentially helped to ferret out the data that was being transmitted to the attackers\u2019 server. There\u2019s not really a consensus on HTTPS interception (sometimes called SSL inspection), on the one hand <a href=\"https:\/\/www.thesslstore.com\/blog\/https-interception-harming-security\/\">it\u2019s proven that it does weaken encryption<\/a>. On the other, given the number of threats facing modern businesses \u2013 and the ability for those threats to hide in encrypted traffic \u2013 many feel HTTPS interception is a necessary evil. <a href=\"https:\/\/www.thesslstore.com\/blog\/pki-certificate-management-mistakes\/\">Certainly, at an Enterprise level it\u2019s advisable<\/a>.<\/p>\n<p>Still, with an attacker as sophisticated as Magecart, there\u2019s only so much that can be done. So far Magecart has victimized British Airways, Ticketmaster, Feedify and ABS-CBN. And as it continues to evolve and becomes harder to track, the risk Magecart poses is only going to grow in conjunction.<\/p>\n<p><em>As always, leave any questions or comments below\u2026<\/em><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-7276\" src=\"https:\/\/www.thesslstore.com\/blog\/wp-content\/uploads\/2018\/08\/bigstock-222348568.jpg\" alt=\"Hashed Out by The SSL Store is the voice of record in the SSL\/TLS industry.\" width=\"1559\" height=\"407\" srcset=\"https:\/\/www.thesslstore.com\/blog\/wp-content\/uploads\/2018\/08\/bigstock-222348568.jpg 1559w, https:\/\/www.thesslstore.com\/blog\/wp-content\/uploads\/2018\/08\/bigstock-222348568-300x78.jpg 300w, https:\/\/www.thesslstore.com\/blog\/wp-content\/uploads\/2018\/08\/bigstock-222348568-768x200.jpg 768w, https:\/\/www.thesslstore.com\/blog\/wp-content\/uploads\/2018\/08\/bigstock-222348568-1024x267.jpg 1024w\" sizes=\"auto, (max-width: 1559px) 100vw, 1559px\" \/><\/p>\n\n","protected":false},"excerpt":{"rendered":"<p>Magecart, the same group that stole 380,000 records from British Airways, strikes again&#8230; Today we\u2019re going to talk about the sophisticated group of hackers behind Magecart. But first, cybercrime has&#8230;<\/p>\n","protected":false},"author":6,"featured_media":7448,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":"","tve_updated_post":"","tve_custom_css":"","tve_user_custom_css":"","tve_globals":{},"tcb2_ready":0,"tcb_editor_enabled":0,"tve_landing_page":"","_tve_header":"","_tve_footer":""},"categories":[16],"tags":[8598,4329],"class_list":["post-7441","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-hashing-out-cyber-security","tag-magecart","tag-xss","post-with-tags"],"views":25606,"jetpack_featured_media_url":"https:\/\/www.thesslstore.com\/blog\/wp-content\/uploads\/2018\/09\/bigstock-Milan-Italy-August-212302831.jpg","_links":{"self":[{"href":"https:\/\/www.thesslstore.com\/blog\/wp-json\/wp\/v2\/posts\/7441","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.thesslstore.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.thesslstore.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.thesslstore.com\/blog\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/www.thesslstore.com\/blog\/wp-json\/wp\/v2\/comments?post=7441"}],"version-history":[{"count":0,"href":"https:\/\/www.thesslstore.com\/blog\/wp-json\/wp\/v2\/posts\/7441\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.thesslstore.com\/blog\/wp-json\/wp\/v2\/media\/7448"}],"wp:attachment":[{"href":"https:\/\/www.thesslstore.com\/blog\/wp-json\/wp\/v2\/media?parent=7441"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.thesslstore.com\/blog\/wp-json\/wp\/v2\/categories?post=7441"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.thesslstore.com\/blog\/wp-json\/wp\/v2\/tags?post=7441"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}