Skip to content

fix(control): cap device-login session lifetime and let users revoke other sessions #234

Closed

Description

@abruption

What happened

Security and stability hardening audit finding H07 / P3 (2026-09-28). Priority is an audit recommendation, not a claim of a production incident.

Control configures Better Auth sessions with expiresIn: 86400 and updateAge: 3600, and sliding refresh is left on. Device login saves the bearer token from /api/auth/device/token in the client's login.json. The expiresAt stored next to it is checked only by the client. The /api/relay/* routes validate the token with server-side auth.api.getSession.

In a Node 22 fixture using the pinned better-auth 1.7.5 and the same session settings plus bearer(), a session with 1 h left was extended to 24 h by a single getSession call with Authorization: Bearer. With disableSessionRefresh: true it stayed at 1 h. A bearer token that is used at least once a day therefore never reaches an absolute expiry.

The token is not tied to a device. Revoking a device changes only relay_devices and pending challenges, not auth sessions. The web UI offers "Sign out" for the current browser session only. It has no way to list or revoke other sessions. A copied login.json can therefore keep account-level Control access indefinitely, including device enrollment, device revocation and recovery. Revoking the leaking device does not end that access.

What you expected

Device-login sessions have an absolute lifetime. Account holders can see and revoke other sessions. Revoking a device can also end the login session issued to it.

Environment

  • Baseline: published session-peer v1.0.2, commit 2046836822b88e53246de73851186598604cb5ec.
  • Reproduction: source review plus an in-memory Better Auth fixture (better-sqlite3, synthetic user); no deployed Control instance, live message/ACK tests or production mutation.
  • Audit environment: macOS arm64, Node 22.14.0, Python 3.14.7.
  • Discovery output: not applicable; no real session identifiers or credentials are included.

Source evidence

Acceptance criteria

  • Confirm, with a test against the pinned Better Auth version, whether /api/relay/* requests authenticated by bearer token extend session expiry, and keep that test as a regression guard.
  • Device-login bearer sessions have a documented absolute lifetime. Examples: disableSessionRefresh for bearer use, or a server-side cap from creation time.
  • The UI lists the account's active sessions and can revoke other sessions, or all sessions.
  • Revoking a device can revoke the login session linked to it, or the docs explain clearly why it cannot.
  • Browser sign-in keeps working, and the CLI surfaces login_expired so the user can re-login.

Scope and limitations

Exploiting this requires an existing copy of login.json. This is a hardening change for token lifetime and revocation, not a report of an authentication bypass.

Target: v1.0.3. This issue does not authorize a release or operating-service changes, including changes to the deployed Control instance.

Related, not duplicate: #118 (lost-key and restored-device recovery).

Checked

  • Searched existing issues for duplicates.
  • Removed credentials, conversation contents, private paths and real device/session identifiers.
  • Used isolated fixtures without weakening inbound permissions.

Activity

  1. added this to the v1.0.3 milestone on Sep 28, 2026
  2. added
    bug
    on Sep 28, 2026
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

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions