Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I completely agree with your assessment.

I would like to add that there's probably no reason regex would even be needed for this task. str_replace() would be the more appropriate call. In ##php on Freenode we often have to tell people that you don't need to use preg_* functions if you are not using the power of regular expressions. If you don't need the power of regular expressions, you should be using str_replace() for your operation. In this case, str_replace() would be not only be more appropriate, it would have helped remove the risk of exploit.

That aside, there have been reports of people exploiting metadata in images for years with PHP and other languages. This is not new in any way.

I'm disappointed that the article seems to stress that JPEGs are somehow inherently insecure when, in fact, it should be stressing that one should always be extremely careful dealing with user-submitted input.

In this example, one could simply replace the image uploading aspect with any sort of submitted data. If you're going to be dynamically passing user input into functions of your application, you should always be certain to appropriately clean and escape those situations. Whether that data is hidden in the EXIF data on an image, is going to be put into a database, or is dynamic regex, a healthy level of distrust for all user submitted data is necessary.



> In this case, str_replace() would be not only be more appropriate, it would have helped remove the risk of exploit.

Actually, the exploit was a backdoor planted by the hacker, so the system was already compromised. The recommendation to use str_replace in this instance would be useless, as it appears the victim didn't even put the code there in the first place.


I see. I didn't read it as a back door attack but an injection attack against bad code.


The point of the post seems to be to advertise their product. The comments seem to confirm that.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: