Skip to content

Logout leaves the session cookie in place when the revocation write fails #2981

Description

@lidonius1122

Describe The Bug

Noticed this while testing e5f2f0d4 on beta-5.28.1 and mentioned it in an email thread with the security team — filing it here as well so it doesn't get lost. Measured against the e2e suite rather than a running install, hence the odd-looking environment fields below.

In logout(), revokeUserSessions() is awaited before the cookies are cleared. If it throws, the Set-Cookie line is never reached: the response is a 500 with no Set-Cookie header at all, and the hb-refresh cookie stays in the browser. POST /auth/session with it still returns 201 afterwards.

The UI catches the error and reloads regardless, so from the user's side: they click "log out", the page reloads, and they are back in the signed-in interface with no indication that anything went wrong.

Steps to reproduce (Nest e2e via app.inject, against 270ef02e):

  1. Log in, keep the hb-refresh cookie.
  2. Make the write fail. I used a read-only storage directory (EACCES when the temp file is opened) and, separately, a corrupted auth.json while the user cache was still warm.
  3. POST /auth/logout → 500, no Set-Cookie.
  4. POST /auth/session with the same cookie → 201, with a usable access token.

Control run with a writable directory: logout 201, and the same cookie then returns 401.

Neither failure is something an attacker can trigger, but both are plausible on a Pi — ext4 defaults to remounting read-only on error, and a full or dying SD card gets there. The corrupted-file variant also persists: the user "logs out", someone repairs auth.json later, and the cookie still restores the session because sessionVersion was never incremented.

Clearing the cookies even when the revocation fails would make logout fail closed. How you do that is your call — I've got a patch and a test ready if you want it, happy to open a PR or leave it with you.

Homebridge UI Version

beta-5.28.1 @ 270ef02

Homebridge Version

2.4.0

Node.js Version

24.19.0

Operating System

Other (specify in description)

Environment Info

Other (specify in description)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions