/admin returns 422 on login #2448
Replies: 26 comments 20 replies
-
I can't see that paste , i need to login before i can see it it looks like. Have you tried to see what happens if you take cloudflare out of the equation? |
Beta Was this translation helpful? Give feedback.
-
You can login with any account, it's just that And no, taking cloudflare out of the equation is not an option I will even consider. Seeing as our webserver isn't actually exposed to the internet whatsoever with our current setup, it'd require quite a bit of configuration reworking. |
Beta Was this translation helpful? Give feedback.
-
That is not what i asked. I asked what happens if you bypass it. I guess that you as the admin would be able to do that. The thing is, there is something send to Vaultwarden which is not understood. And the thing in between is cloudflare, and that could be an issue. |
Beta Was this translation helpful? Give feedback.
-
Let me rephrase again Our setup would have to be almost ENTIRELY reworked to allow us to take cloudflare out of the equation. Even for an admin. As it stands now, the firewall doesn't allow non cloudflare connections, nginx is only listening on localhost, and all web requests have to come through cloudflare tunnel. This would also require us to issue a valid SSL certificate on the servers, as the only certificate installed is the cloudflare origin certificate which is only trusted by cloudflare, and require us to even temporarily expose our servers to the internet. |
Beta Was this translation helpful? Give feedback.
-
Then we would need to see the actual http request coming in into Vaultwarden. Either via a tcpdump/wireshark or by enabling trace logging. Also double check then nginx config compared with the examples in the wiki. |
Beta Was this translation helpful? Give feedback.
-
There is no magic bypass button in our case. It would be really helpful if logs told us why the request isn't processable. |
Beta Was this translation helpful? Give feedback.
-
Is trace logging referring to setting |
Beta Was this translation helpful? Give feedback.
-
That is done by the webserver library (Rocket), which you can trigger to be a bit more verbose by setting logging to trace. |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
You could use an ssh tunnel maybe or ssh socks proxy to connect to it. There probably is a way to connect to it without even nginx in front of it. |
Beta Was this translation helpful? Give feedback.
-
The only one on the pastebinit list that works and isn't private by default |
Beta Was this translation helpful? Give feedback.
-
Ssh also goes through cloudflare, through their zero trust solution. Nonetheless logs with the logging level set to trace are above, albeit with a few extra ASCII color codes in the mix. |
Beta Was this translation helpful? Give feedback.
-
Please check your nginx config. It looks like it is sending a header to do an upgrade which isn't right. Also, try if you can filter the cf-* headers in nginx so that they do not pas on to Vaultwarden. |
Beta Was this translation helpful? Give feedback.
-
Then it still is ssh. Not sure if it then supports socks5 proxy or port tunneling. But if that is the case you could use that to bypass cloudflare. |
Beta Was this translation helpful? Give feedback.
-
The only Upgrade headers i see (CTRL-F'ing the log) are browser headers. NGINX only attempts the connection over http1.1 and http, and up until it hits cloudflare http2/3 doesn't even come into play. |
Beta Was this translation helpful? Give feedback.
-
http1.1 supports upgrade. |
Beta Was this translation helpful? Give feedback.
-
Okay, the only place upgrade headers are set is And the config is originally copy-pasted from the wiki. The only modifications are to work with cloudflare tunnel and cloudflare's origin cert, plus CSP, Access-Control-*, referrer-policy, and x-content-type-options. |
Beta Was this translation helpful? Give feedback.
-
Just for giggles, I recopied the config since it was a while ago when we initially set this up, only changing the listen, ssl, and adding one location directive for internal use, and still same result. We're shooting in the dark here, because the logs even at higher levels, don't say what isn't processable. Just that something isn't. |
Beta Was this translation helpful? Give feedback.
-
Well, a 422 is mostly because something is malformed. That could be headers, or the request body. For example, no correct new lines after headers or weird characters in the headers or body. But, most of the time it is malformed body, so incorrect json for example. It could even be charset issues, or something which should be an integer and suddenly is a string, or the other way around. It could even be a simple thing as a difference between lower or uppercase characters if that is changed somewhere in between. And that is why i asked to try and remove cloudflare from the equations to rule that out, since cloudflare is known to do some transformations sometimes with requests. I can take a closer look in the morning if i can find anything more specific in the posted logs. |
Beta Was this translation helpful? Give feedback.
-
@androidacybot , I'm looking at it right now. |
Beta Was this translation helpful? Give feedback.
-
Well, it looks like the client you are using, or CloudFlare is doing something to let your browser redirect using a I see the And that is what is causing the issues, since Vaultwarden expect that there is a This is not something wrong on the Vaultwarden side, since Vaultwarden (and the Rocket library) is very strict in what they receive and verify the contents, if it doesn't matched what is programmed it will disallow the request. |
Beta Was this translation helpful? Give feedback.
-
@BlackDex which I suppose is why it worked PERFECTLY FINE before I suppose. Sorry to bother you. Obviously the only solution you are willing to pursue is 'taking cloudflare out of the equation". |
Beta Was this translation helpful? Give feedback.
-
@androidacybot, I'm sorry you feel that way. I did an investigation of the trace logs you send, i put time and effort in it, and i gave you my conclusion that it looks like your browser, or something in between is not responding correctly to the I do not say that you need to take it out by default, but i say that you should see what happens. That is something totally different. For me it feels like you think this could only be an error on the Vaultwarden side, which could have been an option, but looking at the logs, it just isn't. I can't change the outcome of that, it just is what the logs show. |
Beta Was this translation helpful? Give feedback.
-
@BlackDex by any chance does Vaultwarden try to redirect http to https on it's own? Asking because the last time this was an issue the service behind nginx was trying to redirect http to https because up until nginx the request is done over https, but nginx to the backend service is http (it's a local connection at that point so it doesn't hurt anything) |
Beta Was this translation helpful? Give feedback.
-
Okay, I confirmed a suspicion but I'm no closer to solving. It has to do with an interesting interaction with Cloudflare Workers. Everything BUT 303 is being handled correctly - we bypass requests if the method is not GET and response type is not text/html. For some reason, the 303 is being followed by the worker itself - and never getting sent to the client. The interesting part is the worker is not correctly transitioning from POST to GET. One workaround on VW's side would be to use a 302 - that seems to be handled correctly, and WordPress uses a 302 in much the same way (login page -> POST to login page -> 302 to final destination, with appropriate cookies now in place). Otherwise i'll try to get in touch with cloudflare to see why this is happening, and update you if we find out anything. |
Beta Was this translation helpful? Give feedback.
-
@androidacy-user I have created a PR which should probably solve your issue reported here. I think this should fix the issues you had regarding this. |
Beta Was this translation helpful? Give feedback.
-
Subject of the issue
Admin dashboard returns 422
Deployment environment
Install method: docker-compose
Clients used: browser
Reverse proxy and version: Nginx 1.21.0, behind cloudflare tunnel (previously known as argo tunnel) which is behind cloudflare itself
MySQL/MariaDB or PostgreSQL version: n/a
Other relevant details: IP_HEADER variable is set accordingly since we are running behind cloudflare
Steps to reproduce
Expected behaviour
Login and shows the dashboard
Actual behaviour
The 422 error is returned.
Troubleshooting data
complete `docker-compose logs`
Beta Was this translation helpful? Give feedback.
All reactions