Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JWT in URL: option to send it within the socket connection #84

Open
fjf2002 opened this issue May 25, 2022 · 7 comments
Open

JWT in URL: option to send it within the socket connection #84

fjf2002 opened this issue May 25, 2022 · 7 comments

Comments

@fjf2002
Copy link
Contributor

fjf2002 commented May 25, 2022

My security department has a problem with sensitive data as part of URLs - here: the JWT.

Can you imagine requesting a channel by POSTing a JWT - or like postgrest : putting the JWT in a header instead (i. e. Authorization: Bearer)?

The security background probably is, the webserver logs (of my reverse proxy) contains URLs, thus currently contains sensitive data (the JWTs).

@diogob
Copy link
Owner

diogob commented May 26, 2022

@fjf2002 unfortunately the websocket clients on browsers are very limited and AFAIK do not have any header capability. Check this discussion for more info.

It seems that the simplest solution in this case would be to apply some filter on the logs to remove the those URLs before persisting them.
I also advise short TTLs (a few minutes) for the tokens and some error handling that tries to get new tokens a few times.

We could have some option to send the token as the first message and move the auth to the websocket connection.

@fjf2002
Copy link
Contributor Author

fjf2002 commented May 30, 2022

Ok, thanks for the clarification.

@fjf2002
Copy link
Contributor Author

fjf2002 commented May 31, 2022

Just another idea: What about sending the token in-channel, i. e. as the first websocket message after connection, from the browser to the postgres-websockets?

@diogob
Copy link
Owner

diogob commented May 31, 2022

@fjf2002 yes, that would work. It adds a bit of complexity to the code, and it could be easier for a malicious user to consume resources (since we would have to open the socket before authenticating). But this could be enabled by a configuration flag to avoid using this workflow in cases where it's not needed. I'll leave this issue open as an enhancement and see if anybody else will thumbs up this.

@diogob diogob changed the title JWT in URL: security issue? JWT in URL: option to send it within the socket connection May 31, 2022
@fjf2002
Copy link
Contributor Author

fjf2002 commented Jun 2, 2022

ok, thanks!

@fjf2002
Copy link
Contributor Author

fjf2002 commented Jun 2, 2022

it could be easier for a malicious user to consume resources (since we would have to open the socket before authenticating).

You seem to mean the additional HTTP->Websocket "switching protocol" server reponse? The TCP socket must be open in each case.

@diogob
Copy link
Owner

diogob commented Jun 2, 2022

Also the server thread that keeps the websocket session alive sos we can wait for the auth token.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants