Use of Pow.Store.Backend.MnesiaCache is susceptible to session hijacking as expired keys are not being invalidated correctly on startup. A cache key may become expired when all Pow.Store.Backend.MnesiaCache instances have been shut down for a period that is longer than the keys' remaining TTL and the expired key won't be invalidated on startups.
Workarounds
The expired keys, including all expired sessions, can be manually invalidated by running:
:mnesia.sync_transaction(fn ->
Enum.each(:mnesia.dirty_select(Pow.Store.Backend.MnesiaCache, [{{Pow.Store.Backend.MnesiaCache, :_, :_}, [], [:"$_"]}]), fn {_, key, {_value, expire}} ->
ttl = expire - :os.system_time(:millisecond)
if ttl < 0, do: :mnesia.delete({Pow.Store.Backend.MnesiaCache, key})
end)
end)
References
pow-auth/pow@15dc525
pow-auth/pow#713
pow-auth/pow#714
References
Use of
Pow.Store.Backend.MnesiaCacheis susceptible to session hijacking as expired keys are not being invalidated correctly on startup. A cache key may become expired when allPow.Store.Backend.MnesiaCacheinstances have been shut down for a period that is longer than the keys' remaining TTL and the expired key won't be invalidated on startups.Workarounds
The expired keys, including all expired sessions, can be manually invalidated by running:
References
pow-auth/pow@15dc525
pow-auth/pow#713
pow-auth/pow#714
References