Skip to content

πŸ› Bug Report: Realtime accepts sessions that have not completed MFAΒ #14414

Closed

Description

@JoshiJoshiJoshi

πŸ‘Ÿ Reproduction steps

  1. Create a user with a verified email and enable MFA (mfa: true, an authenticator added).
  2. Log in with email and password only: POST /v1/account/sessions/email β†’ session with factors: ["password"].
  3. With this session, GET /v1/account and GET a row readable only by user:<id>.
  4. Open wss://<host>/v1/realtime?project=<id> with the same session cookie and subscribe to a table channel and to account.
  5. Create a row with read("user:<id>") (e.g. with an API key).

πŸ‘ Expected behavior

Realtime rejects the session the same way the HTTP API does (user_more_factors_required) until the second factor is completed. No user data and no events are delivered.

πŸ‘Ž Actual Behavior

Step Response
GET /v1/account 401 user_more_factors_required (correct)
GET row with read(user:<id>) 401 (correct)
Realtime connect accepted; the connected message contains the complete user document (email, targets, prefs, mfa, …)
Subscribe to table channel and account accepted
Row created with read(user:<id>) event with the full row data delivered to this connection

Two runs, on both realtime nodes, identical. Someone who knows the password but not the second factor can read live everything the account can read through realtime: rows, file metadata, account, team and membership events. MFA is not enforced for realtime at all.

Cause: the HTTP API checks the factors in app/controllers/shared/api.php L545–L564. app/realtime.php resolves the user and roles from the session on connect and in the authentication message handler, but never looks at mfa, the user's verified factors or session.factors. The password-reset check that comes before it in shared/api.php is missing too (from the code, not measured). 2.3.0 behaves the same.

🎲 Appwrite version

2.4.0 (also 2.3.0)

πŸ’» Operating system

Linux (Debian 12), Docker

🧱 Your Environment

Self-hosted Appwrite 2.4.0, two API nodes, two realtime nodes.

πŸ’‘ Suggested fix

Apply the same factor check (and the password-reset check) in realtime on connect, on the authentication message and whenever roles are recomputed; reject with user_more_factors_required.

πŸ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find a similar issue

🏒 Have you read the Code of Conduct?

  • I have read the Code of Conduct

Related: #14415 (plaintext secret in server-side token/session events) makes this worse. If a backend creates tokens or sessions for the user through the server API, those secrets reach the account channel in clear text, which turns this read bypass into a full account takeover.

Activity

  1. added
    api / realtime
    product / auth
    product / avatars
    product / databases
    product / messaging
    product / self-hosted
    product / storage
    product / vcs
    on Oct 13, 2026
  2. changed the title [-]Realtime accepts sessions that have not completed MFA (MFA bypass for realtime reads)[/-] [+]πŸ› Bug Report: Realtime accepts sessions that have not completed MFA[/+] on Oct 13, 2026
  3. sundeep8967 commented on Oct 31, 2026

    @sundeep8967

    Verified on current main: this issue has already been resolved by commit 30105a7 (#15134).

    Specifically:

    • In app/realtime.php, MFA factors are checked during connection establishment and Exception::USER_MORE_FACTORS_REQUIRED is thrown if the user has MFA enabled and the session has not completed the required factors.
    • In src/Appwrite/Realtime/Message/Handlers/Authentication.php, the authentication message handler also validates MFA factors and throws Exception::USER_MORE_FACTORS_REQUIRED when necessary.

    This can be closed.

  4. HarshMN2345 commented on Nov 4, 2026

    @HarshMN2345
    Member

    Fixed in #14803, thanks for reporting it!

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

    api / realtimeproduct / authproduct / avatarsproduct / databasesproduct / messagingproduct / self-hostedproduct / storageproduct / vcs

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions