Skip to content

Commit 44f6bc5

Browse files
committed
Fix an authenticated (Contributor) SQL Injection issue
1 parent fc630cf commit 44f6bc5

File tree

5 files changed

+13
-9
lines changed

5 files changed

+13
-9
lines changed

core/class-db-helpers.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ public static function get_db_index ($db_name) {
220220
* @since 9.0.8
221221
*/
222222
public static function validate_qualifier ($input, $default = '') {
223-
if ( preg_match("#^[a-zA-Z0-9 \.,_\]]+$#", $input) ) {
223+
if ( preg_match("#^[a-zA-Z0-9 \.,`_\]]+$#", $input) ) {
224224
return $input;
225225
} else {
226226
return $default;

core/class-db-options.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ function get_tp_option($var, $category = 'system') {
9999
*/
100100
function get_tp_options($category, $order = "`setting_id` DESC", $output_type = OBJECT) {
101101
global $wpdb;
102-
$order = esc_sql($order);
102+
103+
$order = TP_DB_Helpers::validate_qualifier($order);
103104
$result = $wpdb->get_results(
104105
$wpdb->prepare( "SELECT * FROM " . TEACHPRESS_SETTINGS . " WHERE `category` = %s ORDER BY " . $order, $category ), $output_type
105106

core/class-update.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -895,8 +895,8 @@ private static function rename_table($oldname, $newname) {
895895

896896
global $wpdb;
897897
// Check if the old table exists
898-
if( $wpdb->get_var("SHOW TABLES LIKE '" . esc_sql($oldname) . "'") == esc_sql($oldname) ) {
899-
$wpdb->query('RENAME TABLE ' . esc_sql($oldname) . ' TO ' . esc_sql($newname) . '');
898+
if( $wpdb->get_var("SHOW TABLES LIKE '" . TP_DB_Helpers::validate_qualifier($oldname) . "'") == TP_DB_Helpers::validate_qualifier($oldname) ) {
899+
$wpdb->query('RENAME TABLE ' . TP_DB_Helpers::validate_qualifier($oldname) . ' TO ' . TP_DB_Helpers::validate_qualifier($newname) . '');
900900
return true;
901901
}
902902
return false;

readme.txt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ License URI: https://www.gnu.org/licenses/gpl-2.0.html
66
Requires at least: 3.9
77
Tested up to: 6.7.2
88
Requires PHP: 7.0
9-
Stable tag: 9.0.11
9+
Stable tag: 9.0.12
1010

1111
Manage your publications with teachPress
1212

@@ -124,18 +124,21 @@ Please note the [teachPress 6.0 Upgrade Information](https://mtrv.wordpress.com/
124124

125125
== Changelog ==
126126

127+
= 9.0.12 =
128+
* Bugfix: Fix an authenticated (Contributor) SQL Injection issue
129+
127130
= 9.0.11 (22.03.2025) =
128131
* Bugfix: Change used gettext functions
129132

130133
= 9.0.10 (20.03.2025) =
131-
* Bugfix: Fixes another CSRF vulnerability in tp import dialog
134+
* Bugfix: Fixes another CSRF vulnerability in tp import dialog (CVE-2025-1320) (Thanks to Krzysztof Zając for reporting)
132135

133136
= 9.0.9 (11.03.2025)
134137
* Bugfix: Fix space handling in bibtex keys within publication exists check (#267)
135138
* Bugfix: Unknown column 'r.name' in 'where clause' error in function TP:Authors::get_authors() (#262)
136139

137140
= 9.0.8 (25.02.2025) =
138-
* Bugfix: Fix an authenticated (Contributor) SQL Injection issue (Thanks to truonghuuphuc for reporting)
141+
* Bugfix: Fix an authenticated (Contributor) SQL Injection issue (CVE-2025-1321 ) (Thanks to Krzysztof Zając for reporting)
139142

140143
= 9.0.7 (18.01.2025) =
141144
* New: Meta keys search to shortcodes added (Thanks to Juma7C9) (#259)

teachpress.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Description: Powerful publication management for WordPress
66
* Author: Michael Winkler
77
* Author URI: http://mtrv.wordpress.com/
8-
* Version: 9.0.11
8+
* Version: 9.0.12
99
* Requires at least: 3.9
1010
* Text Domain: teachpress
1111
* Domain Path: /languages
@@ -219,7 +219,7 @@ function tp_show_screen_options($current, $screen) {
219219
* @return string
220220
*/
221221
function get_tp_version() {
222-
return '9.0.11';
222+
return '9.0.12';
223223
}
224224

225225
/**

0 commit comments

Comments
 (0)