Track vulnerabilities like this one.
Sign up free to get alerted when software you use is affected.
8.1
Mercure may send private updates to unauthorized users
published 7 months ago
Summary
The Mercure service can mix up its internal cache when topic names contain underscores, allowing an attacker to receive or block messages meant for others. Upgrade to Mercure version 0.22.0 or newer to fix the issue, or turn off the topic selector cache (set it to -1 or 0) if you cannot upgrade right away.
What to do
- Update dunglas github.com/dunglas/mercure to version 0.22.0.
Affected software
| Ecosystem | Vendor | Product | Affected versions |
|---|---|---|---|
| Go | dunglas | github.com/dunglas/mercure |
< 0.22.0 Fix: upgrade to 0.22.0
|
Original advisory text
mercure has Topic Selector Cache Key Collision
### Impact
A cache key collision vulnerability in `TopicSelectorStore` allows an attacker to poison the match result cache, potentially causing private updates to be delivered to unauthorized subscribers or blocking delivery to authorized ones.
The cache key was constructed by concatenating the topic selector and topic with an underscore separator:
```go
k = "m_" + topicSelector + "_" + topic
```
Because both topic selectors and topics can contain underscores, two distinct pairs can produce the same key:
```
selector="foo_bar" topic="baz" → key: "m_foo_bar_baz"
selector="foo" topic="bar_baz" → key: "m_foo_bar_baz"
```
An attacker who can subscribe to the hub or publish updates with crafted topic names can exploit this to bypass authorization checks on private updates.
### Patches
The vulnerability is fixed by replacing string-encoded cache keys with typed Go struct keys that are inherently collision-free:
```go
type matchCacheKey struct {
topicSelector string
topic string
}
```
The internal `TopicSelectorStoreCache` interface and sharded cache abstraction have also been removed in favor of a single typed otter cache.
Users should upgrade to version **0.22.0** or later.
### Workarounds
Disable the topic selector cache by setting `topic_selector_cache` to `-1` in the Caddyfile, or by passing a cache size of `0` when using the library directly. This eliminates the vulnerability at the cost of reduced performance.
A cache key collision vulnerability in `TopicSelectorStore` allows an attacker to poison the match result cache, potentially causing private updates to be delivered to unauthorized subscribers or blocking delivery to authorized ones.
The cache key was constructed by concatenating the topic selector and topic with an underscore separator:
```go
k = "m_" + topicSelector + "_" + topic
```
Because both topic selectors and topics can contain underscores, two distinct pairs can produce the same key:
```
selector="foo_bar" topic="baz" → key: "m_foo_bar_baz"
selector="foo" topic="bar_baz" → key: "m_foo_bar_baz"
```
An attacker who can subscribe to the hub or publish updates with crafted topic names can exploit this to bypass authorization checks on private updates.
### Patches
The vulnerability is fixed by replacing string-encoded cache keys with typed Go struct keys that are inherently collision-free:
```go
type matchCacheKey struct {
topicSelector string
topic string
}
```
The internal `TopicSelectorStoreCache` interface and sharded cache abstraction have also been removed in favor of a single typed otter cache.
Users should upgrade to version **0.22.0** or later.
### Workarounds
Disable the topic selector cache by setting `topic_selector_cache` to `-1` in the Caddyfile, or by passing a cache size of `0` when using the library directly. This eliminates the vulnerability at the cost of reduced performance.
References
- https://github.com/dunglas/mercure/security/advisories/GHSA-hwr4-mq23-wcv5 URL
- https://nvd.nist.gov/vuln/detail/CVE-2026-39972 Vendor Advisory
- https://github.com/dunglas/mercure/commit/4964a69be904fd61e35b5f1e691271663b6fdd... URL
- https://github.com/dunglas/mercure Product
- https://github.com/dunglas/mercure/releases/tag/v0.22.0 URL
Internet-facing
60 days
Internal
At next upgrade
- Not known to be exploited
- Needs hands-on effort to exploit (estimated)
- Gives an attacker partial control (estimated)
Type
CWE-1289Improper Validation of Unsafe Equivalence in Input
Timeline
Published8 Apr 2026
Updated10 Sep 2026
First seen8 Apr 2026
Sources
GHSA-hwr4-mq23-wcv5 · OSV
Track software like this
Free during beta