Hi folks,
I plan on having an aspect of my site where the users can submit HTML, CSS, and JS, which is then generated 'live' into full working pages of HTML. Other users will be able to see this. These pages need to have working Javascript on them.
I understand that's a pretty major security flaw in itself, but it's very important this feature is on the site. I had these ideas:
- No external Javascript files can be linked to
- jQuery etc. can be included, but only from a trusted CDN (e.g. Google)
- Certain Javascript functions will be disabled and removed (e.g.
eval()
) - Users cannot submit live demo code until they have earnt a certain amount of 'reputation'
- User-submitted live demo code must be authorised by an administrator before it goes live
- No minified code may be used
And passive security measures:
- Disclaimer, so we're not held responsible! ;)
- 'Report' buttons in case a user finds something dodgy
So here's the question: What do you think of this, as a security plan? Will these measures combined be enough to stop attackers? Users will be submitting their code in three seperate inputs - CSS, HTML, and JS - so I will be able to filter and sanitise accordingly, then restructure it 'live' for others to preview.
Thanks!
Jack