Security Issue Fixes for 3.9.4 #2255
Open
+15
−11
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.
Security Issue Fix for 3.9.4
Issue 1
Inside
CouponControllerclass for both ajax methodbulk_action_handlerandcoupon_permanent_deletethere is a check for user capability however the error message is not returned, the methodtutor_utils()->error_message()is called but not returned thus it is not returning from the methodsTo fix this i have use the method
tutor_utils()->check_current_user_capability()which correctly checks user capability and returns a json error if unauthorized.Issue 2
On the
pay_nowaction which is called during checkout you can inject SQL on thecoupon_codeargument when passing the form data during checkoutThis in-turn runs a SQL query when trying to query the data of the coupon code by calling the
get_couponmethod insideCouponModelclassThis calls the
QueryHelper::get_rowmethod which takes a where clause, and when preparing the where clause the malicious SQL code gets added.To fix this i have put coupon_code inside an
esc_sqlinsideget_coupon_details_for_checkoutmethod which calls theget_couponmethod and passes the coupon_codeIssue 3
On the
tutor_order_detailsaction the method it calls has nonce check but no capability checkAfter looking over everything this action was called i have found out that it is only used for admin users not any other users
So to fix it i added
tutor_utils()->check_current_user_capability()method so that only admin can view the order detailsIssue 4
On
mark_course_complete()method no check was provided whether user is enrolled, allowing any user to mark course as complete even if it is paid courseTo fix it added a check if user is enrolled using
tutor_utils()->is_enrolled(), if not then exit from the functionIssue 5
On
course_enrollment()method there is no check if the course is purchasable allowing user to enroll in course with ajax call.To fix this i added the
tutor_utils()->is_course_purchasable()check to check if user is need to purchase the course before enrollment