Skip to content

Home session expiry maps 401 by exact error-string match (Low) #537

Closed

Description

@irzhywau

Severity: Low (fails closed; correctness and observability only)

Found in the security review of #536.

Current behavior

home_projection_token_error (elastos/crates/elastos-server/src/api/gateway_home_runtime.rs) decides 401 by exact string equality:

if err.to_string() == "home launch token auth session is not active" { 401 } else { 500 }

A future rewording of load_active_session_grant, an added .context(...), or any anyhow display change falls through to gateway_internal_error → 500. Access is still denied, but the client loses its "re-authenticate" signal and logs fill with misleading 500s.

Fix

  • Use a typed error (an enum such as HomeTokenError::SessionInactive, or err.downcast_ref) instead of string equality.
  • Log the underlying error before the map_err(|_| …) collapses in grant_bound_token_expiry (gateway_home_token.rs) and RoomSessionAuthorization::validate (room_service.rs), so a lapsed grant is distinguishable from I/O or state corruption.

Done means

  • A lapsed or revoked grant maps to 401 regardless of how the grant loader's message is worded.
  • The underlying grant-store error is logged before it is collapsed to an auth failure.

Activity

  1. added a commit that references this issue on Nov 16, 2026
  2. added this to the 2.0.2 milestone on Nov 16, 2026
  3. andersalm commented on Nov 16, 2026

    @andersalm
    Contributor

    Main: closed as the 13 Nov approval on #539 asked ("Close #537 after acceptance and merge"). The fix merged in #539 as d3322d2, and develop CI on that commit is green (run 43858070471).
    Both Done-means points hold in the merged code: the 401 is decided by the error type, and the grant-store error is logged before it is collapsed (Claude Fable review of 4497ca3).

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

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions