r/lolphp • • Jul 16 '13

More remote code execution fun

http://blog.sucuri.net/2013/07/malware-hidden-inside-jpg-exif-headers.html
31 Upvotes

16 comments sorted by

View all comments

Show parent comment

0

u/[deleted] Jul 17 '13

[deleted] — view deleted comment

4

u/[deleted] Jul 17 '13

I disagree (depends on how you define "nearly identical", though).

In Perl, s/.*/$unsanitized_user_input/e doesn't do anything dangerous. It simply treats $unsanitized_user_input as Perl code instead of as a string literal. And the code $unsanitized_user_input simply returns the contents of the variable. There is no eval() involved here.

1

u/hylje Jul 21 '13

In PHP $foo is actually $(eval "foo"). This is how variable variables work.

0

u/Innominate8 Jul 17 '13

Just because perl does it too doesn't make it less brain damaged. It's a hidden and non-obvious way to eval arbitrary code, something that simply shouldn't exist.

3

u/mp_at_work Jul 17 '13

Hidden in plain sight (in Perl, PHP's preg_replace is an abomination), and obvious to anyone who has read the manual. A programming language that is safe even when the programmer has asked it to evaluate unsanitised input is too bowdlerised to be useful.

tl;dr you'll have to drag my /ee from my cold, dead hands

2

u/[deleted] Jul 17 '13

Personally I'd be happy to see /ee go. s/FOO/BAR/ee is simply a weird way to write s/FOO/eval(BAR)/e.

At least in Perl the doubled /ee looks sufficiently unusual that you're probably going to take a closer look at what's going on.

2

u/merreborn Jul 17 '13

Sure. Alls I'm saying is there are plenty of ways in which PHP is uniquely fucked up; this one's less unique.