There are quite a few technologies these days for countering XSS like content security policy headers, template escaping, contextual escaping in templates, etc.
With a content security policy, you can restrict scripts so that only external files served from the same domain will be allowed to run and anything else, including inline scripts will be killed off. You can also pass a number of hashes in headers, so that only scripts which match specific hashes will run, this might be useful if you're loading a script off a third party CDN.
There are also nonces where you generate a random string and the one in the script tag has to match the one in the header for a particular script to run.
With contextual escaping, the template system is aware of whether it's in a JS block, etc. and will apply the appropriate escaping rather than blindly doing entity escapes intended for HTML or other silliness. This is fairly common in more modern languages these days.
There are plenty of old legacy systems which will always be affected, but could it be that the dreaded XSS will vanish from the world?
With a content security policy, you can restrict scripts so that only external files served from the same domain will be allowed to run and anything else, including inline scripts will be killed off. You can also pass a number of hashes in headers, so that only scripts which match specific hashes will run, this might be useful if you're loading a script off a third party CDN.
There are also nonces where you generate a random string and the one in the script tag has to match the one in the header for a particular script to run.
With contextual escaping, the template system is aware of whether it's in a JS block, etc. and will apply the appropriate escaping rather than blindly doing entity escapes intended for HTML or other silliness. This is fairly common in more modern languages these days.
There are plenty of old legacy systems which will always be affected, but could it be that the dreaded XSS will vanish from the world?







