Page MenuHomePhabricator

Investigate storing anonymous sessions client-side
Closed, DeclinedPublic

Description

We might want to explore session store implementations which do not put load on our infrastructure (see T394075: Investigate using different stores for different kinds of sessions for motivation). The ultimate version of this is not using our infrastructure at all, and storing the session on the client side. We probably don't want to do this for security-sensitive data (we don't want the security of our session encryption scheme and key management to be the only things preventing an attacker from impersonating any other account by just changing the username in the session data), but for anonymous sessions it might be fine.

Some potential complications:

  • Sessions can be large. AuthManager puts a fair amount of data in the session. Special:Book can put an arbitrarily large amount of data in the session.
  • Especially during login, we do store security-sensitive information in the session; an attacker manipulating that would be functionally equivalent to being able to manipulate the username in an authenticated session. So the exact scope of what sessions to use this for might be somewhat different from "unathenticated". Or maybe we might want to use a scheme where some data is stored in the cookie but it can have a pointer to further data in the session store. (We already have Session::setSecret(), that might be a reasonable way of differentiating.)
  • Using cookies as storage limits what code can write to the session (e.g. jobs or post-send deferred can't). That would break some use cases like storing upload progress in the session, although probably those use cases are not relevant for anonymous users.
  • Race conditions and similar problems will get worse as time between MediaWiki code issuing a session write and the session store (browser) actually receiving it goes up by a magnitude.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

Stateless web frameworks such as Flask and Play Framework store everything locally in Cookies. However in Wikimedia wikis, I doubt how many anonymous sessions is active (comparing with logged-in and temporary accounts), and if the number is small, it may not worth doing. In addition, how is anonymous sessions currently used - some feature can be rewritten with cookie only without using session store.

This is phrased non-committally ("investigate" rather than "do") because I'm somewhat skeptical it will be feasible. If we end up doing it, we'll want some subtasks though (probably around analytics / deployment, maybe performance) - this would be a significant change.

However in Wikimedia wikis, I doubt how many anonymous sessions is active (comparing with logged-in and temporary accounts)

About two thirds of session writes are anonymous (per this dashboard).

In addition, how is anonymous sessions currently used

Mostly CSRF and login/signup state.

I think this should be a top-level epic for 5.1.1: it's fairly large (investigating not so much, but if we end up actually doing it, that is going to take some effort), it's not part of the commitment we made about providing a separate backend for anonymous sessions (it's more like a "backendless" mode), it will need its own QA and deploy process which won't have any overlap with the one for a separate anonymous backend.

JTweed-WMF claimed this task.
JTweed-WMF subscribed.

As @Tgr notes this ticket was an investigation and I think we've decided not to do this, so closing as resolved.

Tgr changed the task status from Resolved to Declined.Nov 24 2025, 10:43 AM

Just to clarify, we didn't investigate whether client-side session storage is possible (we decided that with T400372: Separate storage backend for anonymous sessions done, there is no pressing reason for now so even if we found client-side storage is technically feasible, we probably wouldn't invest into building it, making the investigation pointless).