Making WordPress.org

Changeset 14784


Ignore:
Timestamp:
03/31/2026 08:11:10 PM (6 hours ago)
Author:
obenland
Message:

Block non-scalar query parameters in Pattern Directory requests

Vulnerability scanners pass nested arrays for parameters like curation and pattern-categories, which cause PHP warnings.
Reject these requests early with a 400 response.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/mu-plugins/pub/wporg-bad-request.php

    r14775 r14784  
    204204
    205205/**
     206 * Detect non-scalar values in Pattern Directory query parameters.
     207 *
     208 * Scanners pass nested arrays like `curation[$in][]=all` which cause PHP
     209 * warnings downstream when the value is used in esc_attr().
     210 */
     211add_action( 'send_headers', function() {
     212    if ( ! str_contains( $_SERVER['REQUEST_URI'], 'wordpress.org/patterns/' ) ) {
     213        return;
     214    }
     215
     216    $scalar_only = [ 'curation', 'pattern-categories' ];
     217
     218    foreach ( $scalar_only as $field ) {
     219        if ( isset( $_REQUEST[ $field ] ) && ! is_scalar( $_REQUEST[ $field ] ) ) {
     220            die_bad_request( "non-scalar $field in \$_REQUEST" );
     221        }
     222    }
     223} );
     224
     225/**
    206226 * Detect invalid requests from vulnerability scanners to Jetpack Share by Email forms.
    207227 */
Note: See TracChangeset for help on using the changeset viewer.