JMeter Cookie Manager not working - performance

I have been trying to get a rather simple JMeter test up and running with cookies for days and having no luck at all. I have exhausted almost all SO threads with attempts to fix this, but no luck yet.
My test is simply to POST login username/password to a server, which returns a SAML token if successful. Then I resubmit that SAML token to my replying party site, which successfully responds with cookies in the headers.
However, every subsequent request does NOT pass along these cookies.
Here is the layout of my plan:
Thread Group
HTTP Request Default
HTTP Cookie Manager
HTTP Request - GET load login page
HTTP Request - POST user/pass to remote server and store SAML token
HTTP Request - POST Submit SAML token to Relying Party site (successfully returns cookies in response)
HTTP Request - GET View protected page (always send [no cookies])
Debug Sampler
View Results Tree
Aggregate Report
I Have enabled these settings:
CookieManager.allow_variable_cookies=true
CookieManager.save.cookies=true
CookieManager.check.cookies=false
The result of the 3rd HTTP Request Sampler responds with a HTTP Response like this:
Thread Name: Visitors 1-1
Sample Start: 2015-09-29 11:53:49 AEST
Load time: 1949
Connect Time: 400
Latency: 1369
Size in bytes: 83261
Headers size in bytes: 2013
Body size in bytes: 81248
Sample Count: 1
Error Count: 0
Response code: 200
Response message: OK
Response headers:
HTTP/1.1 200 OK
Cache-Control: no-cache, no-store
Content-Type: text/html; charset=utf-8
Expires: -1
Pragma: no-cache
Content-Length: 81248
Date: Tue, 29 Sep 2015 01:53:52 GMT
Connection: keep-alive
Set-Cookie: sitecore_device=; path=/
Set-Cookie: .ASPXAUTH=CC27DB52E62EA5412220CB33ECD9BB84F4A65B76C5A46F8A5A2271AC862C8ED4C71F06258060F30EEB162EF43863B5EDBCDAE0D07002AA71D64F5A473D6FF197E2598F1ACAACB6E36D64D5B9E3B59C102851FF9B22844079BCA09326D491FE5F763E5C7A03FE89AA000600E452B5EAAA64AB83ED5D870B18F86DD213A524FB2F2DF76FECDCB302DEB51BBF39F9FAE6308111E5E084009F1DD8A82E700D8C8DD04E7015DAFFEB5F7373210019F72DF323C3CF2D02; path=/; HttpOnly
Set-Cookie: ASP.NET_SessionId=1yguqfbt5eyrvgo1agawui0z; path=/; HttpOnly
Set-Cookie: sitecore_device=; path=/
Set-Cookie: .ASPXAUTH=CC27DB52E62EA5412220CB33ECD9BB84F4A65B76C5A46F8A5A2271AC862C8ED4C71F06258060F30EEB162EF43863B5EDBCDAE0D07002AA71D64F5A473D6FF197E2598F1ACAACB6E36D64D5B9E3B59C102851FF9B22844079BCA09326D491FE5F763E5C7A03FE89AA000600E452B5EAAA64AB83ED5D870B18F86DD213A524FB2F2DF76FECDCB302DEB51BBF39F9FAE6308111E5E084009F1DD8A82E700D8C8DD04E7015DAFFEB5F7373210019F72DF323C3CF2D02; path=/; HttpOnly
Set-Cookie: ASP.NET_SessionId=1yguqfbt5eyrvgo1agawui0z; path=/; HttpOnly
Set-Cookie: rvconf=0; path=/; HttpOnly
Set-Cookie: rvre=14432509917526119; path=/; HttpOnly
HTTPSampleResult fields:
ContentType: text/html; charset=utf-8
DataEncoding: utf-8
I also realise that some cookies are being set twice from the server, but this is out of my control. I hope that this is not the issue...

Pass the cookie variable in jMeter (you can access your ASP.NET_SessionId in this manner ${COOKIE_ASP.NET_SessionId}) to pass the cookie values to the HTTP Header Manager associated with the request.
JMeter Cookie Manager

Related

How to Capture the API's ?if API's have no end points and just showing baseUrls

I need help or any suggestion. I have no idea how to do it?
Request URL: https://www.vizofly.com/NTU/Stress/StreamingAssets/Schools.json
Request Method: GET
Status Code: 200 (from disk cache)
Remote Address: 172.66.43.59:443
Referrer Policy: strict-origin-when-cross-origin
alt-svc: h3=":443"; ma=86400, h3-29=":443"; ma=86400
cf-cache-status: DYNAMIC
cf-ray: 6d4c32aacdb1926d-FRA
content-encoding: br
content-type: application/json
date: Fri, 28 Jan 2022 18:14:00 GMT
etag: W/"1261-61f2caaf-3e2d8e;;;"
expect-ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
last-modified: Thu, 27 Jan 2022 16:39:11 GMT
nel: {"success_fraction":0,"report_to":"cf-nel","max_age":604800}
report-to: {"endpoints":[{"url":"https://a.nel.cloudflare.com/report/v3?s=aVZAHndifoZtrY0MH3O1WlauF71saxbdUuS7eBS0tReoUi5fGDG3zSlxFCTvbIwJxvGeVeiQyjT%2FVIUWKfUpxNbRT1jUi%2F9VEOvJnaBBRtJKapsW8RBKeLUxqP%2FusLzYEHQ%3D"}],"group":"cf-nel","max_age":604800}
server: cloudflare
x-content-type-options: nosniff
x-frame-options: ALLOW-FROM https://www.ntu.edu.sg
If you're asking about how to configure JMeter to send the request:
Add Thread Group to your Test plan
Add HTTP Request sampler and set it up like:
You may also want to add HTTP Cache Manager to represent browser cache, HTTP Cookie Manager to automatically handle cookies and so on in order to configure JMeter to behave more like a real browser

Permanent Cookie Contains Sensitive Session Information Laravel using Appscan security tool

I have scan the Laravel Project using AppScan tool, I am facing security issue Permanent Cookie Contains Sensitive Session Information issue in AppScan Security Document.
Here is My Network information of Header:
Cache-Control: no-cache, private
Connection: keep-alive
Content-Encoding: gzip
Content-Length: 3692
Content-Type: text/html; charset=UTF-8
Date: Thu, 16 Aug 2018 06:01:02 GMT
Expires: 0
Pragma: no-cache
Server: Apache
Set-Cookie: XSRF-TOKEN=eyJpdiI6Ik9XVzJyOXRSZ0JkRnhaTXdkZlQzeVE9PSIsInZhbHVlIjoibUxEKzBLUHdCM2VwWVc4MzhPNjR3TmpcL2VZdWJXRjJmeVZklSaGtnb2RRblVBblpXNEVDS1wvMXExKzQwaE9NWlQwVFRpUTZiTHB3b1ZRMlcwZz09IiwibWFjIjoiNzhmMDg4MjUzN2YzMDA3MDg3MTJiOGNkMTQ4MTZlNWIyZWZiZTkxYjgwNzI1NzVmMzBmNWQyYjE1ZThjZDc3MiJ9; expires=Thu, 16-Aug-2018 08:01:02 GMT; Max-Age=7200; path=/; secure;HttpOnly;HttpOnly;Secure
Set-Cookie: laravel_session=eyJpdiI6InJpK3FNeHhTMGFEUUgxSGxKUkc1Rmc9PSIsInZhbHVlIjoieVRGaGpMcnJ3bnBrWCtOTzZcL2dzVFRKNDl5U29jUTlvb0tSZE54d2YxbTFvSHZ3TW5jc2FXcFwvcjhLaXlFN2R5eEo0Tlpoa1FxY0VUWlJ5bUjIjoiYTY2MjkwODU3YWQyMTFmZTJkNmZlMWUzMTgyYzk2NjA2OTBiMDgyODMzM2ZlZjg4NDE4MDBjZDFkYmIyNmEyMCJ9; expires=Thu, 16-Aug-2018 08:01:02 GMT; Max-Age=7200; path=/; secure; httponly;HttpOnly;HttpOnly;Secure
Strict-Transport-Security: max-age=31536000; includeSubDomains; preload
Vary: Accept-Encoding
X-Content-Security-Policy: allow 'self';
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
Also When i stop/ remove cookies from server side. I will block the csrf token.
How can i fix this security issue.?
Please Help!!
Thanks in Advance
I think it's a bug in the AppScan application. The message is already correct, session information is stored in the cookie. This serves to transfer this token with every request and to send back a new CSRF token afterwards.
Since the cookie has a Max-Age=7200; the cookie lives only 2 hours. Therefore, AppScan's statement that the cookie exists permanently is false.
And remember, with each request a new CSRF-Token is assigned to you, whereby the attacker would have to manipulate your locally sent request to be able to use this method.

How to debug "Response Code 500 Internal server error" in J-Meter 4.0?

I am getting "Response code 500 - Internal Server Error" for a performance test run in Apache J-Meter 4.0 for a recording of a simple test done over VPN. I am new to this tool and want to know how I can investigate this. As reference, I am mentioning the sampler result error that I am getting.
Sampler Result:
Thread Name: Thread Group 1-1
Sample Start: 2018-06-11 13:21:56 IST
Load time: 1941
Connect Time: 1700
Latency: 1941
Size in bytes: 2301
Sent bytes:2145
Headers size in bytes: 594
Body size in bytes: 1707
Sample Count: 1
Error Count: 1
Data type ("text"|"bin"|""): text
Response code: 500
Response message: Internal Server Error
Response headers:
HTTP/1.1 500 Internal Server Error
Date: Mon, 11 Jun 2018 07:51:58 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 1707
Connection: keep-alive
Set-Cookie: AWSALB=ZS1nnfJyJ+Wk5NEu/FmWGmiRWfEQPnfiywAN8b8f8De6AjOYDrh0nWRVVcsQeBanayjPnpp1IxhjK34EipQB4m/lsAZgdKJ4mgUDDS+Yep8atzWucMNdYTw0oIdB; Expires=Mon, 18 Jun 2018 07:51:58 GMT; Path=/
Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept
Access-Control-Allow-Origin: *
Content-Security-Policy: default-src 'self'
Vary: X-HTTP-Method-Override
X-Content-Type-Options: nosniff
X-Powered-By: Express
HTTPSampleResult fields:
ContentType: text/html; charset=utf-8
DataEncoding: utf-8
In the majority of cases you will not be able to successfully replay recorded scenario without modifications.
Add HTTP Cookie Manager to your test plan
Detect all dynamic parameters and perform correlation
Also looking into AWSALB cookie my expectation is that your application under test "hides" behind Amazon Elastic Load Balancer so make sure to add DNS Cache Manager to your Test Plan.
If you still experience problems you can try catching the requests which is being sent by JMeter and by the real browser using a sniffer tool like Wireshark or Fiddler - the requests should be exactly the same (apart from dynamic parameters mentioned in point 2).

JMETER 403 when uploading a file but needs to be logged in

So I am trying to test the file upload function of this website: http://the-v.net/en/vtube/upload-video through JMETER but to be successful, the user has to be logged in through this form: http://the-v.net/login, Now, I think this is a parameter-based authentication which could be solved by defining a valid username and password in the HTTP Authorization Manager config element, but even doing so I keep getting this error:
Thread Name: Thread Group 1-1
Sample Start: 2018-01-30 20:11:06 CST
Load time: 1373
Connect Time: 214
Latency: 1167
Size in bytes: 19151
Sent bytes:134
Headers size in bytes: 768
Body size in bytes: 18383
Sample Count: 1
Error Count: 1
Data type ("text"|"bin"|""): text
Response code: 403
Response message: Forbidden
Response headers:
HTTP/1.1 403 Forbidden
Date: Tue, 30 Jan 2018 12:11:06 GMT
Server: Apache/2.4.23 (Win64) PHP/5.6.25
X-Powered-By: PHP/5.6.25
X-Drupal-Cache: MISS
Expires: Sun, 19 Nov 1978 05:00:00 GMT
Cache-Control: public, max-age=900
X-Content-Type-Options: nosniff
Content-Language: en
X-Frame-Options: SAMEORIGIN
X-Generator: Drupal 7 (http://drupal.org)
Link: <http://the-v.net/en/vtube/warning>; rel="canonical",<http://the-v.net/en/vtube/warning>; rel="shortlink",<http://the-v.net/sites/all/themes/vtube17/favicon.png>; rel="shortcut icon"
Etag: "1517314266-0"
Last-Modified: Tue, 30 Jan 2018 12:11:06 GMT
Vary: Cookie,Accept-Encoding
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/html; charset=utf-8
HTTPSampleResult fields:
ContentType: text/html; charset=utf-8
DataEncoding: utf-8
Any idea on how can I solve this? Thanks
I would suggest you record the upload in the browser and look in View Results Tree the headers/ coookies that are transmitted.
You can use File > Template. > Recording
Read:
http://jmeter.apache.org/usermanual/jmeter_proxy_step_by_step.html
You are most probably missing:
A header
A cookie
A parameter
You need to be logged in in order to be able to upload anything. HTTP Authorization Manager won't help as it is designed to deal with protocol level authentication and you need cookie-based one.
Add HTTP Cookie Manager to your Test Plan
Pay attention to form_build_id dynamic parameter you need to pass along with credentials during login request
So your test plan should look like:
1st HTTP Request - open login page
Post-Processor (i.e. CSS/JQuery Extractor to fetch form_build_id
2nd HTTP Request - perform login - provide credentials and the form_build_id from the previous step. You will also need to pass form_id parameter with the value of MYFORM_form
3rd HTTP Request - perform the upload.

Unauthorized CSRF validation failed in jMeter testing

I'm new to jMeter testing. I want to test the field update on UI. So When I run my test I'm getting the CSRF validation error. How can I resolve this. My test plan looks as,
And the sampler result is as follows,
Thread Name: Thread Group 1-1
Sample Start: 2014-11-18 23:37:49 IST
Load time: 688
Latency: 688
Size in bytes: 483
Headers size in bytes: 457
Body size in bytes: 26
Sample Count: 1
Error Count: 1
Response code: 401
Response message: Unauthorized : CSRF validation failed
Response headers:
HTTP/1.1 401 Unauthorized : CSRF validation failed
Date: Tue, 18 Nov 2014 18:08:07 GMT
Server: Apache/2.4.7 (Ubuntu)
X-Powered-By: PHP/5.5.9-1ubuntu4.5
Expires: Sun, 19 Nov 1978 05:00:00 GMT
Last-Modified: Tue, 18 Nov 2014 18:08:07 +0000
Cache-Control: no-cache, must-revalidate, post-check=0, pre-check=0
ETag: "1416334087"
Vary: Accept
Content-Length: 26
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: application/json
Why do we get CSRF validation error and how to resolve it.
CSRF stands for Cross-site request forgery and you're getting CSRF Validation error due to missing mandatory dynamic request parameter, usually a Cookie or a Header.
I would suggest executing your scenario in i.e. Firefox Browser with HttpFox or FireBug extension enabled and inspect request details. CSRF token usually comes as a cookie in server's response and needs to be passed as a header or request parameter. So it is similar to usual correlation. So the flow should look as follows:
First HTTP Request: open first page
Extract CSRF token from response via one of the following Post Processors
Regular Expression Extractor
XPath Extractor
CSS/JQuery Extractor
Second HTTP Request: open second page (CSRF-protected). Add the token, extracted in step 2 to one of the following:
HTTP Request Parameter
HTTP Header Manager
HTTP Cookie Manager
Depending on where your server expects the token to live.
For the future, looking at your "localhost" server name - don't run JMeter performance tests on the same machine where application lives.

Resources