Reputation: 12438
We have a website that allows users to upload their own JavaScript which gets loaded with the site's pages. Problem is if user adds a malicious script (eg. keylogger). Can anyone give any idea(s) on how to handle this?
Upvotes: 4
Views: 235
Reputation: 6629
Wow, you are creating an attacker's playground! If you let the user (attacker) upload his own JavaScript, then there are so many malicious things he can do.
I disagree with the people who are talking about scanning the JavaScript for viruses. Anti-virus software searches for known bad signatures in software and mainly targets malicious software that has affected a large number of people. Remember: each signature that an anti-virus software checks against was the result of many man hours worth of analysis of a known threat. It does not detect zero-day threats! When you let a user write his own JavaScript, he is not limited to these known bad signatures. He can do whatever he wants, and there is no way that anti-virus software can tell if what is happening is malicious or intended by business logic.
Let's start to illustrate some concerns if you allow a user (= attacker) to upload his own JavaScript:
If you want, you can play the cat-and-mouse game: you propose a way to prevent the issues I mention above, then I tell you how the attacker can bypass it, then you alter your solution, then I alter my attack, and so on. You might be able to prevent some things, but you won't be able to prevent all of the attacks. Security is hard!
Bottom line: don't do it!
Upvotes: 2