WordPress.org

Make WordPress Core


Ignore:
Timestamp:
07/21/2020 12:01:10 PM (15 months ago)
Author:
TimothyBlynJacobs
Message:

REST API: Issue a _doing_it_wrong when registering a route without a permission callback.

The REST API treats routes without a permission_callback as public. Because this happens without any warning to the user, if the permission callback is unintentionally omitted or misspelled, the endpoint can end up being available to the public. Such a scenario has happened multiple times in the wild, and the results can be catostrophic when it occurs.

For REST API routes that are intended to be public, it is recommended to set the permission callback to the __return_true built in function.

Fixes #50075.
Props rmccue, sorenbronsted, whyisjake, SergeyBiryukov, TimothyBlynJacobs.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-oembed-controller.php

    r48135 r48526  
    3737            array(
    3838                array(
    39                     'methods'  => WP_REST_Server::READABLE,
    40                     'callback' => array( $this, 'get_item' ),
    41                     'args'     => array(
     39                    'methods'             => WP_REST_Server::READABLE,
     40                    'callback'            => array( $this, 'get_item' ),
     41                    'permission_callback' => '__return_true',
     42                    'args'                => array(
    4243                        'url'      => array(
    4344                            'description' => __( 'The URL of the resource for which to fetch oEmbed data.' ),
Note: See TracChangeset for help on using the changeset viewer.