Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/security-hardening-faustwp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@faustwp/wordpress-plugin": patch
---

fix[faustwp]: use hash_equals() for constant-time secret key comparison in REST and GraphQL permission callbacks, clean up uploaded blockset file on failed extraction
1 change: 1 addition & 0 deletions plugins/faustwp/includes/blocks/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ function process_and_replace_blocks( $wp_filesystem, $file, $dirs ) {

$unzip_result = unzip_uploaded_file( $target_file, $dirs['target'] );
if ( is_wp_error( $unzip_result ) ) {
$wp_filesystem->delete( $target_file );
return $unzip_result;
}

Expand Down
5 changes: 3 additions & 2 deletions plugins/faustwp/includes/graphql/callbacks.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,9 @@ function filter_introspection( $value, $default_value, $option_name, $section_fi
return $value;
}

$secret_key = get_secret_key();
if ( $secret_key !== $_SERVER['HTTP_X_FAUST_SECRET'] ) {
$secret_key = get_secret_key();
$faust_secret = sanitize_text_field( wp_unslash( $_SERVER['HTTP_X_FAUST_SECRET'] ) );
if ( ! hash_equals( $secret_key, $faust_secret ) ) {
return $value;
}

Expand Down
4 changes: 2 additions & 2 deletions plugins/faustwp/includes/rest/callbacks.php
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ function rest_authorize_permission_callback( \WP_REST_Request $request ) {
$header_key = $request->get_header( 'x-faustwp-secret' );

if ( $secret_key && $header_key ) {
return $secret_key === $header_key;
return hash_equals( $secret_key, $header_key );
}

return false;
Expand All @@ -444,7 +444,7 @@ function wpac_authorize_permission_callback( \WP_REST_Request $request ) {
$header_key = $request->get_header( 'x-wpe-headless-secret' );

if ( $secret_key && $header_key ) {
return $secret_key === $header_key;
return hash_equals( $secret_key, $header_key );
}

return false;
Expand Down