Skip to content
New issue

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

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

Already on GitHub? # to your account

Is it safe to pass access token as query param? #79

Open
asvrada opened this issue Jul 17, 2023 · 4 comments
Open

Is it safe to pass access token as query param? #79

asvrada opened this issue Jul 17, 2023 · 4 comments

Comments

@asvrada
Copy link

asvrada commented Jul 17, 2023

In the above link, an access token is generated and passed back to user-agent (browser) as query param. Is there a security risk for transferring access token in plain text URL?

@Invectys
Copy link

i have the same question

@aditya812
Copy link

Passing an access token as a query parameter is generally not recommended from a security standpoint.

URL Visibility: Query parameters are often visible in browser history, server logs, and can be easily copied from the URL. This means that if someone gains access to a user's browser history or a server log, they could potentially obtain the access token, which can be used maliciously.

Caching: Some web browsers and caching mechanisms may cache URLs, including query parameters. If an access token is included in a URL, it could be cached on the user's device or intermediary caching servers, making it accessible even after the user logs out or the token expires.

@luvarqpp
Copy link

luvarqpp commented Oct 6, 2023

Sidenote, when using SSE using standard approach like:

 var source = new EventSource("demo_sse_endpoint");

You have no possibility to add any headers (i.e. Authorization header with Bearer token, JWT).
There is generally advised to pass some special, one time only, token as query parameter. On the other side, when connection is lost and event stream tries to re-establish connection, you will face problem, when given token is not valid anymore. There can be message id used as another secret, but it make things even more complex.

@AdigaAkhil
Copy link

User-agent storing Any form of tokens is not a good practice according to this article

One of the approaches is to use a BFF server along with session cookies with the User-Agent.
On successful login. the success handler should set an httpOnly session cookie. Which later will be used by the User-Agent to get the access-token only.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants