Repository navigation
fix: gate the forum HTTP API behind a toggle and require a staff caller - #68
Merged
Merged
Conversation
Backport of the upstream fix for GHSA-c6fp-f54c-6cv4 (openedx/forum 91d9b9f, the 0.4.x backport of 322ca14) to release-ulmo (LP-1391). The forum HTTP API under /forum/api/v1/ and /forum/api/v2/ is mounted on the LMS through the plugin url_config and authenticated no one, so an anonymous caller could read and delete discussion content and rename LMS user accounts. edx-platform calls forum.api in process, so nothing needs these routes over HTTP. - Don't route /forum/api/ unless FORUM_ENABLE_HTTP_API is True. The setting defaults to False, including when it is not defined. - Require a staff caller on every view through the ForumAPIView base class. - Move the fork-only ban views in views/bans.py (ban, unban, banned users, ban detail) onto ForumAPIView and drop their AllowAny. Upstream doesn't have these views, so the backport alone left them open. - Add upstream's test_permissions.py and test_urls.py. The permission test walks the URLconf, so it covers the ban routes too. Conflicts with the fork's telemetry imports were resolved by keeping both. The fork's version (0.7.4) is unchanged, and the changelog entry goes under Unreleased.
The forum HTTP API now requires a staff caller (GHSA-c6fp-f54c-6cv4), so the api_client fixture in tests/conftest.py logs in as a staff service account. tests/e2e/conftest.py overrode that fixture with an anonymous client, so every e2e request got a 403 and the e2e job failed with 57 failures and 14 errors. Remove the override so the e2e suite uses the authenticated fixture from tests/conftest.py. This is the change upstream made in openedx/forum 8149351.
abhalsod-sonata
approved these changes
Oct 20, 2026
abhalsod-sonata
left a comment
Member
There was a problem hiding this comment.
Approving. Checked against upstream 91d9b9f: permissions.py, views/base.py, both new test modules and the FORUM_ENABLE_HTTP_API toggle block are identical, and urls.py differs only by the fork's ban routes. No view under forum/ is left on plain APIView, AllowAny or a function view: all 27 routed views, including the four fork-only ban views, now inherit ForumAPIView, so a new view is protected by default. Routing defaults to off when the setting is absent, which is the right failure mode.
Alam-2U
approved these changes
Oct 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backports the upstream fix for GHSA-c6fp-f54c-6cv4 to
release-ulmo. It uses upstream's 0.4.x backport 91d9b9f (of 322ca14), which matches this fork's flatforum/layout.Ticket: https://2u-internal.atlassian.net/browse/LP-1391
Changes
/forum/api/v1/and/forum/api/v2/aren't routed unlessFORUM_ENABLE_HTTP_APIisTrue. It defaults toFalse, including when the setting isn't defined. edx-platform callsforum.apiin process, so discussions don't use these routes.ForumAPIViewbase class (forum/views/base.py,forum/permissions.py).views/bans.py(ban, unban, banned users, ban detail) now usesForumAPIView, andAllowAnyis removed. Upstream doesn't have these views, so the backport alone wouldn't cover them.tests/test_permissions.pyandtests/test_urls.py. The permission test walks the URLconf, so it covers the ban routes on v1 and v2. With the oldbans.py, 8 cases fail.tests/e2e/conftest.pyoverrodeapi_clientwith an anonymous client, so with the new permission every e2e request got a 403. The override is removed so e2e uses the staff-authenticated fixture fromtests/conftest.py. This is the same change as upstream openedx/forum 8149351.0.7.4, and the changelog entry goes under Unreleased.The setting will be pinned off explicitly in edx-internal for edge, stage and prod (separate PR).
Testing
Unit tests:
pytestpasses 598/598 on Python 3.12 and Django 5.2.manage.py check, pylint, pycodestyle/pydocstyle and mypy pass. black reports the same 2 files asrelease-ulmo(setup.py,tests/test_backends/test_mongodb/test_comments.py); this PR doesn't touch them.e2e:
tests/e2epasses 74/74 locally against the compose services (MongoDB, Elasticsearch, Meilisearch). Before the conftest fix, those tests failed with 403s, as in CI.Devstack: LMS on edx-platform
release-ulmo, with this branch installed editable.FORUM_ENABLE_HTTP_APITrueFalse(default)With the setting
False, I ran discussions through the discussion API the MFE uses (/api/discussion/v1/): create, edit and read a post; reply and nested comment; upvote; follow; pin/unpin; close/reopen; learner flag/unflag; ban, list banned and unban; search; delete. All 29 checks passed.Manual testing
curl -i http://localhost:18000/forum/api/v1/commentables/<course_id>/countsshould return 404.discussions.enable_discussion_bancourse flag).Merge checklist:
forum/settings/common.pyas a toggle annotation)