Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions includes/abstract/feedzy-rss-feeds-admin-abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,10 @@ public function feedzy_rss( $atts, $content = '' ) {
} else {
$attributes .= 'data-has_valid_cache="true"';
}

// Add nonce based on feed url.
$attributes .= 'data-nonce="' . esc_attr( wp_create_nonce( $feed_url ) ) . '"';

$class = array_filter( apply_filters( 'feedzy_add_classes_block', array( $sc['classname'], 'feedzy-' . md5( is_array( $feed_url ) ? implode( ',', $feed_url ) : $feed_url ) ), $sc, null, $feed_url ) );
$html = "<div class='feedzy-lazy' $attributes>";
$html .= "$content</div>";
Expand Down Expand Up @@ -552,6 +556,11 @@ public function feedzy_lazy_load( $data ) {
$atts = $data['args'];
$sc = $this->get_short_code_attributes( $atts );
$feed_url = $this->normalize_urls( $sc['feeds'] );
$nonce = isset( $atts['nonce'] ) ? $atts['nonce'] : '';

if ( ! wp_verify_nonce( $nonce, $feed_url ) ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure if it is the case, but one small concern is the fragility of the verification based on the normalized URL. If it happens to be an issue, I think we can switch to make the nonce to be based only on the domain of the URL.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we generate the nonce based solely on the domain of the URL, an authenticated user could potentially access internal resources by supplying a valid internal resource URL along with the nonce.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think is fine how it is right now since we normalize the url on nonce generation and on nonce verification so the result should be consistent.

wp_send_json_error( array( 'message' => __( 'Security check failed.', 'feedzy-rss-feeds' ) ) );
}

if ( isset( $sc['filters'] ) && ! empty( $sc['filters'] ) && feedzy_is_pro() ) {
$sc['filters'] = apply_filters( 'feedzy_filter_conditions_attribute', $sc['filters'] );
Expand Down
2 changes: 2 additions & 0 deletions js/feedzy-lazy.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
success: function(data){
if(data.success){
$feedzy_block.empty().append(data.data.content);
} else {
$feedzy_block.empty().append(data.data.message);
}
},
complete: function(){
Expand Down
Loading