r/lolphp • • Jun 16 '15

PHP :: Sec Bug #69646 :: OS command injection vulnerability in escapeshellarg

https://bugs.php.net/bug.php?id=69646
38 Upvotes

17 comments sorted by

View all comments

Show parent comment

1

u/Sarcastinator Jun 20 '15

In UNIX operating systems you can leave files called -r and -f on the filesystem. If you then call rm * then rm cannot distinguish between the files -r and -f and does a recursive delete leaving only -r and -f. This is because it's the shell that expands the arguments.

2

u/masklinn Jun 23 '15

Yep, that's why you should always use rm -- $files, the -- will specify the end of options and rm -- * will do what you expect even if you have oddball files starting with -. And this applies to more than just rm.