Making WordPress.org


Ignore:
Timestamp:
05/25/2020 08:42:46 AM (6 years ago)
Author:
dd32
Message:

Bad Requests: Add two more cases to be discarded.

File:
1 edited

Legend:

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

    r9825 r9924  
    6565}, 9 );
    6666
     67// Jetpack Contact form - https://github.com/Automattic/jetpack/pull/15826
     68add_action( 'template_redirect', function () {
     69        if ( isset( $_REQUEST['contact-form-id'] ) ) {
     70                // Jetpack supports contact forms in widgets, but AFAIK we don't have any.
     71                if ( ! is_numeric( $_REQUEST['contact-form-id'] ) ) {
     72                        die_bad_request( "Bad input to Jetpack Contact Form" );
     73                }
     74                if ( ! isset( $_SERVER['HTTP_REFERER'] ) || ! isset( $_SERVER['HTTP_USER_AGENT'] ) ) {
     75                        die_bad_request( "Missing referer or user-agent" );
     76                }
     77                // Jetpack Contact forms can have array fields, but we have none on WordPress.org
     78                foreach ( $_REQUEST as $k => $v ) {
     79                        if ( ! is_scalar( $v ) ) {
     80                                die_bad_request( "non-scalar input to Jetpack Contact Form" );
     81                        }
     82                        if ( 'sample@email.tst' === $v ) {
     83                                die_bad_request( "sample@email.tst input to Jetpack Contact Form" );
     84                        }
     85                }
     86        }
     87} );
     88
     89// bbPress - https://bbpress.trac.wordpress.org/ticket/3373
     90add_action( 'template_redirect', function () {
     91        if ( isset( $_REQUEST['action'] ) && is_array( $_REQUEST['action'] ) && function_exists( 'bbpress' ) ) {
     92                if ( isset( $_REQUEST['action'][0] ) && 'bbp' === substr( $_REQUEST['action'][0], 0, 3 ) ) {
     93                        die_bad_request( "non-scalar input to bbPress subactions." );
     94                }
     95        }
     96} );
     97
    6798/**
    6899 * Detect badly formed XMLRPC requests.
Note: See TracChangeset for help on using the changeset viewer.