Security review fixes: keep pending-capture ids, ship uninstall.php (+verify step), webhook guard, IPv6 /64 + global order throttle, token-safe redirects, honest refund wording, request-id and overlay-token hardening
Test and Release / test (push) Successful in 1m23s
Test and Release / release (push) Successful in 5s

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
shadowdaoandClaude Sonnet 5.5 committed 2026-11-15 14:07:44 -08:00
1 parent 68bd917660
commit 473fe192cd
28 files changed
+747 -34

No files matched your search

+46 -1
View File
@@ -29,6 +29,7 @@ final class Updater {
add_filter( 'pre_set_site_transient_update_plugins', array( self::class, 'inject' ) );
add_filter( 'plugins_api', array( self::class, 'pluginInfo' ), 10, 3 );
add_filter( 'http_request_args', array( self::class, 'authorize' ), 10, 2 );
add_filter( 'pre_http_request', array( self::class, 'followSafely' ), 10, 3 );
add_action( 'upgrader_process_complete', array( self::class, 'afterUpgrade' ), 10, 2 );
add_action( 'admin_post_' . self::ACTION_CHECK, array( self::class, 'handleCheck' ) );
}
@@ -170,7 +171,7 @@ final class Updater {
}
$token = trim( (string) Settings::get( 'update_token', '' ) );
$host = self::repo()['host'];
if ( '' === $token || ! ReleaseParser::isAllowedUrl( $url, $host ) ) {
if ( '' === $token || ! RedirectPolicy::tokenAllowed( $url, $host ) ) {
return $args;
}
$args['headers'] = is_array( $args['headers'] ?? null ) ? $args['headers'] : array();
@@ -181,6 +182,50 @@ final class Updater {
return $args;
}
private static bool $following = false;
/**
* Token-bearing requests never let HTTP redirect handling carry the Authorization header anywhere: we send the
* request with redirection disabled and follow a 3xx ourselves ONLY while it stays on the pinned host (max 3 hops).
* A redirect to any other host is not followed at all, so the token cannot leak and the update fails closed.
*/
public static function followSafely( mixed $pre, mixed $args, mixed $url ): mixed {
if ( false !== $pre || self::$following || ! is_array( $args ) || ! is_string( $url ) ) {
return $pre;
}
$headers = is_array( $args['headers'] ?? null ) ? $args['headers'] : array();
$has = false;
foreach ( array_keys( $headers ) as $k ) {
$has = $has || 'authorization' === strtolower( (string) $k );
}
$host = self::repo()['host'];
if ( ! $has || ! RedirectPolicy::tokenAllowed( $url, $host ) ) {
return $pre;
}
self::$following = true;
try {
$current = $url;
$resp = null;
for ( $hop = 0; $hop <= RedirectPolicy::MAX_HOPS; $hop++ ) {
$a = $args;
$a['redirection'] = 0;
$resp = wp_remote_request( $current, $a );
$code = is_wp_error( $resp ) ? 0 : (int) wp_remote_retrieve_response_code( $resp );
if ( $code < 300 || $code >= 400 || is_wp_error( $resp ) ) {
return $resp;
}
$next = RedirectPolicy::nextUrl( $current, (string) wp_remote_retrieve_header( $resp, 'location' ), $host, $hop );
if ( null === $next ) {
return $resp; // not followed: the caller sees the 3xx and fails
}
$current = $next;
}
return $resp;
} finally {
self::$following = false;
}
}
public static function afterUpgrade( mixed $upgrader, mixed $options ): void {
if ( is_array( $options ) && ( $options['type'] ?? '' ) === 'plugin' ) {
self::clearCache();