Skip to content

Commit b325e3d

Browse files
Merge pull request #1155 from Codeinwp/bugfix/pro/938
Prevent SSRF vulnerability
2 parents bfb5703 + 441aade commit b325e3d

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

includes/gutenberg/feedzy-rss-feeds-gutenberg-block.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,9 @@ public function feedzy_register_rest_route() {
284284
array(
285285
'methods' => 'POST',
286286
'callback' => array( $this, 'feedzy_rest_route' ),
287-
'permission_callback' => function () {
288-
return is_user_logged_in();
287+
'permission_callback' => function ( WP_REST_Request $request ) {
288+
$post_id = absint( $request->get_param( 'postId' ) );
289+
return current_user_can( 'edit_post', $post_id );
289290
},
290291
'args' => array(
291292
'url' => array(
@@ -398,12 +399,14 @@ public function feedzy_rest_route( $data ) {
398399
*/
399400
public function feedzy_sanitize_feeds( $input ) {
400401
if ( count( $input ) === 1 ) {
401-
$feed = esc_url( $input[0] );
402+
$feed = wp_http_validate_url( $input[0] );
402403
return $feed;
403404
} else {
404405
$feeds = array();
405406
foreach ( $input as $item ) {
406-
$feeds[] = esc_url( $item );
407+
if ( wp_http_validate_url( $item ) ) {
408+
$feeds[] = esc_url_raw( $item );
409+
}
407410
}
408411
return $feeds;
409412
}

js/FeedzyBlock/Editor.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,11 +194,12 @@ class Editor extends Component {
194194
.filter((item) => item !== '');
195195
url = queryString.stringify({ url }, { arrayFormat: 'bracket' });
196196
}
197+
const postId = wp.data.select('core/editor').getCurrentPostId();
197198

198199
apiFetch({
199200
path: `/feedzy/v1/feed?${url}`,
200201
method: 'POST',
201-
data: this.props.attributes,
202+
data: {...this.props.attributes, postId: postId},
202203
})
203204
.then((data) => {
204205
if (this.unmounting) {

0 commit comments

Comments
 (0)