Skip to content

Commit 647ee05

Browse files
committed
Bootstrap/Load: Prevent loopback scraping errors when there is no key or nonce.
For error detection and rollback functions WordPress also starts a loopback request to the homepage. This loopback request is made with special parameters that when they don't match, generates an erorr. This hardens that flow by exiting out of the check if the nonce or key is missing or the nonce is not saved in the DB. It further hardens it by not caching the failures and asking search engines not to index the url with the failures. Props georgwordpress, swissspidy, jorbin. Fixes #62105. git-svn-id: https://develop.svn.wordpress.org/trunk@59171 602fd350-edb4-49c9-b593-d223f7449a82
1 parent c3b9b39 commit 647ee05

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/wp-includes/load.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1806,8 +1806,20 @@ function wp_start_scraping_edited_file_errors() {
18061806

18071807
$key = substr( sanitize_key( wp_unslash( $_REQUEST['wp_scrape_key'] ) ), 0, 32 );
18081808
$nonce = wp_unslash( $_REQUEST['wp_scrape_nonce'] );
1809+
if ( empty( $key ) || empty( $nonce ) ) {
1810+
return;
1811+
}
1812+
1813+
$transient = get_transient( 'scrape_key_' . $key );
1814+
if ( false === $transient ) {
1815+
return;
1816+
}
18091817

1810-
if ( get_transient( 'scrape_key_' . $key ) !== $nonce ) {
1818+
if ( $transient !== $nonce ) {
1819+
if ( ! headers_sent() ) {
1820+
header( 'X-Robots-Tag: noindex' );
1821+
nocache_headers();
1822+
}
18111823
echo "###### wp_scraping_result_start:$key ######";
18121824
echo wp_json_encode(
18131825
array(

0 commit comments

Comments
 (0)