Skip to content

Commit 3c7a27c

Browse files
authored
Merge pull request #685 from Automattic/fix/unauthenticated-ajax-vulnerability
Fix the unathenticated vulnerability for ajax/rest endpoints
2 parents 4284d1e + 20ba9fe commit 3c7a27c

File tree

5 files changed

+12
-7
lines changed

5 files changed

+12
-7
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Changelog
22

3+
## 1.9.7
4+
* Adds a capability check to the preview, authors and hashtag endpoint to prevent unauthenticated calls (#685)
5+
36
## 1.9.6
47

58
* Revert #597, restoring `get_fields_for_render()` that is being used in some implementations (#639)

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Requires at least: 4.4
77
* Requires PHP: 5.6
88
* Tested up to: 4.9.8
9-
* Stable tag: 1.9.6
9+
* Stable tag: 1.9.7
1010
* License: GPLv2 or later
1111
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
1212

classes/class-wpcom-liveblog-rest-api.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,12 +180,12 @@ public static function register_routes() {
180180
array(
181181
'methods' => WP_REST_Server::CREATABLE,
182182
'callback' => array( __CLASS__, 'format_preview_entry' ),
183+
'permission_callback' => array( 'WPCOM_Liveblog', 'current_user_can_edit_liveblog' ),
183184
'args' => array(
184185
'entry_content' => array(
185186
'required' => true,
186187
),
187188
),
188-
'permission_callback' => '__return_true',
189189
)
190190
);
191191

@@ -205,12 +205,12 @@ public static function register_routes() {
205205
array(
206206
'methods' => WP_REST_Server::READABLE,
207207
'callback' => array( __CLASS__, 'get_authors' ),
208+
'permission_callback' => array( 'WPCOM_Liveblog', 'current_user_can_edit_liveblog' ),
208209
'args' => array(
209210
'term' => array(
210211
'required' => false,
211212
),
212213
),
213-
'permission_callback' => '__return_true',
214214
)
215215
);
216216

@@ -230,12 +230,12 @@ public static function register_routes() {
230230
array(
231231
'methods' => WP_REST_Server::READABLE,
232232
'callback' => array( __CLASS__, 'get_hashtag_terms' ),
233+
'permission_callback' => array( 'WPCOM_Liveblog', 'current_user_can_edit_liveblog' ),
233234
'args' => array(
234235
'term' => array(
235236
'required' => false,
236237
),
237238
),
238-
'permission_callback' => '__return_true',
239239
)
240240
);
241241

liveblog.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Plugin Name: Liveblog
55
* Plugin URI: http://wordpress.org/extend/plugins/liveblog/
66
* Description: Empowers website owners to provide rich and engaging live event coverage to a large, distributed audience.
7-
* Version: 1.9.6
7+
* Version: 1.9.7
88
* Author: WordPress.com VIP, Big Bite Creative and contributors
99
* Author URI: https://github.com/Automattic/liveblog/graphs/contributors
1010
* Text Domain: liveblog
@@ -26,7 +26,7 @@
2626
final class WPCOM_Liveblog {
2727

2828
/** Constants *************************************************************/
29-
const VERSION = '1.9.6';
29+
const VERSION = '1.9.7';
3030
const REWRITES_VERSION = 1;
3131
const MIN_WP_VERSION = '4.4';
3232
const MIN_WP_REST_API_VERSION = '4.4';
@@ -917,6 +917,8 @@ public static function flatten_entries( $entries ) {
917917
}
918918

919919
public static function ajax_preview_entry() {
920+
self::ajax_current_user_can_edit_liveblog();
921+
920922
$entry_content = isset( $_REQUEST['entry_content'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['entry_content'] ) ) : ''; // input var ok
921923
$entry_content = self::format_preview_entry( $entry_content );
922924

readme.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Tags: liveblog
44
Requires at least: 4.4
55
Requires PHP: 5.6
66
Tested up to: 5.8
7-
Stable tag: 1.9.6
7+
Stable tag: 1.9.7
88
License: GPLv2 or later
99
License URI: http://www.gnu.org/licenses/gpl-2.0.html
1010

0 commit comments

Comments
 (0)