0

I want to make a site where users can upload their own canvas animations for others to see. What are the security risk implications associated with this? Is there an easy way to assure what I'm getting are only canvas functions and not malicious code snippets? Thoughts? Thank you.

EDIT: What if I put each animation in a separate subdomain? Is there a way to automate subdomain creation whenever a user uploads?

dmoonman
  • 77
  • 1
  • 7
  • 2
    Closely related: [What are the risks of letting users upload and run Javascript](http://stackoverflow.com/questions/4932048/what-are-the-risks-of-letting-users-upload-and-run-javascript) – Pekka Apr 23 '11 at 20:12
  • 1
    Also ['Sanitising' user-submitted Javascript - so it still works!](http://stackoverflow.com/questions/3413224/sanitising-user-submitted-javascript-so-it-still-works) – Pekka Apr 23 '11 at 20:13
  • 4
    "Is there an **easy** way?" Heck no. – Matt Ball Apr 23 '11 at 20:20
  • One important thing is to run the snippets on a separate domain that has no admin access, no login forms and nothing. That will already eliminate 95% of all your headaches already. – Pekka Apr 23 '11 at 23:38

2 Answers2

0

Javascript is a language that is VERY flexible and it's nearly impossible to make sure what an actual code is executing unless you run very deep analyzis on it. If you allow Javascript to be uploaded, you can get anything and most of the protection you will try to use will not work.

In your case what you could do is allow people to upload the animation sequence in some custom language that you transform in Javascript after it's uploaded. That way you can have some better control over what is executed.

HoLyVieR
  • 10,985
  • 5
  • 42
  • 67
0

In terms of specific risks, the obvious one is the easy ability to create a persistent XSS threat. This could easily do anything from reading a users cookie's (including those used to identify their authenticated session) to rewriting the page or modifying the CSS.

It also opens a very easy door to CSRF which would potentially allow the script to post arbitrary commands on behalf of the victim. Plus there's the risk of things like clickjacking and tabnapping - the possible exploits are very extensive!

There are ways to mitigate these threats, but the very fact that you're allowing people to upload arbitrary scripts is a massive risk.

Troy Hunt
  • 20,345
  • 13
  • 96
  • 151