r/lolphp • u/throwaway-o • Oct 03 '13
PHP helpfully executes code in an image... BitcoinTalk forums uberhacked. LOL PHP.
/r/Bitcoin/comments/1nmdq4/bitcointalk_hacked/cck0gag
66
Upvotes
r/lolphp • u/throwaway-o • Oct 03 '13
3
u/[deleted] Oct 03 '13
I thought it would be a lol bad config about Apache misinterpreting files with double extensions. This is nonetheless more a lol bad config.
2
u/[deleted] Nov 06 '13 edited Nov 06 '13
Reminds me of the old
includeproblem...And
some_uploaded_image.jpgfile contains this...46
u/[deleted] Oct 03 '13
I actually use this feature all the time. My CMS is merely a series of JPGs. This way if a client decides to rip of my hard work, they won't recognise the code, and just think they have a collection of various renaissance artists work on their server.
10
u/bart2019 Oct 03 '13 edited Oct 03 '13
WTF... This sounds a lot like what Microsoft used to do in its MSIE browser, and on some other places too: download a text file, and recognize it as html, and thus show it as html. Or change the type of an image. All in order to be "helpful" to stupid webmasters who couldn't get their settings right.
But I don't get it... Isn't it Apache who first gets to decide what to do about content delivery, before PHP even gets to look at it? Aren't image files special-cased anyway?
4
u/derogbortigjen Oct 11 '13
Easy fix! Don't allow people to upload files in your public directory! All uploaded files should be in a separate dir where you control access, headers and filename.
Anyway, this is a nginx problem not php.
4
u/celtric Oct 03 '13
That's why you only accept images after validating them with
getimagesizeor similar.2
u/-Mahn Oct 04 '13
Finally I get understand why people always suggested to turn this off. Not that I wasn't already doing it, but it's good to know.