# GHSA-98CG-M2CG-6XPR: Malicious/compromised server crashes any embedding application via malformed Reply frame (centrifugal/centrifuge-go dependency)

- Database: GitHub
- Severity: low (stated by ghsa, no CVSS score)
- Published: 2026-08-18
- Modified: 2026-08-18

## Affected versions

- github.com/centrifugal/centrifuge-go (Go): through 0.12.0

## Description

## Vulnerability Details

**Note on scope**: this vulnerability lives in `github.com/centrifugal/centrifuge-go`, the
official Go **client SDK** for connecting to a Centrifugo/centrifuge server — a fourth,
separate repository from `centrifugo`, `centrifuge`, and `protocol` (all covered by earlier
reports/advisories this session), with no private vulnerability reporting enabled and no
SECURITY.md of its own. Submitting through this working channel, consistent with
`centrifugal/protocol`'s own SECURITY.md, which states security reports for the ecosystem's
packages are handled through the `centrifugo` repository.

**Threat model note**: this is the inverse of a typical server-side finding. The party to
distrust here is a **malicious or compromised Centrifugo/centrifuge server**, or an on-path
attacker able to inject bytes into an unencrypted `ws://` connection — not an attacker
targeting a server. Any application (backend service, CLI tool, etc.) that embeds this SDK
to consume real-time data is affected.

**File**: `transport_websocket.go` (this repo), lines 127-176, `websocketTransport.reader`
**File**: `protocol.go` (this repo), lines 51-56, `newReplyDecoder`
**Root cause**: `github.com/centrifugal/protocol@v0.19.2`'s `decode.go`,
`(*ProtobufReplyDecoder).Decode` — this is the exact pre-fix dependency version
`centrifuge-go` currently pins (confirmed via go.sum hash match). This same bug in
`centrifugal/protocol` was already found and reported earlier this session (fixed upstream
in v0.20.0 before I could file a separate advisory for it there, since the fix predated my
report by ~12 days) — but `centrifuge-go`, as currently published, has not bumped past the
vulnerable v0.19.2, so it is a live, concretely-exploitable artifact today.

**CWE**: CWE-129 — Improper Validation of Array Index
**Severity**: High
**CVSS**: 6.5 — CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
(Scored from the perspective of the party this SDK must distrust — PR:N because no privilege
on the client application is needed, only control of, or a MITM position on, the server the
application is already configured to connect to.)

### Root Cause
```go
// protocol.go:51-56 (centrifuge-go)
func newReplyDecoder(enc protocol.Type, data []byte) protocol.ReplyDecoder {
    if enc == protocol.TypeJSON {
        return protocol.NewJSONReplyDecoder(data)
    }
    return protocol.NewProtobufReplyDecoder(data)
}
```
```go
// transport_websocket.go: reader() runs in a bare, unrecovered goroutine
go t.reader()
func (t *websocketTransport) reader() {
    ...
    for {
        _, data, err := t.conn.ReadMessage()   // raw bytes from the server
        ...
        decoder := newReplyDecoder(t.protocolType, data)
        for {
            reply, err := decoder.Decode()   // panics on malformed server data
            ...
```
```go
// centrifugal/protocol@v0.19.2/decode.go (pinned dependency, pre-fix)
func (d *ProtobufReplyDecoder) Decode() (*Reply, error) {
    if d.offset < len(d.data) {
        var c Reply
        l, n := binary.Uvarint(d.data[d.offset:])
        replyBytes := d.data[d.offset+n : d.offset+n+int(l)]   // no bounds check
        err := c.UnmarshalVT(replyBytes)
```

Every WebSocket message received from the server is decoded via this path (protobuf
subprotocol is the default: `dialer.Subprotocols = []string{"centrifuge-protobuf"}`). The
pinned decoder reads a length-prefix varint and immediately slices with no bounds check.
This happens inside `websocketTransport.reader()`, a bare goroutine spawned via
`go t.reader()`. This library has **zero `recover()` calls** anywhere in its non-test code
(confirmed via full-repo grep). An unrecovered panic in a goroutine is fatal to the entire
Go process, not just that goroutine or connection.

### Dynamic Confirmation (2026-08-16)
```go
func TestVuln101MaliciousServerReplyPanic(t *testing.T) {
    malformed := []byte{0x02} // claims 2 bytes follow, 0 present
    decoder := newReplyDecoder(protocol.TypeProtobuf, malformed)
    _, err := decoder.Decode()
}
```
A **single 1-byte malformed message** — the smallest possible WS frame carrying just a
length-prefix byte — reliably panics via this repo's own decoder wrapper, using the exact
dependency version it ships with:
```
panic: runtime error: slice bounds out of range [:3] with capacity 1
github.com/centrifugal/protocol.(*ProtobufReplyDecoder).Decode(...)  decode.go:208
github.com/centrifugal/centrifuge-go.TestVuln101MaliciousServerReplyPanic(...)
```

### Attack Scenario
1. An application embeds `centrifuge-go` to connect to a Centrifugo server (default protobuf
   subprotocol)
2. The server side is malicious, compromised, or MITM'd (unencrypted `ws://`, or an
   attacker-controlled TLS termination point)
3. That party sends a single malformed frame — e.g. a message whose first byte is a varint
   `0x02` with no further bytes present
4. `ProtobufReplyDecoder.Decode()` panics; the panic is unrecovered in `t.reader()`'s bare
   goroutine, crashing the **entire host application process**, not just the connection

### Impact
Full crash of any Go application embedding `centrifuge-go` with the protobuf subprotocol,
whenever the server side is malicious, compromised, or MITM-able. No action required from
the embedding application beyond normal connect/subscribe usage.

### Recommended Fix
1. **Primary**: bump the pinned `github.com/centrifugal/protocol` dependency from v0.19.2 to
   v0.20.0 or later, where `ProtobufReplyDecoder.Decode` already has the correct bounds
   check (fixed upstream in commit `1fc2374`, 2026-08-04). No consumer-side code changes
   needed — the fix doesn't alter any exported function signature.
2. **Defense-in-depth**: wrap `t.reader()` (and any other bare `go func`/`go t.X()` spawn
   point in this library) in a `recover()` that logs and cleanly disconnects rather than
   crashing the entire host process — a malformed frame from a misbehaving server should
   degrade to "this connection is broken," not "this whole program is dead."

### Verification
Dynamically confirmed via direct in-process invocation of this repo's own `newReplyDecoder`
wrapper, using the exact `centrifugal/protocol` v0.19.2 dependency this repo currently ships
— a single 1-byte crafted message reliably panics the decoder.

## References

- https://github.com/centrifugal/centrifugo/security/advisories/GHSA-98cg-m2cg-6xpr

Page: https://cve.now/GHSA-98CG-M2CG-6XPR

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