Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

CVE-2026-25742: Restrict topic access when spectator access is disabled.

Sahil Batra6d37f2b07cf2
diff --git a/zerver/lib/streams.py b/zerver/lib/streams.py
index 80625a69464..5fb935f4ed9 100644
--- a/zerver/lib/streams.py
+++ b/zerver/lib/streams.py
@@ -16,6 +16,7 @@ from zerver.lib.exceptions import (
ChannelExistsError,
IncompatibleParametersError,
JsonableError,
+ MissingAuthenticationError,
OrganizationOwnerRequiredError,
)
from zerver.lib.stream_subscription import (
@@ -1072,6 +1073,9 @@ def access_stream_by_name(
def access_web_public_stream(stream_id: int, realm: Realm) -> Stream:
+ if not realm.web_public_streams_enabled():
+ raise MissingAuthenticationError
+
error = _("Invalid channel ID")
try:
stream = get_stream_by_id_in_realm(stream_id, realm)
diff --git a/zerver/tests/test_message_topics.py b/zerver/tests/test_message_topics.py
index fc436188cf6..2324b554046 100644
--- a/zerver/tests/test_message_topics.py
+++ b/zerver/tests/test_message_topics.py
@@ -4,6 +4,7 @@ from unittest import mock
import orjson
from django.utils.timezone import now as timezone_now
+from zerver.actions.realm_settings import do_set_realm_property
from zerver.actions.streams import do_change_stream_permission, do_deactivate_stream
from zerver.actions.user_topics import do_set_user_topic_visibility_policy
from zerver.lib.events import ClientCapabilities, do_events_register
@@ -189,6 +190,12 @@ class TopicHistoryTest(ZulipTestCase):
],
)
+ do_set_realm_property(iago.realm, "enable_spectator_access", False, acting_user=None)
+ result = self.client_get(endpoint)
+ self.assert_json_error(
+ result, "Not logged in: API authentication or user session required", status_code=401
+ )
+
def test_get_topics_non_web_public_stream_web_public_request(self) -> None:
stream = get_stream("Verona", self.example_user("iago").realm)
endpoint = f"/json/users/me/{stream.id}/topics"