Below is a differential between the unpatched vulnerable code and the patched update, for reference.
--- a/wpforo/admin/listtables/Members.php
+++ b/wpforo/admin/listtables/Members.php
@@ -58,7 +58,7 @@
return ! empty( $usergroup['name'] ) ? esc_html( $usergroup['name'] ) : __( 'default', 'wpforo' );
case 'secondary_groupids':
- return implode( ', ', WPF()->usergroup->get_secondary_group_names( $item[ $column_name ] ) );
+ return esc_html( implode( ', ', WPF()->usergroup->get_secondary_group_names( $item[ $column_name ] ) ) );
case 'blog_posts':
return WPF()->member->blog_posts( $item['userid'] );
case 'blog_comments':
@@ -66,7 +66,7 @@
case 'online_time':
return ( $item['online_time'] ) ? wpforo_date_raw( $item['online_time'], 'datetime', false ) : '-';
default:
- return $item[ $column_name ];
+ return esc_html( (string) $item[ $column_name ] );
}
}
@@ -146,7 +146,7 @@
//Return the title contents
return sprintf(
'%1$s %2$s',
- /*$1%s*/ $item['userid'],
+ /*$1%s*/ (int) $item['userid'],
/*$2%s*/ $this->row_actions( $actions )
);
}
--- a/wpforo/classes/Forms.php
+++ b/wpforo/classes/Forms.php
@@ -1282,6 +1282,11 @@
$value = sanitize_text_field( $value );
} elseif( $type === 'textarea' ) {
$value = stripslashes( wpforo_kses( trim( (string) $value ), 'user_description' ) );
+ } elseif( $type === 'tinymce' ) {
+ // Rich-text fields (about, signature) keep post-level markup, but event
+ // handlers and scripts must not reach storage: these values are also read
+ // outside wpForo, e.g. by the core post-author-biography block.
+ $value = wpforo_kses( trim( (string) $value ), 'post' );
} elseif( $type === 'email' ) {
$value = sanitize_email( $value );
} elseif( $type === 'password' ) {
--- a/wpforo/classes/Members.php
+++ b/wpforo/classes/Members.php
@@ -653,6 +653,11 @@
'user_pass2',
'userid',
'ID',
+ 'display_name',
+ 'user_nicename',
+ 'user_url',
+ 'first_name',
+ 'last_name',
] as $reserved ) {
unset( $data['data'][ $reserved ] );
}
@@ -969,31 +974,29 @@
if( $check_permissions ) WPF()->perm->can_edit_user( $userid );
//User Fields
- if( wpfkey( $data, 'display_name' ) ) {
- $user_fields['display_name'] = $data['display_name'];
+ if( wpfkey( $data, 'display_name' ) && ( $display_name = sanitize_text_field( (string) $data['display_name'] ) ) !== '' ) {
+ $user_fields['display_name'] = $display_name;
$user_fields_types[] = '%s';
}
if( wpfkey( $data, 'user_email' ) ) {
$user_fields['user_email'] = $data['user_email'];
$user_fields_types[] = '%s';
}
- if( wpfkey( $data, 'user_nicename' ) ) {
- if( ! wpfval( $data, 'user_nicename' ) ) {
- $user_info = get_userdata( $userid );
- $data['user_nicename'] = sanitize_title( sanitize_user( $user_info->user_nicename, true ) );
- }
- $user_fields['user_nicename'] = $data['user_nicename'];
+ // Keep the current nicename when the new value sanitizes to nothing, so a
+ // non-Latin or markup-only input can't blank the profile URL.
+ if( wpfkey( $data, 'user_nicename' ) && ( $user_nicename = sanitize_title( sanitize_user( (string) $data['user_nicename'], true ) ) ) !== '' ) {
+ $user_fields['user_nicename'] = $user_nicename;
$user_fields_types[] = '%s';
- update_user_meta( $userid, 'nickname', $data['user_nicename'] );
+ update_user_meta( $userid, 'nickname', $user_nicename );
}
if( wpfkey( $data, 'first_name' ) ) {
- update_user_meta( $userid, 'first_name', $data['first_name'] );
+ update_user_meta( $userid, 'first_name', sanitize_text_field( (string) $data['first_name'] ) );
}
if( wpfkey( $data, 'last_name' ) ) {
- update_user_meta( $userid, 'last_name', $data['last_name'] );
+ update_user_meta( $userid, 'last_name', sanitize_text_field( (string) $data['last_name'] ) );
}
if( wpfkey( $data, 'user_url' ) ) {
- $user_fields['user_url'] = $data['user_url'];
+ $user_fields['user_url'] = esc_url_raw( (string) $data['user_url'] );
$user_fields_types[] = '%s';
}
@@ -1074,9 +1077,12 @@
$profile_fields_types[] = '%s';
}
if( wpfkey( $data, 'about' ) ) {
- $profile_fields['about'] = $member['about'];
+ // Callers that skip Forms::sanitize() (registration, imports) must not be
+ // able to store scripts here: WordPress renders this meta outside wpForo.
+ $about = wpforo_kses( (string) $member['about'], 'post' );
+ $profile_fields['about'] = $about;
$profile_fields_types[] = '%s';
- update_user_meta( $userid, 'description', $member['about'] );
+ update_user_meta( $userid, 'description', $about );
}
if( wpfkey( $data, 'occupation' ) ) {
$profile_fields['occupation'] = $member['occupation'];
--- a/wpforo/classes/Template.php
+++ b/wpforo/classes/Template.php
@@ -3061,12 +3061,13 @@
'<blockquote data-userid="%1$d" data-postid="%2$d" data-mention="%3$s"><div class="wpforo-post-quote-head">%4$s %5$s</div>',
$userid,
$postid,
- $mention,
- ( $posted_by ? sprintf( '<div class="wpforo-post-quote-author"><strong> %1$s: %2$s </strong></div>', wpforo_phrase( 'Posted by', false ), $posted_by ) : '' ),
+ // display_name comes from the WP profile and may contain quotes or markup.
+ esc_attr( $mention ),
+ ( $posted_by ? sprintf( '<div class="wpforo-post-quote-author"><strong> %1$s: %2$s </strong></div>', wpforo_phrase( 'Posted by', false ), esc_html( $posted_by ) ) : '' ),
( $postid ? sprintf(
'<div class="wpforo-post-quote-link"><a href="%1$s" title="%2$s">↑</a></div>',
- WPF()->post->get_url( $postid ),
- wpforo_phrase( 'go to original post', false )
+ esc_url( WPF()->post->get_url( $postid ) ),
+ esc_attr( wpforo_phrase( 'go to original post', false ) )
) : '' )
);
}, (string) $text );
--- a/wpforo/includes/hooks.php
+++ b/wpforo/includes/hooks.php
@@ -2279,6 +2279,11 @@
'user_pass2',
'userid',
'ID',
+ 'display_name',
+ 'user_nicename',
+ 'user_url',
+ 'first_name',
+ 'last_name',
] as $reserved ) {
unset( $data['data'][ $reserved ] );
}
@@ -2582,7 +2587,7 @@
$attach_html .= '<br/><div class="wpfa-item wpfa-file"><a class="attach_cant_view" style="cursor: pointer;"><span style="color: #666;">' . wpforo_phrase(
'Attachment',
false
- ) . ' : </span> ' . urldecode( basename( $match[2] ) ) . '</a></div>';
+ ) . ' : </span> ' . esc_html( urldecode( basename( $match[2] ) ) ) . '</a></div>';
}
}
if( $attach_html ) {
--- a/wpforo/wpforo.php
+++ b/wpforo/wpforo.php
@@ -5,7 +5,7 @@
* Description: WordPress Forum plugin. wpForo is the only AI powered forum solution for your community. Modern design and 5 forum layouts.
* Author: gVectors Team
* Author URI: https://gvectors.com/
-* Version: 3.2.4
+* Version: 3.2.5
* Requires at least: 5.2
* Requires PHP: 7.1
* Text Domain: wpforo
@@ -14,7 +14,7 @@
namespace wpforo;
-define( 'WPFORO_VERSION', '3.2.4' );
+define( 'WPFORO_VERSION', '3.2.5' );
//Exit if accessed directly
if( ! defined( 'ABSPATH' ) ) exit;