Closed CameronJung closed 2 years ago
I have a few ideas of how to do this. The one I'm thinking of right now is make a singleton in the front end that can be called by any of the services. The singleton's functions will include string searches that look for bits of html code in user input that could be used maliciously, such as "src=". If such a sequence is found than the input is rejected and the request isn't sent to the backend. I suspect this issue is more complicated than I realize so I'd like feedback on this approach.
you could use .replaceAll() and the escaped characters:
< renders as <
> renders as >
& renders as &
" renders as "
' renders as '
Though this might interfere with the spoiler tags
So should this clean input that has been determined to be malicious, and send what it's able to salvage, or should it just reject the request entirely so that nothing is sent to the back end?
Once the characters are escaped, there is no longer danger in storing whatever it is they entered. I think it should be stored to avoid a false positive rejecting someone's valid request.
Yeah that's a good point. Besides, if the sanitizer results in variable behavior that will make it more work to use.
There are three input fields I can think of that will need to be sanitized, user names, comments and reviews. Can anybody think of any others?
Apparently Vue protects against XSS attacks innately.
Cross code attacks can have devastating consequences, but defending against them isn't very complicated from my understanding.