Unpatched vulnerability exposes Magento online shops to hacking

The flaw allows attackers to upload and execute malicious PHP scripts on web servers

IDG

IDG

An unpatched vulnerability in the Magento e-commerce platform could allow hackers to upload and execute malicious code on web servers that host online shops.

The flaw was discovered by researchers from security consultancy DefenseCode and is located in a feature that retrieves preview images for videos hosted on Vimeo. Such videos can be added to product listings in Magento.

The DefenseCode researchers determined that if the image URL points to a different file, for example a PHP script, Magento will download the file in order to validate it. If the file is not an image, the platform will return a "Disallowed file type" error, but won't actually remove it from the server.

An attacker with access to exploit this flaw could achieve remote code execution by first tricking Magento to download an .htaccess configuration file that enables PHP execution inside the download directory and then downloading the malicious PHP file itself.

Once on the server, the PHP script can act as a backdoor and can be accessed from an external location by pointing the browser to it. For example, attackers could use it to browse the server directories and read the database password from Magento's configuration file. This can expose customer information stored in the database, which in the case of online shops, can be very sensitive.

The only limitation is that this vulnerability cannot be exploited directly because the video-linking functionality requires authentication. This means attackers need to have access to an account on the targeted website, but this can be a lower-privileged user and not necessarily an administrator.

The authentication obstacle can also be easily overcome if the website doesn't have the "Add Secret Key to URLs" option turned on. This option is intended to prevent cross-site request forgery (CSRF) attacks and is enabled by default.

CSRF is an attack technique that involves forcing a user’s browser to perform an unauthorized request on a website when visiting a different one.

"The attack can be constructed as simple as <img src=… in an email or a public message board, which will automatically trigger the arbitrary file upload if a user is currently logged into Magento," the DefenseCode researchers said in an advisory. "An attacker can also entice the user to open a CSRF link using social engineering."

This means that by simply clicking on a link in an email or by visiting a specifically crafted web page, users who have active Magento sessions in their browser might have their accounts abused to compromise websites.

The DefenseCode researchers claim that they've reported these issues to the Magento developers back in November, but received no information regarding patching plans since then.

Several versions of the Magento Community Edition (CE) have been released since November, the most recent one being 2.1.6 on Tuesday. According to DefenseCode, all Magento CE versions continue to be vulnerable, which is what prompted them to go public about the flaw.

Magento, the company that oversees development of the e-commerce platform, did not immediately respond to a request for comment.

"All users are strongly advised to enforce the use of 'Add Secret Key to URLs' which mitigates the CSRF attack vector," the DefenseCode researchers said. "To prevent remote code execution through arbitrary file upload the server should be configured to disallow .htaccess files in affected directories."

Magento is used by over 250,000 online retailers, making it an attractive target for hackers. Last year, researchers found thousands of Magento-based online shops that had been compromised and infected with malicious code that skimmed payment card details.

Join the newsletter!

Error: Please check your email address.
Rocket to Success - Your 10 Tips for Smarter ERP System Selection
Keep up with the latest tech news, reviews and previews by subscribing to the Good Gear Guide newsletter.

Lucian Constantin

IDG News Service
Show Comments

Father’s Day Gift Guide

Most Popular Reviews

Latest Articles

Resources

PCW Evaluation Team

David Coyle

Brother PocketJet PJ-773 A4 Portable Thermal Printer

I rate the printer as a 5 out of 5 stars as it has been able to fit seamlessly into my busy and mobile lifestyle.

Kurt Hegetschweiler

Brother PocketJet PJ-773 A4 Portable Thermal Printer

It’s perfect for mobile workers. Just take it out — it’s small enough to sit anywhere — turn it on, load a sheet of paper, and start printing.

Matthew Stivala

HP OfficeJet 250 Mobile Printer

The HP OfficeJet 250 Mobile Printer is a great device that fits perfectly into my fast paced and mobile lifestyle. My first impression of the printer itself was how incredibly compact and sleek the device was.

Armand Abogado

HP OfficeJet 250 Mobile Printer

Wireless printing from my iPhone was also a handy feature, the whole experience was quick and seamless with no setup requirements - accessed through the default iOS printing menu options.

Azadeh Williams

HP OfficeJet Pro 8730

A smarter way to print for busy small business owners, combining speedy printing with scanning and copying, making it easier to produce high quality documents and images at a touch of a button.

Andrew Grant

HP OfficeJet Pro 8730

I've had a multifunction printer in the office going on 10 years now. It was a neat bit of kit back in the day -- print, copy, scan, fax -- when printing over WiFi felt a bit like magic. It’s seen better days though and an upgrade’s well overdue. This HP OfficeJet Pro 8730 looks like it ticks all the same boxes: print, copy, scan, and fax. (Really? Does anyone fax anything any more? I guess it's good to know the facility’s there, just in case.) Printing over WiFi is more-or- less standard these days.

Featured Content

Latest Jobs

Don’t have an account? Sign up here

Don't have an account? Sign up now

Forgot password?