Tutor LMS 3.9.4's changelog reads, in full, "Fix: Security vulnerabilities." The diff that line covers is one call to esc_sql() wrapped around one argument to one function. The argument is $coupon_code. The helper that built the SQL underneath, QueryHelper::prepare_where_clause, is unchanged. Eighty-one other callers of the same helper across twenty-four files are unchanged. Three release tags from Themeum shipped on that helper before 3.9.7 on February 25, 2026 finally added a prepare_value() method that runs $wpdb->prepare() on every value the helper sees.
CVE-2025-13673: Tutor LMS Patched One Caller. The Helper Shipped Three More Releases.
vendor
pattern
cve
proof of concept
The dispatcher fires on every WordPress request
Tutor LMS registers one init action and routes every visitor through it. From classes/Tutor.php:
add_action( 'init', array( $this, 'init_action' ) );
public function init_action() {
$tutor_action = Input::sanitize_request_data( 'tutor_action' );
if ( '' !== $tutor_action ) {
do_action( 'tutor_action_' . $tutor_action );
}
}init runs on every WordPress page load. Logged in, logged out, REST, frontend, admin. If the request carries tutor_action, the plugin fires tutor_action_<value> as a WordPress action and dispatches to whichever handler subscribed. The dispatcher is the front door; the value of tutor_action chooses the room.
ecommerce/CheckoutController.php subscribes tutor_action_tutor_pay_now:
add_action( 'tutor_action_tutor_pay_now', array( $this, 'pay_now' ) );pay_now() reads coupon_code straight from $_POST through Tutor's array sanitizer, which routes string fields through WordPress's sanitize_text_field. sanitize_text_field strips tags, normalizes line endings, removes extra whitespace, and removes any octet that is not a printable ASCII character or a UTF-8 sequence. It does not touch single quotes. A ' in the request body arrives at the SQL layer intact. The sanitizer's name reads like a defense, but its contract is HTML safety, not SQL safety.
pay_now() also resolves an order owner before the coupon lookup runs:
$current_user_id = is_user_logged_in() ? get_current_user_id() : wp_rand();That line is explicit. The handler is designed to run for unauthenticated visitors and to manufacture a synthetic user identifier rather than reject the request. Themeum did not forget anonymous users; they shipped a code path for them.
The handler does check a nonce. The check is wp_verify_nonce( $_POST['_tutor_nonce'], 'tutor_nonce_action' ). For an anonymous visitor WordPress builds the nonce against user_id = 0 and session_token = '', and the same _tutor_nonce value is embedded in every frontend page Tutor renders, including / and the public /courses/ listing. The PoC at dinosn/CVE-2025-13673 harvests it with a one-line regex against the homepage body. The nonce is a CSRF token, not an authentication token, and an unauthenticated visitor can read it from the unauthenticated HTML the plugin serves them. Themeum wrote a guard that the dispatcher's own behavior nullifies.
So: an unauthenticated POST to / with tutor_action=tutor_pay_now, _tutor_nonce=<harvested>, and coupon_code=<payload> reaches the coupon lookup. The coupon lookup reaches a helper. The helper builds the SQL.
The helper concatenates the value. The phpcs:disable annotation admits it.
helpers/QueryHelper.php defines prepare_where_clause. Below is the default branch of the operator switch that handles =, !=, <, >, <=, >=, LIKE, NOT LIKE, and <>. Every coupon lookup in the codebase lands here.
default:
$val = is_numeric( $val ) ? $val : "'" . $val . "'";
$clause = array( $field, $operator, $val );And the fallback at the bottom of the same function, for non-array operator forms:
$value = is_numeric( $value ) ? $value : "'" . $value . "'";There is no escape call. There is no $wpdb->prepare(). The branch decides between two presentations of the value: a bare number, or the value wrapped in single quotes. The wrap is the entire defense, and a single quote inside $val ends the literal early and starts arbitrary SQL.
The same file's get_row() consumes that clause and threads it into a $wpdb->prepare() call. The phpcs annotation on the next line is the part that tells you the author knew:
$where_clause = self::prepare_where_clause( $where );
/*phpcs:disable*/
$query = $wpdb->prepare(
"SELECT * FROM {$table} WHERE {$where_clause} ORDER BY {$order_by} {$order} LIMIT %d",
1
);/*phpcs:disable*/ exists to silence the WordPress coding-standards linter, which flags interpolated variables inside $wpdb->prepare() because that pattern is the canonical SQL injection in WordPress plugins. The WordPress Plugin Review Team rejects submissions for exactly this. Themeum's developer ran the linter, the linter said this is dangerous, and the developer turned the linter off rather than change the code. The comment is a signature. It dates the choice.
The same annotation appears above get_all, get_count, insert, update, delete, and several other helper methods in the same file. Each one calls prepare_where_clause, each one passes the result into an interpolated $wpdb->prepare() template, and each one silences the linter that would otherwise refuse to ship.
grep -r 'QueryHelper::' tutor/ returns eighty-two read/write call sites across twenty-four files in 3.9.3. They include CouponModel::get_coupon, OrderModel::get_orders, CartModel::get_cart, EnrollmentModel::get_enrollments, QuizModel::get_quiz_attempts, and every model in tutor/models/ that wraps a wp_tutor_* table. Every one of them trusts prepare_where_clause to produce a safe fragment. The pattern that produces the fragment trusts its caller to never pass a quote, and the caller's caller, and so on, up to a coupon_code field that the unauthenticated visitor controls.
The 3.9.4 patch was at one caller. The helper was unchanged.
3.9.4 shipped on December 18, 2025. The changelog entry, in full:
Fix: Security vulnerabilities
The diff against 3.9.3 in the coupon path is a single line in models/CouponModel.php, inside get_coupon_details_for_checkout:
- 'coupon_code' => $coupon_code,
+ 'coupon_code' => esc_sql( $coupon_code ),esc_sql() is a thin wrapper around $wpdb->_real_escape(), which calls MySQL's real-escape on a string. It escapes the single quote that breaks out of the literal. Wrapped around $coupon_code in CouponModel::get_coupon_details_for_checkout, it closes the exact PoC path the public advisory named.
It also leaves QueryHelper::prepare_where_clause exactly as it was. Eighty-one other callers across twenty-four files are still routing user-influenced values through a helper that concatenates them into SQL with single quotes and nothing else. The next disclosure on the helper would not have to find a new bug; it would have to find a new caller. Many of those callers take values from authenticated form posts, REST routes, and AJAX actions, where the only difference from the coupon path is the source of the string.
The 3.9.4 diff is the smallest possible response to the advisory text. It treats CVE-2025-13673 as a bug in get_coupon_details_for_checkout rather than a bug in prepare_where_clause. The advisory titled it the former; the source code shows it is the latter.
esc_sql() escaped one caller. prepare_where_clause built queries for eighty-two.
Three release tags shipped on the same helper
After 3.9.4 came 3.9.5 on January 8, 2026:
Fix: Fixed security issues
And 3.9.6 on January 28, 2026:
Fix: Added a capability check to the coupon details AJAX request.
git diff v3.9.4 v3.9.6 -- helpers/QueryHelper.php returns zero bytes. The helper file is byte-identical across the three releases that followed the original advisory. The 3.9.6 capability check sits on top of wp_ajax_tutor_apply_coupon, the authenticated UNION-based vector. Logged-in users could call that endpoint, the handler called CouponModel::get_coupon, get_coupon called QueryHelper::get_row, get_row called prepare_where_clause, and the response reflected the result rows back as JSON with two columns the attacker could populate via UNION SELECT. The 3.9.6 patch adds a current_user_can gate at the AJAX boundary. The query the gate now protects is still built by the same helper, with the same concatenation, with the same /*phpcs:disable*/ above it. A subscriber-level account, which sites with open registration grant freely, still passed the gate.
The gap between the changelog line "Fix: Security vulnerabilities" and the changelog line that finally addresses SQL injection by name is sixty-nine days and three release tags. Across those three tags, Themeum shipped capability checks, frontend tweaks, payment-gateway adjustments, and other plugin work on top of a helper that the project's own linter had flagged. The patches in that window do not look like a project ignoring the issue; they look like a project that believed the issue was the call site.
The 3.9.7 patch is at the helper
3.9.7 shipped on February 25, 2026:
Fix: Resolved SQL injection security vulnerabilities to enhance system security.
The diff in helpers/QueryHelper.php adds a new private method:
private static function prepare_value( $value ) {
global $wpdb;
if ( is_numeric( $value ) ) {
return $value;
}
return $wpdb->prepare( '%s', $value );
}And the default branch of prepare_where_clause becomes:
- $val = is_numeric( $val ) ? $val : "'" . $val . "'";
+ $val = self::prepare_value( $val );
$clause = array( $field, $operator, $val );$wpdb->prepare( '%s', $value ) is the WordPress idiom for getting a properly quoted, properly escaped SQL string literal for an arbitrary input. It returns the value with single quotes around it and any embedded quotes escaped against the current $wpdb connection charset. Routing every non-numeric value through prepare_value fixes the helper for all eighty-two call sites at once, including the one the 3.9.4 patch had wrapped by hand and including the seventy-eight that nobody had publicly named. The trailing else and the make_clause path in the same file get the same treatment in the same commit.
The /*phpcs:disable*/ block in get_row stays, because the table and operator interpolations are still there. The value side no longer carries attacker-controlled SQL. The annotation is now narrower than it was, but it still marks the same admission.
This is the patch the 3.9.4 changelog implied. It arrived in the fourth release after the disclosure.
QueryHelper is a design-debt driver
There is a class of bug substrate where a single helper produces many call sites that share the same defect, and each disclosure asks the project to patch the symptom at the call site rather than the helper. Tutor LMS picked the call-site patch three times in a row before picking the helper patch. The patches at the call sites all said "Fix: Security vulnerabilities." The patch at the helper said "Resolved SQL injection."
The shape recurs. Ech0's CVE-2026-35037 had a SendRequest/SendSafeRequest pair where the parameterized helper existed but the unsafe one kept getting called; the disclosure was filed against a specific caller, and the next caller was already queued up. WordPress plugin history is full of prepare_where_clause siblings: a project writes a "convenience" SQL builder that takes an associative array of field-value pairs, the builder concatenates the values, every model in the project uses the builder, and an audit later turns the project's own catalog into the attack surface. The disclosures get filed one at a time, against get_coupon, then get_order, then get_enrollment.
We tag posts like this with Design Debt Driver. The defender frame is: when you find one of these, the disclosure is not the bug. The helper is the bug. Patches at the call site buy time. Patches at the helper close the class. The signal that you have one is usually inside the source rather than in the advisory: a builder function with no parameter binding, a linter suppression above the line that interpolates the builder's output, a count of call sites in the dozens.
The /*phpcs:disable*/ line in helpers/QueryHelper.php is what design debt looks like in source. It is a developer telling the project's own quality gate to stop complaining about a pattern the gate is correct to complain about. Three releases shipped over that comment. CVE-2025-13673 is the disclosure that named the pattern the comment was hiding.
The 3.9.4 changelog called it a security fix. The 3.9.7 changelog called it SQL injection.