r/drupal • u/mlhess • Mar 28 '18
Update now -- Drupal core - Highly critical - Remote Code Execution - SA-CORE-2018-002
https://www.drupal.org/sa-core-2018-0029
u/Rhodiego Mar 28 '18
Looks like Acquia deployed a platform mitigation: https://twitter.com/acquia_support/status/979093305429405696?s=20
7
u/mgmgmgmgmgm Mar 28 '18
And Pantheon too by the looks of it: https://pantheon.io/blog/security-update-drupal-sa-2018-002
9
u/elondaits Mar 28 '18
I applied the Drupal 6 patch to a Drupal 5 installation (with minimal adaptations) and it seems to work. I can't claim this is necessary (but I think it is), or that it's sufficient (better than nothing?) or that it won't break something.
So... here's the patch for Drupal 5: https://pastebin.com/zW765ruV
4
2
u/mikeytown2 Contrib Dev Mar 28 '18
You should patch D5 as this issue deals with how array keys that start with "#" are special.
6
u/watbe Mar 28 '18
I guess this is about as bad as it gets; remote code execution without any mitigating factors.
6
u/greenthumble Mar 29 '18
Well I had planned to take my birthday off. Guess not. As a 10+ year Drupal veteran I'm nearing the end of my ropes here.
2
u/grumblegrim Mar 29 '18
Or just take your birthday off. You are allowed to mind your own health before that of a website first.
1
u/greenthumble Mar 30 '18
Thanks for the sentiment but I never would have been able to sleep last night leaving the sites I babysit open to attack. Fortunately of 20 or so sites only 2 had any issues. All the D7 sites were already done and udpated by an automatic system that just
drush up drupalevery evening and runs tests. One D6 site was a pain, after I applied patch it WSODd. And one D8 site was a pain, it was an 8.3 site that I just took the hit and went to 8.5 on now have to clean some stuff up there heh.
5
u/pwhite Mar 28 '18
Drupal.org down for anyone else atm?
2
5
u/jibbawock Mar 29 '18
So now that the smoke has cleared and I’m all updated I’m curious—any exploits seen in the wild yet?
1
5
u/and_Dez Mar 29 '18
I am super proud of my team we updated 24 drupal 8 sites 29 drupal 7 sites across 3 server environments.
3
u/illtakethewindowseat Mar 29 '18
We did 89!
9
u/WhoaItsAFactorial Mar 29 '18
89!
89! = 1.6507955160908465e+136
1
u/Kronis1 Mar 30 '18
Bad bot
1
u/GoodBot_BadBot Mar 30 '18
Thank you, Kronis1, for voting on WhoaItsAFactorial.
This bot wants to find the best and worst bots on Reddit. You can view results here.
Even if I don't reply to your comment, I'm still listening for votes. Check the webpage to see if your vote registered!
9
u/Tetracyclic Mar 28 '18 edited Mar 28 '18
Eight sites successfully patched here, just waiting on the D6 LTS patch to drop.
We've gained a request sanitizer, the meat of which is this check:
if ($key !== '' && $key[0] === '#' && !in_array($key, $whitelist, TRUE)) {
unset($input[$key]);
$sanitized_keys[] = $key;
}
else {
$input[$key] = static::stripDangerousValues($input[$key], $whitelist, $sanitized_keys);
}So it would appear to be an issue with request keys starting with a # character.
EDIT: The obvious way to begin to exploit this is to attach whatever you want as a form handler by passing in a request key starting with #, but jumping from that to full RCE is probably best left to someone with more knowledge than I.
10
u/intoxination Mar 28 '18
D6 Patch is out and available here:
https://www.drupal.org/files/issues/2018-03-28/SA-CORE-2018-002.patch
2
5
u/calligraphic-io Mar 28 '18
Here's a tweet from Kyle Cunningham with more information:
Drupal uses the hash "#" at the beginning of array keys to signify special keys usually that lead to some type of computation. Basically you can inject these. See Drupal form API for example
Drupal render arrays use the pound symbol to denote metadata (as opposed to renderable array keys). The Forms API makes use of render arrays. I'm looking through the codebase to see what the exploit might be, I haven't found it yet. I'll be interested to know when someone else finds it and comments on what it is.
1
u/bfr_ Mar 29 '18
It was our developer who found it, but cannot comment anything else than that everyone is affected, so patch quickly.
4
u/elondaits Mar 28 '18
16 sites done, 12 to go. I want a new job 😨.
3
u/xroni Mar 29 '18
I'm not sure if you are serious, but in case you are, please consider the following:
Make sure you automate your update procedure. Performing an update is just following a series of very basic steps that are the same every time. There is no reason at all for manual steps to be taken. Once you have more than 2 or 3 sites it pays off to start automating.
You can use simple scripts to automate it, typically people use Bash or Python for it that fire a sequence of commands, leveraging Drush or Drupal Console to do the work.
If you don't want to start maintaining your own scripts, there are third party tools that you can use that are designed for deploying updates to websites automatically. Some generic ones are Ansible, Puppet or SaltStack. There are also solutions that have support for Drupal out of the box and are more suitable for beginning hosts, like Pantheon, Platform SH, Aegir, ...
This update is not a one time event. There are potential security releases every two weeks. Start automating today (or convince your boss that this is needed), or it is possible that you start questioning your job again two weeks from now ;)
5
u/elondaits Mar 29 '18
Yes, dead serious.
To give some context: These are sites developed for several different customers. A number of those (around 10) I actually actively maintain with ongoing monthly contracts, and they're all on decent hosting accounts. The others are cases where the customers don't have IT people, don't know any better, and sites might be in real crappy hostings... some of the sites were done 2-3 years ago, but I updated them as an "extended warranty" kind of thing because it's easier now than deal with the consequences later.
For all cases I had git repositories with the latest sources and a local copy in my dev server. I updated the local copy via drush, rsynced and updated the remote db. So pretty automatic... but some crappy hostings only had very very slow ftp access (I synced through GoodSync).
Also my main customer has a very very complex Drupal not developed by me with tons of modules. I created a capistrano based deploy mechanism with dev, staging and production servers. I also created a phantomCSS powered test suite that does visual comparisions of several different paths (50-60 I think) to make sure nothing breaks... so updating means running the tests, updating dev, running the tests again with automatic comparision of screenshots, deploying to staging, checking nothing broke, deploying to production. It's all very automated but still a pain... because that Drupal is chock full of modules, super slow, etc.
I use Drush, capistrano for that one site, and I have my own Python scripts that allow me to perform "safe" rsyncs (with a Dry run) of Drupal sites (with or without the sites/all/files directory, without the settings, etc.).
I always strive to automate my work. My goal in life is to "write the robot that replaces me" figuratively.
... but yesterday I had to update all these sites at once, running against the clock, dealing with bad choices of hosting companies other people made, applying extra upgrades that appeared between the last time and now, back-porting the Drupal 6 patch to a Drupal 5 I have to maintain, dealing with a couple of sites that were not installed in my current macbook because I hadn't worked in them for 3+ years, etc. It was a nightmare that took me like 7 straight hours of stressful work. The 10 sites I actively maintain and have contracts for were probably done in the first 2 hours.
[edit - Oh, I forgot:] In one of the crappy hosted sites I hadn't worked in for a very very long time I found a number of .php malware files apparently uploaded a long time ago. Thanks to syncing from my sources they were very evident. I also removed those.
2
0
Mar 28 '18
[deleted]
4
u/mjpa Mar 28 '18
Only thing that springs to mind is the form api or the render api... but that'd imply $_GET / $_POST / $_COOKIE is merged into a form array or something.... but that'd be pretty stupid to do....
1
u/spin81 Mar 28 '18
Being unfamiliar with Drupal it sounds to me like the hash keys just correspond to code and get executed straight out of the superglobals, with no way of preventing it unless you patch. I'd agree with you that it is stupid - and then some.
5
u/sarciszewski Mar 28 '18
It's actually worse than you think: https://twitter.com/codeincarnate/status/979080318966730753
3
u/mjpa Mar 28 '18
Had a brief look but not finding anything obvious where they can be injected.
The fact that there's a sanitizer and not a fix the vulnerable bit suggests it's more than one place...
2
u/f1234k Mar 28 '18
Or they do not want to "photograph" the part of the code that could be exploited.
2
u/mjpa Mar 29 '18
They were fine fixing the SQL injection one at the point of entry. I have a feeling this isn't exploitable in core but more in a few high profile contrib modules and it's an easy fix in core.
1
u/HiddenIncome Mar 29 '18
Fixing the SQL injection in that one place was unavoidable.
I have a feeling this isn't exploitable in core but more in a few high profile contrib modules and it's an easy fix in core.
The security risk TD:Default indicates core itself is vulnerable. The FAQ expands this to: "What percentage of users are affected? Default or common module configurations are exploitable, but a config change can disable the exploit."
1
3
u/spin81 Mar 28 '18
From Googling it, it seems that you can use these hash parameters to trigger render hooks and build up your page that way, including the
#markupkey, which by its name sounds perfect for XSS attacks.2
u/jkksldkjflskjdsflkdj Mar 28 '18
When you see stuff like $form_state['input'] = $_POST; (in ajax.inc) you have to wonder.
4
u/Tetracyclic Mar 28 '18 edited Mar 28 '18
Mm, we've mostly moved away from Drupal to Laravel, so it's just a bunch of legacy enterprise D6 and D7 sites left on the books.
It'll be interesting to read the post-mortems in the coming days. It's likely to do with the special
#array keys, I can't think of a good proof-of-concept off the top of my head, but I can see how it wouldn't be too hard to come up with one.1
u/mecromace Mar 28 '18
The first thing I thought of was how # is often treated as a comment indicator in many languages including php. This could potentially be used like the classic SQL injection via comments:
;select * from <table>;--. My thought process would be if a malicious key contained encoded characters like\nwhich were later escaped and had executable code following. In such a case, you could throw anything in there and hope it gets executed at some point down the line whether it is php, twig, javascript, etc. This specifically white-lists keys so random code can't be injected in the manner I described.
4
u/CrypticOctagon Mar 30 '18
Does anyone know what to look for when auditing whether a site has been exploited by this bug? Thanks.
3
u/thereallamewad Mar 28 '18
Anyone know anything about this error?
Could not find package drupal/core in a version matching 8.5.1
0
Mar 28 '18
[deleted]
2
u/xroni Mar 29 '18
Tip: you can avoid the dependency on the Github mirror if you add the following lines to your
composer.jsonfile. This will instruct Composer to look for the updates on drupal.org's own servers:"repositories": [ { "type": "composer", "url": "https://packages.drupal.org/8" } ]1
2
2
u/mr_pablo Mar 29 '18
Anyone had twitter feeds break after patching?
1
Mar 29 '18
I have a patched D7 site that's still successfully importing tweets after the update. (But thanks for the heads-up to check)
2
u/Kronis1 Mar 30 '18
Has anyone seen this in the wild yet?
2
u/HiddenIncome Mar 31 '18
I'm monitoring a number of sites, including a honeypot. So far, I've detected no exploit activity. I've also not seen any reports indicating otherwise.
In addition, I went back 6 months in stored logs on several sites and found no exploit activity for SA-CORE-2018-002.
1
u/StrongLinks Apr 02 '18
Just a question: What in earth are you using to identify this exploit via logs?
This vulnerability allows RCE, and without a public exploit kit, there is no telling what the exploit vector (pattern) is that will show up in logs.
On top of that, with RCE an attacker could theoretically remove large portions of logs... So what exactly are you looking for?
We've some guys discussing this further on the GreySec forums here: https://greysec.net/showthread.php?tid=2912&pid=10594#pid10594
If you want to register you can use my refer link: https://greysec.net/member.php?action=register&referrer=2630
2
u/HiddenIncome Apr 02 '18
I'm using the conf/settings "sanitize_input_logging" to detect potential exploit attempts since the patches were applied. This is something anyone can do.
As for possible historical exploits; our sites log all interesting logs to a central logging server, removal is not possible.
[...] without a public exploit kit, there is no telling what the exploit vector (pattern) is that will show up in logs.
Sorry, I'm not able to share any additional information on exploit patterns.
1
1
2
2
u/brontide Mar 29 '18 edited Mar 29 '18
Do I need to populate the configs with sanitize_input_whitelist or does the empty array work?
EDIT: Answering my own question the whitelist appears to only be for # input variables and not for regular ones. We're going to go ahead and presume that this only need to be populated for sites that require some internal use of those special inputs.
2
u/CritterM72800 mcrittenden Mar 30 '18
You're correct - the majority of sites shouldn't need to touch that.
2
u/grumblegrim Mar 29 '18
Drupal 8.3.x and 8.4.x are no longer supported
Is this a joke? Because Drupal.org makes it really convenient to just update to the latest version and all. /s
4
Mar 30 '18
Yep. Which is why where I work has migrated the bulk of our sites away from Drupal, just three more to go.
I love Drupal, but the migration between versions is an absolute nightmare and always has been, when compared to other popular CMS offerings.
I've been through hell with Drupal from 4x to 5x, 5x to 6x and 6x to 7x - I finally decided I'd had it with the pain of doing this. No more.
1
u/mr_pablo Mar 31 '18
May I ask what platform you moved too?
3
Mar 31 '18
In the past, I've moved to ExpressionEngine from Drupal. Right now, wordpress - as the sites in question don't really require the power that Drupal provides.
I have to hold my hand up here and again stress just how much I love working with Drupal. It's arguably one of the most flexible and powerful CMS systems and I really respect that - it's a CMS that favours developers as it can do pretty much near anything you want, so long as you invest the time.
It's just the upgrade pain - I really wish that could be sorted.
1
u/intoxination Mar 30 '18
Same here. It's not just the headaches of doing the actual migrations, but explaining to clients the why and costs associated.
1
u/mikey_p5151 Apr 02 '18
What problems are you having with Drupal 8 minor version releases? 100% of these have been seamless for me as they aren't allowed to have any breaking changes.
Are you thinking of major version updates? Like 7.x -> 8.x?
(and if you've been around long enough, you might remember the 4.x series, which included breaking changes with minor version releases).
1
u/HiddenIncome Apr 12 '18
Update: Checkpoint published a near-exploit on https://research.checkpoint.com/uncovering-drupalgeddon-2/
1
1
0
Mar 29 '18
[deleted]
7
u/sarciszewski Mar 29 '18
This is why Drupal needs automatic security updates, with code-signing.
2
u/elondaits Mar 29 '18
Unfortunately I've witnessed 3rd party modules breaking after updating the core, and functionality breaking after updating 3rd party modules.
... So you have to update everything, but only after making sure nothing breaks. It's not feasible to completely automate updating.
1
u/sarciszewski Mar 29 '18
You can for 99.99% of the world.
For people who are afraid of automatic breakage, they can choose to disable the automatic updates, knowing that they take on the full responsibility of any security consequences for failing to update in a timely manner.
For an example of an organization that failed to update in a timely manner, see: Equifax and Apache Struts.
The vast majority of people are better served with automatic updates, but only if they're implemented securely.
17
u/Hakaku Mar 28 '18
Just updated 600 sites. It's been a fun afternoon.