Skip to content

Fix: unauthorized WooCommerce product association on course create/update - #3276

Open
saadman30 wants to merge 3 commits into
4.3.0from
fix/wc-product-auth-course-api
Open

saadman30 wants to merge 3 commits into
4.3.0from
fix/wc-product-auth-course-api

Conversation

@saadman30

@saadman30 saadman30 commented Dec 1, 2026 •

Copy link
Copy Markdown
Collaborator

ClickUp ticket link:
https://app.clickup.com/t/9018365849/z8zyy1tvwa

Tutor Pro PR
https://github.com/themeum/tutor-pro/pull/2042

Summary

  • Enforce WooCommerce product ownership when instructors create or update courses via REST and Course Builder.
  • Pro REST CourseController now uses validate_price_for_update() on update, and guards direct _tutor_course_product_id writes.
  • Core validate_price() rejects products the current user is not authorized to use (create path), aligning with is_valid_wc_product_author().

Problem

Instructors could submit another instructor’s or an admin’s standalone WC product_id through:

  • PUT /tutor/v1/courses/{id}
  • POST /tutor/v1/courses
    The API accepted the request and saved the unauthorized ID in _tutor_course_product_id because REST relied on validate_price() (no ownership check) and update wrote the meta directly.

Solution

  • Core (Course.php): authorize submitted WC products during create validation; clarify create-time author checks (course_id = 0).
  • Pro (CourseController.php): validate product ownership on update; skip unauthorized product meta writes.
  • Added regression coverage for helpers, REST, and builder AJAX create/update.

@saadman30 saadman30 self-assigned this Dec 1, 2026
@saadman30 saadman30 added the 4.3.0 Tutor v4.3.0 label Dec 1, 2026
@saadman30
saadman30 marked this pull request as ready for review December 2, 2026 05:01
@saadman30
saadman30 requested review from harunollyo and shewa12 and removed request for harunollyo December 2, 2026 05:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

4.3.0 Tutor v4.3.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant