Security: Return a `403` instead of a `200` HTTP status when `check_ajax_referer()` fails.

This is, unfortunately, untestable in the current test suite, even in the AJAX tests.

Fixes #36362


git-svn-id: https://develop.svn.wordpress.org/trunk@38421 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
John Blackbourn 2016-08-28 17:30:29 +00:00
parent a03376e798
commit 289581e280
2 changed files with 14 additions and 4 deletions

View File

@ -2861,9 +2861,19 @@ function _xmlrpc_wp_die_handler( $message, $title = '', $args = array() ) {
* @since 3.4.0
* @access private
*
* @param string $message Optional. Response to print. Default empty.
*/
function _ajax_wp_die_handler( $message = '' ) {
* @param string $message Error message.
* @param string $title Optional. Error title (unused). Default empty.
* @param string|array $args Optional. Arguments to control behavior. Default empty array.
*/
function _ajax_wp_die_handler( $message, $title = '', $args = array() ) {
$defaults = array(
'response' => 200,
);
$r = wp_parse_args( $args, $defaults );
if ( ! headers_sent() ) {
status_header( $r['response'] );
}
if ( is_scalar( $message ) )
die( (string) $message );
die( '0' );

View File

@ -1108,7 +1108,7 @@ function check_ajax_referer( $action = -1, $query_arg = false, $die = true ) {
if ( $die && false === $result ) {
if ( wp_doing_ajax() ) {
wp_die( -1 );
wp_die( -1, 403 );
} else {
die( '-1' );
}