-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 NEFARIOUSPLAN-CANONICAL-V1 {"body_md":"## The dispatcher fires on every WordPress request\n\nTutor LMS registers one `init` action and routes every visitor through it. From `classes/Tutor.php`:\n\n```php\nadd_action( 'init', array( $this, 'init_action' ) );\n\npublic function init_action() {\n $tutor_action = Input::sanitize_request_data( 'tutor_action' );\n if ( '' !== $tutor_action ) {\n do_action( 'tutor_action_' . $tutor_action );\n }\n}\n```\n\n`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_` as a WordPress action and dispatches to whichever handler subscribed. The dispatcher is the front door; the value of `tutor_action` chooses the room.\n\n`ecommerce/CheckoutController.php` subscribes `tutor_action_tutor_pay_now`:\n\n```php\nadd_action( 'tutor_action_tutor_pay_now', array( $this, 'pay_now' ) );\n```\n\n`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.\n\n`pay_now()` also resolves an order owner before the coupon lookup runs:\n\n```php\n$current_user_id = is_user_logged_in() ? get_current_user_id() : wp_rand();\n```\n\nThat 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.\n\nThe 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.\n\nSo: an unauthenticated POST to `/` with `tutor_action=tutor_pay_now`, `_tutor_nonce=`, and `coupon_code=` reaches the coupon lookup. The coupon lookup reaches a helper. The helper builds the SQL.\n\n## The helper concatenates the value. The phpcs:disable annotation admits it.\n\n`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.\n\n```php\ndefault:\n $val = is_numeric( $val ) ? $val : \"'\" . $val . \"'\";\n $clause = array( $field, $operator, $val );\n```\n\nAnd the fallback at the bottom of the same function, for non-array operator forms:\n\n```php\n$value = is_numeric( $value ) ? $value : \"'\" . $value . \"'\";\n```\n\nThere 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.\n\nThe 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:\n\n```php\n$where_clause = self::prepare_where_clause( $where );\n/*phpcs:disable*/\n$query = $wpdb->prepare(\n \"SELECT * FROM {$table} WHERE {$where_clause} ORDER BY {$order_by} {$order} LIMIT %d\",\n 1\n);\n```\n\n`/*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.\n\nThe 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.\n\n`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.\n\n## The 3.9.4 patch was at one caller. The helper was unchanged.\n\n3.9.4 shipped on December 18, 2025. The changelog entry, in full:\n\n> Fix: Security vulnerabilities\n\nThe diff against 3.9.3 in the coupon path is a single line in `models/CouponModel.php`, inside `get_coupon_details_for_checkout`:\n\n```diff\n- 'coupon_code' => $coupon_code,\n+ 'coupon_code' => esc_sql( $coupon_code ),\n```\n\n`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.\n\nIt 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.\n\nThe 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.\n\nesc_sql() escaped one caller. prepare_where_clause built queries for eighty-two.\n\n## Three release tags shipped on the same helper\n\nAfter 3.9.4 came 3.9.5 on January 8, 2026:\n\n> Fix: Fixed security issues\n\nAnd 3.9.6 on January 28, 2026:\n\n> Fix: Added a capability check to the coupon details AJAX request.\n\n`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.\n\nThe 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.\n\n## The 3.9.7 patch is at the helper\n\n3.9.7 shipped on February 25, 2026:\n\n> Fix: Resolved SQL injection security vulnerabilities to enhance system security.\n\nThe diff in `helpers/QueryHelper.php` adds a new private method:\n\n```php\nprivate static function prepare_value( $value ) {\n global $wpdb;\n if ( is_numeric( $value ) ) {\n return $value;\n }\n return $wpdb->prepare( '%s', $value );\n}\n```\n\nAnd the default branch of `prepare_where_clause` becomes:\n\n```diff\n- $val = is_numeric( $val ) ? $val : \"'\" . $val . \"'\";\n+ $val = self::prepare_value( $val );\n $clause = array( $field, $operator, $val );\n```\n\n`$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.\n\nThe `/*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.\n\nThis is the patch the 3.9.4 changelog implied. It arrived in the fourth release after the disclosure.\n\n## QueryHelper is a design-debt driver\n\nThere 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.\"\n\nThe 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`.\n\nWe tag posts like this with [Design Debt Driver](/patterns/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.\n\nThe `/*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.\n\nPoC: [dinosn/CVE-2025-13673](https://github.com/dinosn/CVE-2025-13673)","closing_line":"The 3.9.4 changelog called it a security fix. The 3.9.7 changelog called it SQL injection.","hook_md":"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.","post_id":456,"slug":"tutor-lms-cve-2025-13673-helper-shipped-three-more-releases","title":"CVE-2025-13673: Tutor LMS Patched One Caller. The Helper Shipped Three More Releases.","type":"initial","unreadable_sentence":"esc_sql() escaped one caller. prepare_where_clause built queries for eighty-two."} -----BEGIN PGP SIGNATURE----- iHUEARYIAB0WIQRf0htP5+SjynlxywneZjl4jgkQJgUCawMvsAAKCRDeZjl4jgkQ JtzXAQCOKA6XRVjDkeRWzXdBMHPEXAzuj3YCsCfReMl+EvFHAQEA1+WLN+DFGnVD VWTvV7vekXFqYMdgvapxNJ9hc8xNvwM= =oGeT -----END PGP SIGNATURE-----