# GHSA-P7PG-W358-F35F: Realtime app secret defaults to a hash of the database password, allowing unauthenticated private channel access and XSS

- Database: GitHub
- Severity: CVSS 8.8 (High)
- Published: 2026-11-28
- Modified: 2026-11-28

## Affected versions

- flarum/realtime (Packagist): from 2.0.0-beta.5, fixed in 2.0.3
- flarum/realtime (Packagist): from 2.1.0-beta.1, fixed in 2.1.0-beta.2.1

## Description

### Summary

The Realtime extension (`flarum/realtime`) signs private-channel subscriptions and requests to its daemon with an app secret. Unless `websocket.app-secret` is set in `config.php`, that secret is the MD5 hash of the database password. A forum on SQLite has no database password, so its secret is the MD5 of the empty string, the same on every such forum. The same holds for any database account without a password, and a weak password can be guessed offline.

With that secret and the app key, which is public, a visitor without an account can read other users' private channels and send any event to any connected user. A forged event can change the HTML of a post in the victim's browser, so it runs the attacker's JavaScript in the victim's session.

### Details

`extensions/realtime/src/Websocket/Settings.php` sets the default secret to `md5($dbPassword)`. The app key (`md5` of the forum host) is sent to every visitor in the forum payload.

With both values, an attacker can:

- subscribe to any `private-user=<id>` channel and receive that user's realtime events, including the text of private messages and notifications;
- call the daemon's HTTP interface (`/apps/1/channels`, `/apps/1/events`), listing occupied channels and sending any event to any channel.

The forum frontend puts the data of received events into its store (`app.store.pushPayload`). An event can overwrite a post's `contentHtml`, which core renders as markup, so script in it runs on the forum's origin in the receiving user's session.

On a forum whose database has a password, `POST /api/websocket/auth` gives a visitor a valid signature for the typing channel of any discussion they can read. That signature is an HMAC under the secret, so guesses of the database password can be checked offline; a hit gives both the app secret and the database password.

The fix generates a random 256-bit secret once, stores it in the settings table and keeps it out of the admin payload. The secret is no longer derived from the database password. A secret set in `config.php` still takes precedence.

### Proof of concept

On a forum that uses SQLite, with Realtime enabled and its daemon running, and no `websocket.app-secret` in `config.php`:

1. Read the app key from the forum payload.
2. Open a websocket to the daemon and subscribe to `private-user=2`, signing the subscription (`HMAC-SHA256(socket_id:channel)`) with `d41d8cd98f00b204e9800998ecf8427e`, the MD5 of the empty string. The daemon accepts it. When another member sends user 2 a private message, the attacker receives it.
3. `POST /apps/1/events`, signed with the same secret, delivers an event to every client connected on a channel. An event carrying a `posts` resource with script in its `contentHtml` runs that script in the browser of a signed-in user viewing the post.

### Impact

On affected forums, an unauthenticated attacker can read private messages and notifications as they are sent, and run JavaScript in the browser of any connected user. That script can read the CSRF token and call the API with the victim's permissions. If the victim is an administrator, the attacker can change any setting, including the custom header HTML, and so take over the forum.

Affected forums are those with Realtime enabled and running, no `websocket.app-secret` in `config.php`, and a database password that is empty (always so with SQLite) or guessable. Forums with a strong database password are exposed only to offline guessing of that password.

### Patches

Fixed in `flarum/realtime` **2.0.3** (Flarum 2.0) and **2.1.0-beta.2.1** (Flarum 2.1 beta). Update, run migrations, then restart the daemon and queue workers:

```
composer update flarum/realtime
php flarum migrate
php flarum cache:clear
php flarum queue:restart
```

The update replaces the old secret with a random one. A running daemon keeps using, and accepting, the old secret until it restarts, so restart it with your process manager (for example `supervisorctl restart realtime` or `systemctl restart flarum-realtime`), or stop and start `php flarum realtime:serve` if you run it by hand. `migrate` and `cache:clear` also signal the daemon to stop within 10 seconds, but restart it yourself to be sure the new secret is in use.

If your database password is weak, change it as well: the old secret was the MD5 hash of that password, so anyone who recovered the secret may also have it.

### Workarounds

Set a random secret in `config.php`, then restart the daemon:

```php
'websocket' => [
    'app-secret' => '<a long random value, e.g. the output of: php -r "echo bin2hex(random_bytes(32));">',
],
```

Or disable the Realtime extension until you can update.

### References

- CWE-1188: Initialization of a Resource with an Insecure Default
- CWE-1394: Use of Default Cryptographic Key
- Affected file: `extensions/realtime/src/Websocket/Settings.php`

## References

- https://github.com/flarum/framework/security/advisories/GHSA-p7pg-w358-f35f

Page: https://cve.now/GHSA-P7PG-W358-F35F

Wrong or missing data? Send feedback: POST https://cve.now/api/v1/feedback (see https://cve.now/agents#feedback).
