Hi HN,<p>I'm developing a multiplayer, physics-based simulation game each player has to provide the code for an agent whose goal is to survive in the given environment and eventually reproduce to ensure its survival. The simulation is shared among all players and runs on the server, written in Java, while it is streamed to a web front-end (looks like this https://imgur.com/a/ZBl6SAu).<p>For these reasons, I need to accept code from users that has to be run in the same process as the one running the simulation. The code is not completely arbitrary:<p>* The user has to define a well-specified set of methods like update (what to do at every simulation step), beginContact (what to do when colliding with another object), etc...
* I want to only allow access to a limited set of Java features; I've read that a SecurityManager can be used to only allow access to a subset of packages, but I'm not sure if this is compatible with running in the same process.<p>Is there a way to do this safely? There are a lot of exploits that I'm not sure it's possible and I'd like to hear opinions on how to eventually set this up.