Make WordPress Core


Ignore:
Timestamp:
10/09/2023 02:47:57 PM (12 months ago)
Author:
kadamwhite
Message:

REST API: Correct parsing of password from Authorization header when processing Application Password credentials.

Exit early when parsing Application Password credentials if Authorization header value does not contain at least one colon. The Authorization Basic header must use a colon to separate the username and password components per RFC 7617, so a username-only string is malformed and should not be processed.

Split Authorization header only on the first colon, properly handling passwords containing colons.

Resolves PHP 8.0 warning when list() was called on an exploded credentials array containing only one element.

Props kalpeshh, shooper, sc0ttkclark, jrf, mukesh27, oglekler, nicolefurlan.
Fixes #57512.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/load.php

    r56635 r56804  
    127127    $userpass = base64_decode( $token );
    128128
    129     list( $user, $pass ) = explode( ':', $userpass );
     129    // There must be at least one colon in the string.
     130    if ( ! str_contains( $userpass, ':' ) ) {
     131        return;
     132    }
     133
     134    list( $user, $pass ) = explode( ':', $userpass, 2 );
    130135
    131136    // Now shove them in the proper keys where we're expecting later on.
Note: See TracChangeset for help on using the changeset viewer.