Consider the following PHP script (it could be any other language; I chose PHP for simplicity):
<?php
echo $_SERVER['HTTP_REFERER'];
?>
Is it vulnerable to XSS?
Of course I can send a request to the script using curl and set referer to something like <script>alert(document.cookie)</script>
. However, at least some browsers seem to encode referer, so if I for example redirect users to that script from the following URL:
http://example.com/<script>alert(document.cookie)</script>
the browser encodes referer and in result the PHP script outputs this:
http://example.com/%3Cscript%3Ealert(document.cookie)%3C/script%3E
Are there any browsers that doesn't encode referer? If not, can it be exploited in any other way?