Skip to content

A «Сетевой город» session sends ver=None upstream when logindata has no cacheVer, and its stored timeOut is never read #147

Closed

Description

@lumenpearson

What is broken.

The «Сетевой город» sign-in takes the session's ver from cacheVer in GET /webapi/logindata with setdefault. If that field is missing or null, the session stores "ver": None. That value is sealed into the credential as JSON null. Both calls that send ver build it with str(self.session.get("ver", "")). The key exists, so the "" default never applies, and they send the four-letter string None: the SecurityWarning acknowledgement and POST /webapi/auth/logout.

The project's own reference does not list cacheVer among the logindata fields (docs/diaries/netschool.md:53 and :203). Only one server in regions.md has been seen returning it. The tests always supply it, so nothing covers the missing case.

Separately, the module docstring says the session keeps "the login's timeOut so the keep-alive knows this server's idle window". Sign-in does write time_out, but nothing reads it. The keep-alive pings on a fixed four-minute floor whatever the server's window is. The docstring describes behaviour that does not exist.

The failure scenario.

  1. A family signs in to a region whose GET /webapi/logindata answers {"schoolLogin": true, ...} with no cacheVer.
  2. login_allowed runs self.session.setdefault("ver", None). The session was built in NetSchoolProvider.sign_in without a ver key, so None is stored. client.credential serialises it as "ver": null, and it is sealed into diary_sessions.upstream_token.
  3. Later, any authenticated read or the cron keep-alive gets the co-working /asp/SecurityWarning.asp interstitial. _acknowledge_warning then posts at=…&WarnType=2&ver=None. The same can happen during the sign-in bootstrap, from the in-memory session.
  4. If the server rejects that acknowledgement, the retried call shows the interstitial again. _authed_json then raises SessionExpired, so the family's session is expired, and the only thing wrong is a ver the client made up. This step depends on how the upstream checks ver, and nothing has been run against a live server.
  5. On sign-out, services/diary.py calls provider.open(credential).close(), and logout posts at=…&ver=None to /webapi/auth/logout.
  6. Separately: a reader of the client's docstring expects the keep-alive to adapt to timeOut (900000 ms on one server, 3600000 ms on asurso.ru). It does not. session["time_out"] is written and read by nothing except one test assertion.

Where.

  • server/app/providers/netschool/client.py:263: self.session.setdefault("ver", data.get("cacheVer")) stores None.
  • server/app/providers/netschool/client.py:244: _acknowledge_warning sends str(self.session.get("ver", "")), which is "None".
  • server/app/providers/netschool/client.py:393: logout sends the same expression.
  • server/app/providers/netschool/client.py:221-225: a second interstitial after the acknowledgement raises SessionExpired.
  • server/app/providers/netschool/provider.py:165-166: the session starts without a ver key.
  • server/app/providers/netschool/client.py:9-12: the docstring promises the keep-alive uses timeOut.
  • server/app/providers/netschool/client.py:341-342: time_out is written and never read.
  • server/app/services/diary_keepalive.py:48 and :141-156: the keep-alive uses a fixed KEEPALIVE_MIN_INTERVAL of four minutes and never looks at the session's time_out.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    • Status
      Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions