Skip to content

Commit 02f04fe

Browse files
authored
fix(security): sanitize $_GET input before nonce construction in wp_ajax_fetch_list()
Raw $_GET['list_args']['class'] and $_GET['list_args']['screen']['id'] were used directly to build the nonce action string and passed to _get_list_table() without any sanitization or existence checks. An attacker controlling list_args[class] could influence the nonce key being verified, undermining the referer check. Apply sanitize_key() and isset() guards to both values before use, ensuring the nonce action string and _get_list_table() arguments are constructed from clean input.
1 parent e12ddb3 commit 02f04fe

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

src/wp-admin/includes/ajax-actions.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,11 @@ function wp_ajax_nopriv_heartbeat() {
8181
* @since 3.1.0
8282
*/
8383
function wp_ajax_fetch_list() {
84-
$list_class = $_GET['list_args']['class'];
84+
$list_class = isset( $_GET['list_args']['class'] ) ? sanitize_key( $_GET['list_args']['class'] ) : '';
85+
$screen_id = isset( $_GET['list_args']['screen']['id'] ) ? sanitize_key( $_GET['list_args']['screen']['id'] ) : '';
8586
check_ajax_referer( "fetch-list-$list_class", '_ajax_fetch_list_nonce' );
8687

87-
$wp_list_table = _get_list_table( $list_class, array( 'screen' => $_GET['list_args']['screen']['id'] ) );
88+
$wp_list_table = _get_list_table( $list_class, array( 'screen' => $screen_id ) );
8889
if ( ! $wp_list_table ) {
8990
wp_die( 0 );
9091
}

0 commit comments

Comments
 (0)