Skip to content

Logout deletes another farm's legacy cookie, signing that tab out #569

Description

@mforce

Follow-up from PR #564 (round-12 review). Not a security hole — a usability and correctness wart during the migration window only.

What happens

#564 stopped a farm-B logout from revoking a farm-A legacy session. It did not stop it deleting the cookie.

src/Cluckwork.Api/Endpoints/Auth/AuthEndpoints.cs:618-619 clears the legacy cookie unconditionally whenever one is presented, regardless of which farm owns it. So during the migration window:

  1. a tab opened before the deploy holds legacy cluckwork_rt for farm A;
  2. a new login writes cluckwork_rt_<B>;
  3. logging out of farm B deletes both cookies.

Farm A's tab is signed out by a logout it had nothing to do with. The same path is reachable from revokeSupersededCookie, which the user never initiates.

Worse in a quiet way: farm A's refresh token is now live but unreachable — not revoked, so it survives to ExpiresAt, but its only browser copy is gone. Nothing can use it and nothing will clean it up early.

The test pins the loss

tests/Cluckwork.Api.IntegrationTests/RefreshAccountBindingTests.cs:495 asserts that deletion, inside a test named Logout_WithSelectedFarmAndCrossFarmLegacyCookie_RevokesSelectedAndLeavesLegacySessionLive. The name says the session lives; the assertion requires its cookie to be destroyed. Whatever is decided here, that test needs renaming or re-pointing.

Why it was not fixed in #564

The revocation half was the security-relevant half and is fixed and mutation-proven. This half costs a re-login for a user who had two farms open across a deploy boundary, and the legacy branch drains within one refresh-token lifetime. It did not justify holding an eleven-round PR.

Suggested fix

Resolve the legacy cookie's owner before clearing it — the same resolution the revoke path already does — and clear it only when it matches the selected farm, keeping unconditional clearing when only a legacy cookie is presented.

Verify

  • a farm-B logout with a farm-A legacy cookie present leaves farm A's cookie and its session usable;
  • a logout presenting only a legacy cookie still clears and revokes it;
  • the cross-farm test name and assertions agree.

Found by an internal mutation reviewer, round 12 of #564. Epic #530.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions