I'm looking at some basic PHP code that takes a string from POST data via an ajax call. The POST data is used to directly instantiate a class whose name is equivalent to the value of the POSTed string. Assuming that all the class autoloader does is throw an error or an exception if it can't find a class, what harm could a malicious user inflict here?
POSTing a standard PHP class name that requires parameters, or POSTing 'stdClass' wouldn't do much other than prevent a return view. Beyond that, what could be possible? Furthermore, what would be the best way to validate and to still be flexible when new view classes are added.
require_once('autoloader.php');
if(!empty($_POST['viewRequst'])){
try{
$requestedView = $_POST['viewRequest'];
$view = new $requestedView();
$view->outputPage();
}catch(Exception $e){
/**
Perform Some Logging
**/
}
}else{
echo "Data Error";
}