Skip to content

Commit

Permalink
Merge pull request #685 from Automattic/fix/unauthenticated-ajax-vuln…
Browse files Browse the repository at this point in the history
…erability

Fix the unathenticated vulnerability for ajax/rest endpoints
  • Loading branch information
ingeniumed authored Jun 7, 2024
2 parents 4284d1e + 20ba9fe commit 3c7a27c
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 7 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## 1.9.7
* Adds a capability check to the preview, authors and hashtag endpoint to prevent unauthenticated calls (#685)

## 1.9.6

* Revert #597, restoring `get_fields_for_render()` that is being used in some implementations (#639)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Requires at least: 4.4
* Requires PHP: 5.6
* Tested up to: 4.9.8
* Stable tag: 1.9.6
* Stable tag: 1.9.7
* License: GPLv2 or later
* License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand Down
6 changes: 3 additions & 3 deletions classes/class-wpcom-liveblog-rest-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,12 +180,12 @@ public static function register_routes() {
array(
'methods' => WP_REST_Server::CREATABLE,
'callback' => array( __CLASS__, 'format_preview_entry' ),
'permission_callback' => array( 'WPCOM_Liveblog', 'current_user_can_edit_liveblog' ),
'args' => array(
'entry_content' => array(
'required' => true,
),
),
'permission_callback' => '__return_true',
)
);

Expand All @@ -205,12 +205,12 @@ public static function register_routes() {
array(
'methods' => WP_REST_Server::READABLE,
'callback' => array( __CLASS__, 'get_authors' ),
'permission_callback' => array( 'WPCOM_Liveblog', 'current_user_can_edit_liveblog' ),
'args' => array(
'term' => array(
'required' => false,
),
),
'permission_callback' => '__return_true',
)
);

Expand All @@ -230,12 +230,12 @@ public static function register_routes() {
array(
'methods' => WP_REST_Server::READABLE,
'callback' => array( __CLASS__, 'get_hashtag_terms' ),
'permission_callback' => array( 'WPCOM_Liveblog', 'current_user_can_edit_liveblog' ),
'args' => array(
'term' => array(
'required' => false,
),
),
'permission_callback' => '__return_true',
)
);

Expand Down
6 changes: 4 additions & 2 deletions liveblog.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Plugin Name: Liveblog
* Plugin URI: http://wordpress.org/extend/plugins/liveblog/
* Description: Empowers website owners to provide rich and engaging live event coverage to a large, distributed audience.
* Version: 1.9.6
* Version: 1.9.7
* Author: WordPress.com VIP, Big Bite Creative and contributors
* Author URI: https://github.com/Automattic/liveblog/graphs/contributors
* Text Domain: liveblog
Expand All @@ -26,7 +26,7 @@
final class WPCOM_Liveblog {

/** Constants *************************************************************/
const VERSION = '1.9.6';
const VERSION = '1.9.7';
const REWRITES_VERSION = 1;
const MIN_WP_VERSION = '4.4';
const MIN_WP_REST_API_VERSION = '4.4';
Expand Down Expand Up @@ -917,6 +917,8 @@ public static function flatten_entries( $entries ) {
}

public static function ajax_preview_entry() {
self::ajax_current_user_can_edit_liveblog();

$entry_content = isset( $_REQUEST['entry_content'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['entry_content'] ) ) : ''; // input var ok
$entry_content = self::format_preview_entry( $entry_content );

Expand Down
2 changes: 1 addition & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Tags: liveblog
Requires at least: 4.4
Requires PHP: 5.6
Tested up to: 5.8
Stable tag: 1.9.6
Stable tag: 1.9.7
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand Down

0 comments on commit 3c7a27c

Please sign in to comment.