idi527
I’ve noticed this warning
https://github.com/phoenixframework/phoenix/blob/v1.3/lib/phoenix/token.ex#L225-L231
in phoenix, and wondered what kind of vulnerability would storing a “forever valid” session id have. In other words, is this warning only for the users who store some extra data in the token (besides the session id) which can go stale?
Trending in Questions
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
Hello,
I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
Documentation
While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
Other Trending Topics
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Hi everyone!
The first release candidate for the Expert language server project is now available!
We’ve published a press release detai...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixirconf-us
- #ai
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #hex
- #security










Showing Posts 1 to 6- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
jordiee
Besically the idea of it is if someone gets their hands on a token without an expire that does not belong to them they will forever have access with that token. With an expire time that is not the case. Depending what you are using Phoenix token for it could be perfectly fine that way though.
voltone
I believe the purpose of this warning is to encourage people to explicitly opt-in to non-expiring tokens by setting
max_ageto:infinity. The future default will ‘err on the side of caution’, which is a good security practice.One use-case for non-expiring tokens is to simplify development/testing. In a production environment, non-expiring tokens should only really be used if the token can be revoked, e.g. on sign-out or when the user changes password. This can be achieved by encoding in the token a timestamp or sequence number that is also stored in the User DB record, and updating the DB on sign-out or password change, rendering old tokens invalid.
Without revocation, every sign-in would issue yet another valid token, and the user would have no control over who might abuse such old tokens. A token might be left behind on a public computer, or yet-to-be-discovered weaknesses in crypto protocols might allow an attacker to extract a token from an old packet capture. There would be nothing the user could do, and the site admin could only change the secret key, invalidating all tokens at once.
idi527
In my case the token is stored in the secure enclave and sent to the backend over TLS so that is hardly the case.
I don’t see much difference between forever and at least some time: in both cases the system is breached and the damage is done.
What I don’t understand, is why should there be a default for everyone, even if, as in my case, there isn’t any real additional threat for having “forever valid” signed session ids …
In my case the users don’t have passwords, their “accounts” are tied in to their installation of the app (iCloudID). I only need to know their account or user id, which is, again, exchanged with the server over TLS and the token itself is stored in the secure enclave.
That might affect me, but I’m not sure how. Currently, only one installation of the app per account is allowed, but in the future I might change that. But even then I don’t see why I would want to revoke a token with session id, for someone to abuse it, the abuser would have to have direct access to the victim’s phone.
This definitely could affect me. But that would affect every user, so I might as well just change the secret used for signing the tokens.
Thank you, @voltone!
voltone
If your use-case and threat model allow never-expiring tokens, you can opt-in by passing
:infinity. That will eliminate the warning. The upcoming change and the warning are about making this opt-in rather than opt-out, to avoid mistakes due to someone missing a warning in the docs.voltone
There are other, perhaps more likely, examples where the protection of TLS might be less than perfect. For example, in the past CAs have been compromised and fake certificates issued to intercept communications. This might only affect users in a certain country or using a certain ISP.
The point is, relying on tokens that can never ever be revoked is a risk, no matter how hard you try to protect them. Giving users an option to revoke their own tokens using the DB-backed mechanism I described might be wise, to add another layer of protection.
idi527
I intend to “solve” it with certificate pinning. Since it’s an iphone app that I’m developing, it is possible to do.
But I do understand that there is most likely a way to abuse every “forever valid” token, I just wanted to be sure and know what the possible threats are.
I’ll probably add a counter together with user id into the token, and increase the counter once the user decides to refresh the token. But I’m not sure I want to add automatic expiration via timestamps.