Repository navigation
Session lineage: stamp and measure the supersession window on the store's own clock (ASVS 7.2.4, BACKLOG #4276) - #3259
wshallwshall wants to merge 3 commits into
Conversation
ASVS 7.2.4 arm (ii). A link's retired_at was the elevating process's
time.time() and the window was measured from the signing-in process's,
so a forward step of the signing-in clock, or skew between engine
hosts, dropped a link inside the real window and left the rotated
session live.
Every backend now stamps retired_at from the database clock in the
link INSERT, and the lineage read and the reaper purge measure the
window back from that same clock (SQLite julianday('now'), Postgres
statement_timestamp(), SQL Server SYSUTCDATETIME()). The store API
takes a window length (lineage_seconds) instead of an instant
(lineage_since); rotate_session takes no now. The sign-out asks for
its 5 s plus the time since its proof.
Residual, stated in SECURITY.md and ADR 0210 Amendment B: a step of
the store's own clock still moves the window (on SQLite, the clock of
the host holding the file).
Tests: a 425 s-class forward step of the signing-in process no longer
drops a link (SQLite, service and logout); the store contract now
checks the window and purge ignore the caller's now on all three
backends; tests that aged a link by patching time.time now age it in
the store.
BACKLOG #4276
Review round 1 of the store-clock change. - The walk adds back, on the monotonic clock, the time a store call spent waiting before each lookup, so a lock, connection or row-lock wait no longer shortens the window the caller asked for. - POST /auth/logout reads proven_at on the monotonic clock, and the sign-out measures the time since it on the same clock. - The reaper asks the purge for the window plus its step tolerance, restoring the margin the store-clock purge had dropped. - SECURITY.md, ADR 0210 Amendment B and the docstrings no longer claim an engine clock step is closed on SQLite: there the store's clock is the engine host's. - The store contract now places one window between two real link ages on every backend; the SQLite aging helper moved beside it. BACKLOG #4276
…ll-clock proof time Review round 2. - SECURITY.md names the new residual: on a server store, a forward step of the database clock larger than the reaper's step tolerance lets a purge delete links still inside the bound. - logout refuses a proven_at ahead of the monotonic clock, the shape of a wall-clock reading, rather than silently narrowing the window. - supersession_lineage_seconds says the purge keeps links for the window plus the step tolerance. - The SQLite aging helper takes the store's writer lock; the positive /ui/logout test keeps a 4 s margin; the store docstrings point to store/session_lineage.py instead of restating the residual; the redundant float() coercions are gone. BACKLOG #4276
|
QA (Builder E2, BACKLOG #4276): code-review xhigh, Rounds: 2 + 1 unrepaired, Tag: "xhigh effort -> 10 inline angles -> dedup (no verify) -> sweep -> <=15 findings" (review_tag.py exit 0, round-68bb0bff; rounds 959cf298, f58b65fa same tag) Unrepaired round-3 findings, none fixed, as the Builder reported them:
|
|
Lander hand-over (Manager aebf32, batch 684)
Ledger ask after merge: banner for #4276. The Builder's text is carried with only the requirement-number and arm labels removed, because this is a public place: |
Merge danger
Reversible: yes -- reverting the squash on
mainrestores wall-clock stamping of the session lineage. No schema migration: the change is in the SQL each backend issues, not in the table shape.Blast radius: session rotation, supersession, sign-out and the lineage purge, on all three stores (
messagefoundry/store/store.py,postgres.py,sqlserver.py,base.py,session_lineage.py);messagefoundry/auth/service.py; thePOST /auth/logoutproven_atcontract (api/app.py,api/auth_routes.py, now monotonic, and a wall-clock value raises); the web console logout test;docs/SECURITY.md; ADR 0210 Amendment B and its index row.Evidence
origin/main353b2183fe2,rotate_sessionstampedretired_atwith the engine'stime.time(), and the lineage walk compared that stamp with the signing-in process's ownbefore - window. An engine-host clock step, or skew between engine hosts, could drop a link inside the window.tests/test_session_supersession_lineage.pyandtests/test_session_supersession.py; control: they fail onmain's code. Targeted pytest (lineage, supersession, webauthn contract on SQLite, placeholders, pool, api_auth, auth_before_body, web console logout): 244, then 220 passed on the final head. mypy all four legs clean.Batch 684, BACKLOG #4276 (Builder E2)
Source branch
b684-4276-lineage-clock, head2d785e2ba455ed225a08e199a8c7024b6a1ea1cf. Its own PR because it changes a security control.What changed. Every backend stamps
retired_atfrom the database's own clock in the link INSERT: SQLitejulianday('now'), PostgreSQLstatement_timestamp(), SQL ServerSYSUTCDATETIME(). The lineage read and the purge measure the window length,lineage_seconds, back from that same clock. Store waits are added back on the monotonic clock, and the reaper purges at the window plus its step tolerance.What it does, and does not, do (as
docs/SECURITY.mdnow states):Files beyond the brief's list (the protocol change and the docs needed them):
store/base.py,store/session_lineage.py,api/app.py,api/auth_routes.py,docs/SECURITY.md, ADR 0210 Amendment B, the ADR index row,tests/test_api_auth.py, and the web console logout test.Interaction: batch 684's PR 3255 (BACKLOG #4846) also edits
messagefoundry/auth/service.py.git merge-treeof the two heads exits 0; whichever lands second may still need a branch update.Open question for the owner, not decided here: whether the SQLite host-clock-step case is a deployment requirement (host clock discipline, BACKLOG #2350) rather than something this code must close.
Checks run:
ruff checkandruff format --checkclean; mypy in the four CI legs clean; targeted pytest as above.Not run: the PostgreSQL and SQL Server contract (
test_session_lineage_contract), which is hosted-only: read the postgres and sqlserver legs. The full suite./simplify.Review: code-review skill at xhigh, Rounds: 2 + 1 unrepaired. The QA line and the 12 unrepaired findings are in a comment below.