Repository navigation
Description
👟 Reproduction steps
- A signed-in user U opens a realtime connection and subscribes to
account. - With an API key:
POST /v1/users/{U}/tokens, thenPOST /v1/users/{U}/sessions. - For comparison, log U in with
POST /v1/account/sessions/emailand create account tokens (magic URL, email OTP, recovery, verification). - Optionally, add a webhook for
users.*.tokens.*.createandusers.*.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:
Users/Http/Users/Tokens/Create.phpL93–L98: plaintextsecretset on the model, thensetPayload(...)withoutsensitive.Users/Http/Users/Sessions/Create.phpL126–L136: same.
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