Repository navigation
Description
What is broken. On PR #140's branch, POST /api/v1/diary/session (server/app/api/diary.py, register_session) takes login from the request body and stores it on the session row (services/diary._open_row). The server validates the credential with its own upstream read, but nothing compares the login with the account behind that credential: Petersburg's adopt only lists the children, and «Сетевой город»'s only runs the bootstrap.
The corrections a family lays over the diary are filed under that login (services/diary.owner_key). All the corrections routes key on row.login: the schedule and homework reads, GET/PUT .../overrides, POST .../overrides/reset and DELETE .../overrides/all. Their only other check is _student, which asks whether this session's account can see the pupil.
Before this branch the only way to open a row was /diary/login, where the upstream had just accepted a password for the login. So this gap is new with /session, and it is not on main.
The failure scenario (reproduced end to end against a fake upstream by two independent verifiers):
- Parent A signs in with
/loginasa@x.ruand corrects the room of child 4021 to «204». - Parent B has their own Petersburg account, which also lists child 4021 (the other parent, for example). B sends
POST /api/v1/diary/session {"provider":"petersburg","login":"a@x.ru","credential":{"token":<B's own JWT>}}and gets200. - B's
GET /students/4021/scheduleshows A's «204», andGET .../overrideslists A's row. - B's
PUTchanges what A sees, and B'sPOST .../overrides/resetremoves A's correction.
Severity: low. The attacker must already see the child through a diary account of their own and must know the other adult's login. What they reach is one family's own corrections to lessons they can already read. adopt's docstring, the schema comment and docs/api.md all say the login is not vouched for. None of them says that another adult who sees the same child can read and rewrite these corrections, and the code's own comments still say «every correction this account has made».
Why no test sees it. test_the_login_finds_the_corrections_a_password_sign_in_left has one account sign in both ways and pins the shared key as a feature. No test has two accounts on one child.
Why it is not fixed yet. Every correct fix is a product decision, so it went to the owner (26 September 2026):
- (a) Share the corrections per child: diary, region, pupil. Both parents see and edit them, and the login plays no part.
- (b) Key them on the account the diary vouches for: «Сетевой город»'s user id, or a claim inside Petersburg's JWT. No live answer has ever been seen, so this rests on fields nobody has confirmed. It also breaks
owner_key's promise that a Petersburg key is the bare case-folded login. - (c) Keep the behaviour, and document the trade-off in
docs/api.mdand the comments.
The first answer chose (b), and the owner then stopped that implementation before it changed any file. This issue holds the finding until the decision is final. Neither 0015 nor 0016 depends on it: (a) and (c) need no schema change, and (b) would be an additive revision after 0016.
Metadata
Metadata
Assignees
Type
Projects
- StatusShow more project fieldsDone
Activity
Say where #140 stands now that both reviews are in: one decision left…
lumenpearson commentedon Sep 26, 2026
Decided by the owner, 26 September 2026: (a), shared per child. This replaces the first answer, (b), which was withdrawn before it touched a file.
What that means in the code:
CHILD:petersburg, orCHILD:netschool:<the region's diary host>, together with the pupil id. The host is used rather than the region's name because pupil ids are numbered per server. If a region ever moves to another server, its corrections are lost rather than attached to a different child who happens to have the same number./sessionis shown on «вы вошли как» and nothing else. It decides no access, so naming someone else's login gains nothing. A reset removes a correction for everyone who sees the child, and the last writer wins.CHILDprefix. Every old key is a lowercased login, so no per-child key can equal one. Code reverted tomaincan neither read these rows nor write into them.trueread as pupil 1 in «Сетевой город».0017, data only. It folds old login-keyed rows into the per-child key; where two collide, the newest wins. It deletes the branch-only «Сетевой город» hash-keyed rows, which can no longer be read. On production it rewrites nothing, becausediary_overridesheld 0 rows when read on 26 September.docs/api.mdanddocs/guide.mdchange in the same batch so that they say this.Still unverified, and it will stay written down: that a «Сетевой город» pupil id is unique per server rather than per school, and that two parents' accounts see the same id for one child. No live answer has been seen.
The fix lands on #140's branch and closes this issue.
Generated by Claude Code
File the family's diary corrections under the child, so a login a pho…
Record that 0015, 0016 and 0017 are on production, and where #140 sta…