Critical flaw in PHPMailer library puts millions of websites at risk

The vulnerability could allow attackers execute arbitrary shell commands on web servers

A critical remote code execution vulnerability in PHPMailer, one of the most widely used PHP email sending libraries, could put millions of websites at risk of hacking.

The flaw was found by a security researcher named Dawid Golunski and an initial fix was included in PHPMailer 5.2.18, which was released Saturday. However, it turns out that the patch was incomplete and can be bypassed.

The PHPMailer library is used directly or indirectly by many content management systems (CMSs) including WordPress, Joomla and Drupal. Where the library is not included in their core code, it is likely available as a separate module or can be bundled with third-party add-ons.

Because of this, the flaw's impact can vary from website to website. For example, the Joomla security team determined that the Joomla JMail class, which relies on PHPMailer, has additional validations in place that make exploiting the vulnerability impractical.

The flaw is caused by insufficient validation of the sender email address input and can allow an attacker to inject shell commands that would be executed on the web server in the context of the sendmail program.

However, successful exploitation requires the presence of a web form on the website that uses PHPMailer to send emails and allows inputting a custom sender email address -- the address that appears in the From email header. It's not clear how common such configurations are, because usually web forms have the sender email predefined and only allow users to input their own email address as a recipient.

"All places in the core Joomla API which send mail use the sender address set in the global configuration and does not allow for user input to be set elsewhere," the Joomla security team said in an advisory. "However, extensions which bundle a separate version of PHPMailer or do not use the Joomla API to send email may be vulnerable to this issue."

The WordPress developers reached a similar conclusion, noting on their own bug tracker that the internal wp_mail() function used by the WordPress core code is not affected because it does not use the vulnerable PHPMailer feature. Third-party plug-ins that use wp_mail() correctly should theoretically not be affected either, but the impact to specific plug-ins is still under investigation.

"The upcoming 4.7.1 release will contain mitigation for these issues," WordPress lead developer Dion Hulse said. "We're committed to only shipping secure libraries with WordPress -- regardless of whether we use the feature or not."

The Drupal security team also put out a security advisory for this issue and marked it as critical, even though the Drupal core code is not affected by the flaw.

"Given the extreme criticality of this issue and the timing of its release we are issuing a Public Service Announcement to alert potentially affected Drupal site maintainers," the team said.

Because the initial fix can be bypassed and public exploit code is available, the vulnerability has zero-day status -- it is publicly known and unpatched. Furthermore, because the impact varies from website to website, depending on how PHPMailer is used, there's not easy way for webmasters to mitigate the problem without a thorough evaluation.

If they use PHPMailer directly in their website's code, they should upgrade the library to the latest patched version as soon as it's released. They should also determine if any of their site's contact, feedback, registration, email reset and other forms send out emails with the help of a vulnerable version of PHPMailer and if a potential attacker can input the sender email address.

If they use a content management system they should check its support website to determine if it's affected in its default configuration. Then they should asses the impact for any any third-party plug-ins or modules that they have installed and which might use PHPMailer on their own.

Join the PC World newsletter!

Error: Please check your email address.

Our Back to Business guide highlights the best products for you to boost your productivity at home, on the road, at the office, or in the classroom.

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

Essentials

Microsoft L5V-00027 Sculpt Ergonomic Keyboard Desktop

Learn more >

Lexar® JumpDrive® S57 USB 3.0 flash drive

Learn more >

Mobile

Lexar® JumpDrive® S45 USB 3.0 flash drive 

Learn more >

Exec

Lexar® Professional 1800x microSDHC™/microSDXC™ UHS-II cards 

Learn more >

HD Pan/Tilt Wi-Fi Camera with Night Vision NC450

Learn more >

Audio-Technica ATH-ANC70 Noise Cancelling Headphones

Learn more >

Lexar® JumpDrive® C20c USB Type-C flash drive 

Learn more >

Budget

Back To Business Guide

Click for more ›

Most Popular Reviews

Latest News Articles

Resources

PCW Evaluation Team

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.

Ed Dawson

HP OfficeJet Pro 8730

As a freelance writer who is always on the go, I like my technology to be both efficient and effective so I can do my job well. The HP OfficeJet Pro 8730 Inkjet Printer ticks all the boxes in terms of form factor, performance and user interface.

Michael Hargreaves

Windows 10 for Business / Dell XPS 13

I’d happily recommend this touchscreen laptop and Windows 10 as a great way to get serious work done at a desk or on the road.

Aysha Strobbe

Windows 10 / HP Spectre x360

Ultimately, I think the Windows 10 environment is excellent for me as it caters for so many different uses. The inclusion of the Xbox app is also great for when you need some downtime too!

Mark Escubio

Windows 10 / Lenovo Yoga 910

For me, the Xbox Play Anywhere is a great new feature as it allows you to play your current Xbox games with higher resolutions and better graphics without forking out extra cash for another copy. Although available titles are still scarce, but I’m sure it will grow in time.

Featured Content

Latest Jobs

Don’t have an account? Sign up here

Don't have an account? Sign up now

Forgot password?