Apache Jmeter - The CSRF tokens do not match -


i have recorded basic apache jmeter scenario html login form uses csrf tokens.

sample token recorded application looks follows:

<input id="csrf_token" name="csrf_token" type="hidden" value="iju5nzbhmmi3odnjzgvjmguwymi2ytu4zjrkmtk0mji0mtg3otjlndai.c8ecsa.pkvdb0am2m0rfhslcb_ktyeinfs"> 

using apache jmeter post processor (regex) extracting value following expression:

input id="csrf_token" name="csrf_token" type="hidden" value="(.+?)" 

result success , value assigned csrf_value variable.

in next step sending token login information website, post data looks follows:

username=username&password=password&csrf_token=iju5nzbhmmi3odnjzgvjmguwymi2ytu4zjrkmtk0mji0mtg3otjlndai.c8ecsa.pkvdb0am2m0rfhslcb_ktyeinfs&submit=zaloguj+si%c4%99 

however website returns error csrf tokens not match. thing changed between recorded scenario , modified extraction , placing csrf token in follow request. every time replay scenario check results , show csrf token received == csrf token sent. login fails same error - csrf tokens not match.

so far can't wrong, simple scenario , yet there problem. using apache jmeter 3.1.

i recommend checking other request body parts, i.e.

  • your application may expect csrf token in request header, in case need add http header manager send relevant header
  • your application may expect cookie csrf token value. in case need handle using http cookie manager
  • it might problem html encoding , decoding, i.e. extracted token value may have characters due escaping entities not allowed in html. in case need use jmeter functions __unescapehtml() normalize token value

carefully inspect requests , responses using developer tools in browser , jmeter's view results tree listener, reason listed above.

just in case check out how load test csrf-protected web sites guide.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -