Skip to content

fix: extend course-review authz bypass to embedded library asset URLs - #39248

Draft
efortish wants to merge 1 commit into
openedx:masterfrom
eduNEXT:ks/issue-473-library-asset-authz-bypass
Draft

efortish wants to merge 1 commit into
openedx:masterfrom
eduNEXT:ks/issue-473-library-asset-authz-bypass

Conversation

@efortish

@efortish efortish commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Description

Builds on #39107 (this PR depends on it) to close the remaining gap in the course-review AuthZ bypass. Even after #39107 fixed the surrounding block and container endpoints, static assets (e.g., images) referenced by reviewed library content still returned 403 Forbidden for Course Auditors.

Root Cause

Asset URLs are generated during content rendering by OpenedXContentRuntime._absolute_url_for_asset() and resolved directly by the browser. Since these requests are not controlled by the frontend, there was no way to attach downstream_block_id at request time.

Solution

Propagate downstream_block_id through the rendering pipeline so asset requests can be authorized against the downstream course context:

  • Runtime API: load_block and get_runtime (openedx/core/djangoapps/xblock/api.py) now accept downstream_block_id and pass it to the runtime.
  • Block rendering: embed_block_view forwards the existing downstream_block_id query parameter to load_block, reusing the context already used by its own authorization bypass check.
  • Asset URL generation: OpenedXContentRuntime stores the downstream block ID and appends it as a query parameter to every asset URL it generates.
  • Asset authorization: get_component_version_asset, shared by LibraryComponentAssetView and LibraryComponentDraftAssetView, resolves the component version to its usage key via api.library_component_usage_key and applies the same user_has_course_permission_for_upstream check used by the other endpoints. This ensures assets are served only when the component is actually linked to the specified downstream context.

Fixes openedx/openedx-authz#473

Testing

  • Added LibraryComponentAssetAuthzBypassTest to test_embed_block.py, covering:
    • Asset access is allowed when the component is linked to the specified downstream block.
    • Asset access is denied when downstream_block_id is missing.
    • Asset access is denied when an unrelated downstream block is specified.
    • Existing behavior is preserved for users with direct library access.
  • Ran the full xblock, content_libraries, content_staging clipboard, and content/search test suites locally: 416 passed, 9 skipped, 0 failed.
  • ruff, pylint, and lint-imports all pass.

Dependencies

Depends on #39107, which must be merged before this PR can be merged.

Deadline

None.

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Oct 16, 2026
@openedx-webhooks

Copy link
Copy Markdown

Thanks for the pull request, @efortish!

This repository is currently maintained by @openedx/wg-maintenance-openedx-platform-oncall.

Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review.

🔘 Get product approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.
🔘 Provide context

To help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads
🔘 Get a green build

If one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green.

🔘 Update the status of your PR

Your PR is currently marked as a draft. After completing the steps above, update its status by clicking "Ready for Review", or removing "WIP" from the title, as appropriate.


Where can I find more information?

If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources:

When can I expect my changes to be merged?

Our goal is to get community contributions seen and reviewed as efficiently as possible.

However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

Static assets referenced inside reviewed library content (images, etc.)
still returned 403 for a Course Auditor, even after openedx#39107, because the
asset URL is generated during content rendering (OpenedXContentRuntime's
_absolute_url_for_asset) and resolved directly by the browser, not
through a request the frontend controls.

Thread downstream_block_id from embed_block_view into the runtime via
load_block/get_runtime, so _absolute_url_for_asset can bake it into
every asset URL it generates. LibraryComponentAssetView (used by both
the published and draft asset endpoints) now does the same
user_has_course_permission_for_upstream check the other endpoints use,
resolving the component version back to its usage key via
library_component_usage_key to verify the downstream is actually
linked to it.

Fixes openedx-authz#473.
@efortish
efortish force-pushed the ks/issue-473-library-asset-authz-bypass branch from 723005d to 0dbfd34 Compare November 13, 2026 17:22

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

open-source-contribution PR author is not from Axim or 2U

Projects

Status: Waiting on Author

Development

Successfully merging this pull request may close these issues.

Library asset URLs (images, etc.) embedded in reviewed content still 403 for course_id bypass

2 participants