Drinking coffee every morning !

Credit Card numbers leak in Magento

There’s no unbreakable protection. You may have the hosting provider with a great security: firewalls, antiviruses, malware protection etc., but.. Are you sure that your home/office computer is protected enough, and your neighbor is absolutely trusted person? It worth nothing to grab saved passwords, cookies, RSA keys from some computer and get an ability to access secured remote area. Recently, we’ve noticed that some sites were affected by the exploit which sends customers credit card numbers to a remote site. It’s useful to check your own site because you might not even guess about the ‘gremlin’ in your Magento installation.

Most often the exploit affects Saved Credit Card payment method, but it might be present in any other payment method as well. In this article we’ll explain how to ensure that Saved Credit Card payment method is not hacked as an example, and you can follow the same approach in order to check the relevant payment method used in your store. The malicious code is normally being placed in the payment method’s model: [magento_root]/app/code/core/Mage/Payment/Model/Method/Cc.php

There’s a system method called prepareSave(). In the standard Magento installation, it looks like this:

As you can see, there are many new lines. The main purpose of the malicious code is to collect personal data, which is being entered by a customer and send it to the remote server using CURL request. The server’s domain name each time was the same: http://java-e-shop.com/add.

Well then, for fast malicious code checking just open with a text editor the following file [magento_root]/app/code/core/Mage/Payment/Model/Method/Cc.php. Using search in the text editor, find ‘function prepareSave()’ there. Compare contents of the function with the first example mentioned above. If it looks like the first example (the contents might be slightly different, depending on Magento version) – you can sleep peacefully. But if it looks more like the second example, you need to fix it right now. Firs of all, download a clean copy of the Magento installation that exacts your Magento version. Open app/code/core/Mage/Payment/Model/Method/Cc.php in the clean copy, then copy prepareSave()function with its contents and paste instead of the affected function in your current Magento installation. Then, ensure that the payment process is working correctly. After this, change all your passwords, especially SSH/cPanel/FTP/WHM. Now you are safe.

Share this:

I'm 26 years old, a web developer from Nha Trang, Viet Nam. I love travelling and listen to rock music all day. This site is where I share my knowledges, my moments and some stuff...Wanna drink some beer? Feel free to contact me at the footer.