Hi all,
I've reading some books on advanced PHP, and most of the time I find code like this:
$classes = array ("MyClass1", "MyClass2");
if (!in_array ($_GET['class'], $classes))
throw new Exception ("Class not found!");
$params = $_GET;
$obj = new $_GET['class'];
if (!method_exists ($_GET['method'], $obj)
throw new Exception ("Method not found!");
echo $obj->{$_GET['method']}();
On the book where I find this code, the author always mentions that this code is not secure for production environments, and the class name should be checked.
My question is, if the class name is being checked it's existence in a array (I added this, it wasn't in the book examples), what security considerations should I take more? The class name will bot be outputted so XSS filtering doesn't make much sense. Also the class name will not hit the database, so SQL injection filtering it's not needed.
Thanks in advance for all your answers.