r/PHP • • Mar 28 '18

Drupal core - Highly critical - Remote Code Execution - SA-CORE-2018-002

https://www.drupal.org/sa-core-2018-002
60 Upvotes

17 comments sorted by

5

u/sarciszewski Mar 29 '18

Mirrored patches:

The actual mitigation of these patches: https://gist.github.com/paragonie-scott/79ddffd734bf15a9d86b723d74d15572#file-drupal-7-x-2018-002-patch-L91

Explanation: https://twitter.com/codeincarnate/status/979080318966730753

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

2

u/[deleted] Mar 29 '18

Has anyone analyzed the vulnerability and said if we need to really worry. Being able to execute a random function is really bad, but if you can't pass parameters to it, then...

-12

u/[deleted] Mar 29 '18 edited Mar 29 '18

[removed] — view removed comment

4

u/Otterfan Mar 29 '18

While it's pretty shocking, it's also been an open door for years and no (known) attacks have surfaced.

17

u/CryptoCricket1 Mar 29 '18

Wow. I expected something way more complex. How was this not noticed earlier?

And they fix it by sanitizing input and not by changing hiw they trwat user data. Sanitizing inputis now long known to be a bad idea tor security and just leads to further exploits down the line anyway since it doesn't fix the root cause. Some day someobe in srupal will write special logic arouns keys starting with $ or % and this sanitization wont help then again.

This kind of bugs are final nails in Drupals coffin.

Pro tip: Take a few seconds to check for bugs in your spelling and grammar when attempting to sensationally criticize the bugs of others.

6

u/assertchris Mar 29 '18

I just imagine they're an eagle, typing with sharp eagle talons.

2

u/[deleted] Mar 29 '18

Dracon, rather.

3

u/northintersect Mar 29 '18

But he is not wrong though.

4

u/dev10 Mar 29 '18

Yes, he is.

Sanitizing inputis now long known to be a bad idea tor security and just leads to further exploits down the line anyway since it doesn't fix the root cause.

Enlighten me. Why is sanitizing user input, or any data from outside for that matter, a bad idea for security?

This kind of bugs are final nails in Drupals coffin.

This statement is utter nonsense. Drupal is not going anywhere because of this bug. If these kind of bugs would lead to the demise of a CMS, why on earth do Joomla and WordPress still exist?

8

u/[deleted] Mar 29 '18 edited Mar 29 '18

When someone says "sanitize" typically there's some shoddy filtering involved that often leaves multiple injection places (like in this case). Sanitize implies you take user data, and remove the "bad" parts. But user data is not bad or good, it's just user data in one format, and you want it probably transformed and encoded to another format for display, storage or other processing.

So in general he's right the word "sanitize" is suspicious in someone's mouth. In some cases however, and rare cases, it can be the right solution.

In this case filtering the input array to remove keys beginning with "#" would be a form of sanitization, and it should work, I'm not aware of the details of the bug, and why they failed.

EDIT: Oh, ouch, that's pretty bad. Previously it seems the keys were not validated or sanitized at all. The patch is now to filter everything out from GET/POST/COOKIE etc. which is not in a whitelist. It's a very crude solution still, but better than nothing. This suggests Drupal has some serious architectual WTFs, that won't be easy to fix soon (or ever, if the folks who designed this are still at the helm).

2

u/[deleted] Mar 29 '18

I do a lot of Drupal. This # key is at the core of how Drupal uses it's form API, and render API.

A long term fix will be painful and that's why this patch was put together quickly. Drupal , while not as bad as wp, have a very large contributed/ plugin community and I'd guess any changes to form/ render API the could correct the are going to cause massive bc breaks.

Also yes, architecture is a complicated beast in Drupal. It has beginnings like wp, but had evolved to a framework that has massive abstarction layers to keep people from having to code. It's a damn mess, a productive one, but most devs who with on drupals tends to feel, 'i hate it, but it's the correct too for this project'

2

u/[deleted] Mar 29 '18

Is there any #special key that could be used for a real remote execution vulnerability, or is the risk theoretical for now? I saw various hooks for executing functions by name, like this ['foo', 'bar'] but if you can't specify arguments that's not very useful.

2

u/[deleted] Mar 29 '18

Was thinking it had to do with the #Ajax key but I was patching yesterday, not getting deep into the exploit. It's mostly a guess, not informed in any way.

2

u/judgej2 Mar 29 '18

Joomla is still a thing?!

1

u/dev10 Mar 29 '18

Unfortunately: yes it is. They did cooperate with other projects in the PHP-FIG, so it's still not as bad as WordPress.

5

u/ThePsion5 Mar 29 '18

This kind of bugs are final nails in Drupals coffin.

Yeah, sure, Drupal is right on death's door. Mmm hm.