I have some JavaScript which retrieves a user-submitted querystring value, sets a hidden field’s VALUE to the parameter, then posts the form automatically.
This is all done on page load. Is there any potential for XSS?
<script>
function autoSubmit(){
var url = ... /* retrieve URL from querystring parameter */
document.getElementById("txt").value = url;
document.getElementById("myform").submit();
}
</script>
<!-- ...... --->
<body onload="autoSubmit()">
<form id="myform" name="myform" method="POST" action="http://www.mysite.com/someform.php">
<input id="txt" name="txt" type="hidden" value="" />
</form>
</body>
No. You are not executing remote code anywhere and you aren’t allowing users to enter their own Markup.
But are you sure you are concerned about XSS?
The site is likely vulnerable to some form of XSRF for the usual XSRF Reasons:
More in depth anaylsis would require looking at your someform.php