Is there a way to somehow sandbox user-generated content? I'm working on webapp which will contain a lot of user-generated content. Only "trusted" users will be able to publish the content, but I want to make sure nothing will go wrong if someone compromises their account. They will be able to upload all kinds of files (except binary executables), all of them will be served directly (e.g. PHP file won't be executed).
Considering the worst-case scenario - someone compromises user's account and uploads malicious HTML file with script, which is e.g. stealing cookies or doing AJAX calls, what's the best way to handle this?
Is it sufficient to move the content to subdomain, like https://usercontent.webappdomain.com
Are there any better ways of preventing these issues?