security - What bad things can a user do in a browser without the script tag? -
I have an entry form where the user can type in arbitrary HTML, except for the script tag, what I need to filter is? Here's what I do:
userInput.replace (/ & lt; (script) / GI, "& amp; $ 1"); but manages a white list of tags (used here at SO), and filters all other tags (spaces). Why?
I do not like white lists because I do not want to stop the user from entering the arbitrary tag, if he chooses; But I can use a more comprehensive blacklist in addition to 'script', what if I need to do as a black list?
short answer: they can do anything with Script tag Javascript does not require a script tag, the script can be placed in the almost every HTML tag script in many places the script tag Can appear in addition to the src and href attribute, and style attribute used for the URL. The ability to put unwanted scripts in a user on their page is a security vulnerability known as. Read around and read this topic.
You do not want users to add HTML to your pages. If you need this feature, consider other formats like Markdown that allow you to disable the use of any embedded HTML; Or using some other less secure option is to use a filtering library that attempts to remove all the scripts, such as HTMLPurifier, if you choose the filtering option, subscribe to the announcements of the new release and always use the new projects Go back to your project and work around to install a bug-fixed release of filters.
Comments
Post a Comment