getting "/auth Invalid session state: stored %!s(<nil>), returned ..." only when testing is false and only for a specific single user
Describe the problem
We at Help Systems have deployed an internal web app in a docker-compose on an AWS EC2 VM.
It has 2 nginx reverse proxies, the first for signing in with Vouch-Proxy, and the second for more elaborate Access-Control via the Web Application's Backend and it's database.
Every so often a specific User has issues when attempting to access the Web App; getting "stuck" at the /auth endpoint after successfully singing in to Google or even if signed in to Google in another tab of his browser.
In the logs we see "auth Invalid session state: stored %!s(
In the past, this problem was solvable via the following steps:
- navigating to the /logout endpoint
- deleting all cookies for the internal web app's domain (as it could just be a stale cookie not being overridden)
- navigating to a known UI endpoint in the app, possibly signing in via Google in the process.
- problem solved.
This time this did not work, indeed, even though we could see the Session cookie (but could not decrypt it as we let Vouch set it randomly on startup) and it's path matched the path "stuck" on, Vouch would not be able to read the cookie.
Please Note: On reloading the Docker-Compose for turning on testing mode, the problem disappeared as if it had not happened at all.
Expected behavior Constant, easy, effortless access to the deployment via Google Open-ID Connect, once signed in to Google, for all users.
Desktop:
- OS: [e.g. iOS] Linux Mint 20 Cinnamon
- Browser [e.g. chrome, safari] Google Chrome Version 94.0.4606.61 (Official Build) (64-bit)
Smartphone: Due to a VPN-like solution, it is not possible to access the deployment from a smartphone.
Use a Paste Service Vouch config, docker-compose.yml, nginx configurations and docker-logs-with-testing-on
first-docker-logs-with-the-error-state-for-only-one-user Fair warning: this text file is over 150MB in size!
OAuth provider: Google
@shlomo-kallner-HS it looks like you're passing quite a few claims. That will make the cookie large and you'll need to open up the Nginx buffers. Could you please consult the README for the Nginx settings, adjust your config and then see if that solves your problem?
https://github.com/vouch/vouch-proxy#scopes-and-claims
@bnfinet I thought I did that when i set it up. I have in both vouch-nginx.conf and app-nginx.conf the following block:
## see: http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_buffer_size
## and see: https://github.com/laravel/valet/issues/290#issuecomment-398686133
## but ignore the fastcgi stuff (we are not using that!)
## default: `proxy_buffer_size 4k|8k;`
proxy_buffer_size 4096k;
proxy_buffers 128 4096k;
proxy_busy_buffers_size 4096k;
proxy_buffering on;
that's buffers of 4MB! Do you think I need to expand them to 16MB?
@bnfinet Also, Please Note: this problem disappears on reload/restart of Vouch-Proxy, via reloading (down && up) the docker-compose.yml! And once we turned on "testing" mode the problem again disappears! Only to reappear sporadically while the "testing" Mode is once again turned off.
Sorry to have missed the nginx config in my initial view. When you changed it to 16M what happened? What else have you tried?
@shlomo-kallner-HS could you provide a smaller log file as a gist which only includes VP. A smaller log which shows the startup and then the problems for this user with /auth would be helpful. Anything that makes it easy to hone in on the problem while being able to reference line numbers and without downloading documents to my machine would be appreciated.
I'm not sure why restarting VP or why testing: true would solve the problem. Are there other cookies being set into the same domain?
You mention a "VPN like solution". What is that?
- The vpn solution is ananda a kind of VLAN on top of vpn for businesses to use to work remotely. (PS. they only just now released a beta for Android smartphones, so my previous assertion of smartphone access being irrelevant is still applicable.)
- I updated the gist to include a file called
dumpDoorKeeperVoucherLogs1-with-doorkeeper-removed5.txtwhich is a skimmed down version of the original log with the error state with the nginx instance's logs and many of the successful healthcecks removed and the rest cut down to under 1k lines. I hope this helps. - re. additional cookies, yes, the backend sets an additional session cookie of it's own. possibly the other GUI serving services (Grafana, for instance) might also set a few as well.
- I will update after checking the new nginx configuration.
@shlomo-kallner-HS could you please upgrade to the latest VP v0.34.1 and submit new logs. There are some changes to vouch-in-a-path which might be at play here.
even though vouch is not deployed on a subpath?
yes please
@bnfinet new gist with the new output: https://gist.github.com/shlomo-kallner-HS/60fcdc66ea7540b087589855c8ca4b26 Please note: the Issue pops up again in one of theses logs, but it was because I restarted my browsing session and forgot to click through the testing pages; AKA a timeout of the Cookie's lifetime, I think.
NOTE: of the Nginx Configuration, I ONLY pasted the modified section of the proxy buffers.
@shlomo-kallner-HS Thank you for upgrading to v0.34.1
VP appears to be behaving normally.
What did you find for the size of all the cookies in the domain?
In looking at this
https://gist.github.com/shlomo-kallner-HS/60fcdc66ea7540b087589855c8ca4b26#file-dumplogs1-txt-L774-L825
I notice multiple calls to /auth/5k8QGMMwvgrbcWjf8IC2ufcmDg6fjAA Why would that occur?
Is VP is running on a separate domain? The VP config implies that vouch.yourdomain.com/auth is an accessible callback URL. Is that accurate?
https://gist.github.com/shlomo-kallner-HS/5e7fe106bba67a1370dcd9f0529a92b4#file-vouch-nginx-conf-L45
Try not setting vouch.cookie.domain. Try using that setting for a single entry for vouch.domains and then just use vouch.yourdomain.com/auth for your callback URL...
https://gist.github.com/shlomo-kallner-HS/5e7fe106bba67a1370dcd9f0529a92b4#file-config-yml-L252
In general, VP is pretty close to stateless, so the notion that any restart on the server would change behavior seems highly unusual.
In general, could you please try to post less logs, just vital info for startup, the failing validate call (401) /login, auth. No need to include the nginx /flower calls and /healthcheck. If I need more info or if there's something missing I'll be sure to ask. :)
- multiple calls to
/auth/5k8QGMMwvgrbcWjf8IC2ufcmDg6fjAA- I think I tried to reload the page before realizing that my Cookies Timed-out.. - Is VP is running on a separate domain? No. Unfortunately the config is not accurate in this regard; I was trying to cover all the bases given the documentation for setting VP up.
- re: size of the cookies, I have not checked yet.
Hi,
Any update of the issue. I have experienced the same error. with vouch-proxy + okta with external idp, vouch service running in subdomain, and we are using kubenetes infrastructure to host voucher/vouch-proxy container with testing mode false. It only happens on one specific user which is quite weird:
{"level":"debug","ts":1634171274.0567384,"msg":"/auth"}
{"level":"debug","ts":1634171274.0567799,"msg":"CaptureWriter.Write set w.StatusCode 302"}
{"level":"info","ts":1634171274.0568757,"msg":"|302| 77.612µs /auth","statusCode":302,"request":50347,"latency":0.000077612,"avgLatency":0.0012633,"ipPort":"xxx.xxx.xxx.xxx:60494","method":"GET","host":"vouch-dev.rootdomain.com","path":"/auth","referer":"https://okta-audience/"}
{"level":"debug","ts":1634171274.0867429,"msg":"/auth/{state}/"}
{"level":"error","ts":1634171274.08678,"msg":"/auth Invalid session state: stored %!s(<nil>), returned ecu7lusvRbatQiWOeOhn1GezTeAw7w2P"}
{"level":"debug","ts":1634171274.0867863,"msg":"setting the cookie domain to arwinenvironments.com"}
{"level":"debug","ts":1634171274.0867996,"msg":"rendering error for user: 400 Bad Request"}
{"level":"debug","ts":1634171274.0868053,"msg":"CaptureWriter.Write set w.StatusCode 400"}
{"level":"info","ts":1634171274.0869374,"msg":"|400| 104.665µs /auth/ecu7lusvRbatQiWOeOhn1GezTeAw7w2P/","statusCode":400,"request":50348,"latency":0.000104665,"avgLatency":0.001263277,"ipPort":"xxx.xxx.xxx.xxx:60494","method":"GET","host":"vouch-dev.rootdomain.com","path":"/auth/ecu7lusvRbatQiWOeOhn1GezTeAw7w2P/","referer":"https://okta-audience/"}
{"level":"debug","ts":1634171426.029606,"msg":"/auth"}
{"level":"debug","ts":1634171426.0296469,"msg":"CaptureWriter.Write set w.StatusCode 302"}
{"level":"info","ts":1634171426.0297692,"msg":"|302| 76.242µs /auth","statusCode":302,"request":50349,"latency":0.000076242,"avgLatency":0.001263254,"ipPort":"xxx.xxx.xxx.xxx:33268","method":"GET","host":"vouch-dev.rootdomain.com","path":"/auth","referer":"https://okta-audience/"}
{"level":"debug","ts":1634171426.054557,"msg":"/auth/{state}/"}
{"level":"error","ts":1634171426.0545976,"msg":"/auth Invalid session state: stored %!s(<nil>), returned nVL0RIxHEQALtFb3kCE9TpLnFQZ2dC"}
{"level":"debug","ts":1634171426.0546043,"msg":"setting the cookie domain to arwinenvironments.com"}
{"level":"debug","ts":1634171426.0546207,"msg":"rendering error for user: 400 Bad Request"}
{"level":"debug","ts":1634171426.0546255,"msg":"CaptureWriter.Write set w.StatusCode 400"}
{"level":"info","ts":1634171426.054766,"msg":"|400| 114.739µs /auth/nVL0RIxHEQALtFb3kCE9TpLnFQZ2dC/","statusCode":400,"request":50350,"latency":0.000114739,"avgLatency":0.001263232,"ipPort":"xxx.xxx.xxx.xxx:33268","method":"GET","host":"vouch-dev.rootdomain.com","path":"/auth/nVL0RIxHEQALtFb3kCE9TpLnFQZ2dC/","referer":"https://okta-audience/"}
Thanks,
@bohui I need more data
@bohui please upload your logs and confs as per the README
how big are your headers and cookies for the domain?
hi @bnfinet
Thanks very much for your swift reply. The relevant logs is just attached above. Sorry I just came across this issue and didn't follow the readme requirements to submit an reply. I will try with testing: true. And I will try to get client side cookie size for that failed user, which I don't have right now. For a normal and successful login, vouchsession cookies size is 456 byte and vouchCookie is 2.5k. Hope that can be helpful.
Here is our setting:
cookie:
name: VouchCookie
domain: rootdomain.com
secure: false
maxAge: 480
sameSite: lax
session:
name: VouchSession
headers:
jwt: X-Vouch-Token # VOUCH_HEADERS_JWT
querystring: access_token # VOUCH_HEADERS_QUERYSTRING
redirect: X-Vouch-Requested-URI # VOUCH_HEADERS_REDIRECT
claims:
- sub
- name
- email
- email_verified
- groups
- given_name
idtoken: X-Vouch-IdP-IdToken
accesstoken: X-Vouch-IdP-AccessToken
Thanks for your help!
@bohui ...
The relevant logs is just attached above.
feel free to ping me again when you've got your conf and logs in a gist as per the README.
@bohui @shlomo-kallner-HS I'm going to close this issue due to inactivity. If you care to continue working the issue please do let me know and please do offer the information as requested.