php - dynamic xsrf with javascript -


i'm wondering if it's possible xsrf-attack this:

<form ...> <input type="hidden" name="token" value="xsrf-generated-token" /> ... fields+submit button ... </form> 

using javascript - like:

  • attacker gets me site
  • then calls javascript /admin/users/test/edit
  • he parses xsrf token (using regexes - dom wouldn't work because of same-origin-policy)
  • and send signed edit...

shouldn't /admin/users/test/edit signed token well?

the reason normal ajax requests (using xhr) limited the same origin policy. means in order work, you'd first need exploit xss vulnerability before execute csrf vulnerability.

now, may appear jsonp might way around that. it's not. since jsonp uses script tags, result of request fed right in. , since result html , not js, syntax error should thrown.

so there should no way ever token without first compromising site itself. 2 things should noted depends upon:

  1. all browsers correctly implement same origin policy protection

  2. you're not passing token form via json (for if were, jsonp able read it).


Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -