PHP lets you instantiate classes from variables or array entries, like this:
class Foo {}
$className = 'Foo';
new $className();
$someArray = ['class_name' => 'Foo'];
new $someArray['class_name']();
Distressingly, some of my coworkers - on multiple projects I've worked on at multiple companies - have used this language feature with class names supplied from user input as a way of instantiating one of several possible subclasses depending upon a type specified in the request. I've seen code along these lines...
new $_GET['product_type']($_GET['product_id']);
This, besides being a maintenance headache, is obviously stupid and dangerous; you're letting an attacker instantiate an arbitrary class. But how dangerous? What attacks are there that just use built-in PHP classes (and therefore require no detailed knowledge of the application code) that could be used against endpoints like the one above?
I'm looking for the nastiest attack anyone can come up with that I can use to scare any future coworkers who use this horrible anti-pattern.