Skip to content

🐛 Bug Report: Server-side token and session events carry the plaintext secret to realtime and webhooks #14415

Closed

Description

@JoshiJoshiJoshi

👟 Reproduction steps

  1. A signed-in user U opens a realtime connection and subscribes to account.
  2. With an API key: POST /v1/users/{U}/tokens, then POST /v1/users/{U}/sessions.
  3. For comparison, log U in with POST /v1/account/sessions/email and create account tokens (magic URL, email OTP, recovery, verification).
  4. Optionally, add a webhook for users.*.tokens.*.create and users.*.sessions.*.create.

👍 Expected behavior

The event payload does not contain the secret, the same as for the account endpoints. Only the HTTP response to the caller that created the token or session returns it.

👎 Actual Behavior

Endpoint secret in the event (realtime account channel, webhook)
POST /v1/users/{id}/tokens plaintext
POST /v1/users/{id}/sessions plaintext (providerAccessToken / providerRefreshToken are included too; empty for email login, OAuth not measured)
POST /v1/account/sessions/email empty
Account token endpoints (magic URL, email OTP, recovery, verification) empty

Two runs, on both realtime nodes, identical. The secret of a token or session is a bearer credential. Webhook targets are often third-party services or end up in logs, so user credentials get written to external systems. Server-side token and session creation is the path that custom auth flows, SSO bridges and admin tools use.

Cause: Event::setPayload(array $payload, array $sensitive = []) removes the keys listed in $sensitive from the payload sent to realtime and webhooks. The account endpoints pass sensitive: ['secret'], e.g. app/controllers/api/account.php L2793. The server endpoints don't:

2.3.0 behaves the same. #14045 (OTP secret masking) covers a different path.

🎲 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

Pass sensitive: ['secret'] to setPayload() in both server endpoints, and also the provider tokens for sessions, the same as the account endpoints do.

👀 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: #14414 (realtime does not enforce MFA). Together, a password-only attacker on an MFA-protected account receives freshly created token/session secrets on the account channel and can turn them into a full session.

Activity

  1. added
    api / realtime
    product / auth
    product / messaging
    product / sites
    on Oct 13, 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

    api / realtimeproduct / authproduct / messagingproduct / sites

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions