Skip to content

Commit c6b1653

Browse files
committed
Deploying version 6.3.8
1 parent c154117 commit c6b1653

File tree

6 files changed

+99
-7
lines changed

6 files changed

+99
-7
lines changed

acf.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* Plugin Name: Advanced Custom Fields
1010
* Plugin URI: https://www.advancedcustomfields.com
1111
* Description: Customize WordPress with powerful, professional and intuitive fields.
12-
* Version: 6.3.7
12+
* Version: 6.3.8
1313
* Author: WP Engine
1414
* Author URI: https://wpengine.com/?utm_source=wordpress.org&utm_medium=referral&utm_campaign=plugin_directory&utm_content=advanced_custom_fields
1515
* Update URI: false
@@ -36,7 +36,7 @@ class ACF {
3636
*
3737
* @var string
3838
*/
39-
public $version = '6.3.7';
39+
public $version = '6.3.8';
4040

4141
/**
4242
* The plugin settings array.

includes/class-PluginUpdater.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,13 @@ public function filter_plugin_update_transient( $transient ) {
124124
return $transient;
125125
}
126126

127+
$res = $this->parse_plugin_info( $result );
128+
127129
if ( version_compare( $this->properties['plugin_version'], $result->version, '<' ) ) {
128-
$res = $this->parse_plugin_info( $result );
129130
$transient->response[ $res->plugin ] = $res;
130131
$transient->checked[ $res->plugin ] = $result->version;
132+
} else {
133+
$transient->no_update[ $res->plugin ] = $res;
131134
}
132135

133136
return $transient;

includes/class-acf-site-health.php

+5
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,11 @@ public function get_site_health_values(): array {
287287
'debug' => $is_pro ? 'PRO' : 'Free',
288288
);
289289

290+
$fields['update_source'] = array(
291+
'label' => __( 'Update Source', 'acf' ),
292+
'value' => __( 'ACF Direct', 'acf' ),
293+
);
294+
290295
if ( $is_pro ) {
291296
$fields['activated'] = array(
292297
'label' => __( 'License Activated', 'acf' ),

includes/post-types/class-acf-post-type.php

+41-2
Original file line numberDiff line numberDiff line change
@@ -528,9 +528,9 @@ public function get_post_type_args( $post, $escape_labels = true ) {
528528
$args['supports'] = $supports;
529529
}
530530

531-
// Handle register meta box callbacks if set from an import.
531+
// Handle register meta box callbacks safely
532532
if ( ! empty( $post['register_meta_box_cb'] ) ) {
533-
$args['register_meta_box_cb'] = (string) $post['register_meta_box_cb'];
533+
$args['register_meta_box_cb'] = array( $this, 'build_safe_context_for_metabox_cb' );
534534
}
535535

536536
// WordPress doesn't register any default taxonomies.
@@ -619,6 +619,45 @@ public function get_post_type_args( $post, $escape_labels = true ) {
619619
return apply_filters( 'acf/post_type/registration_args', $args, $post );
620620
}
621621

622+
/**
623+
* Ensure the metabox being called does not perform any unsafe operations.
624+
*
625+
* @since 6.3.8
626+
*
627+
* @param WP_Post $post The post being rendered.
628+
* @return mixed The callback result.
629+
*/
630+
public function build_safe_context_for_metabox_cb( $post ) {
631+
$post_types = $this->get_posts();
632+
$this_post = array_filter(
633+
$post_types,
634+
function ( $post_type ) use ( $post ) {
635+
return $post_type['post_type'] === $post->post_type;
636+
}
637+
);
638+
if ( empty( $this_post ) || ! is_array( $this_post ) ) {
639+
// Unable to find the ACF post type. Don't do anything.
640+
return;
641+
}
642+
$acf_post_type = array_shift( $this_post );
643+
$original_cb = isset( $acf_post_type['register_meta_box_cb'] ) ? $acf_post_type['register_meta_box_cb'] : false;
644+
645+
// Prevent access to any wp_ prefixed functions in a callback.
646+
if ( apply_filters( 'acf/post_type/prevent_access_to_wp_functions_in_meta_box_cb', true ) && substr( strtolower( $original_cb ), 0, 3 ) === 'wp_' ) {
647+
// Don't execute register meta box callbacks if an internal wp function by default.
648+
return;
649+
}
650+
651+
$original_post = $_POST; //phpcs:ignore -- Only used as temporary storage to prevent CSRFs in callbacks.
652+
$_POST = array();
653+
$return = false;
654+
if ( is_callable( $original_cb ) ) {
655+
$return = call_user_func( $original_cb, $post );
656+
}
657+
$_POST = $original_post;
658+
return $return;
659+
}
660+
622661
/**
623662
* Returns a string that can be used to create a post type in PHP.
624663
*

includes/post-types/class-acf-taxonomy.php

+41-1
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ public function get_taxonomy_args( $post, $escape_labels = true ) {
423423
$meta_box = isset( $post['meta_box'] ) ? (string) $post['meta_box'] : 'default';
424424

425425
if ( 'custom' === $meta_box && ! empty( $post['meta_box_cb'] ) ) {
426-
$args['meta_box_cb'] = (string) $post['meta_box_cb'];
426+
$args['meta_box_cb'] = array( $this, 'build_safe_context_for_metabox_cb' );
427427

428428
if ( ! empty( $post['meta_box_sanitize_cb'] ) ) {
429429
$args['meta_box_sanitize_cb'] = (string) $post['meta_box_sanitize_cb'];
@@ -504,6 +504,46 @@ public function get_taxonomy_args( $post, $escape_labels = true ) {
504504
return apply_filters( 'acf/taxonomy/registration_args', $args, $post );
505505
}
506506

507+
/**
508+
* Ensure the metabox being called does not perform any unsafe operations.
509+
*
510+
* @since 6.3.8
511+
*
512+
* @param WP_Post $post The post being rendered.
513+
* @param array $tax The provided taxonomy information required for callback render.
514+
* @return mixed The callback result.
515+
*/
516+
public function build_safe_context_for_metabox_cb( $post, $tax ) {
517+
$taxonomies = $this->get_posts();
518+
$this_tax = array_filter(
519+
$taxonomies,
520+
function ( $taxonomy ) use ( $tax ) {
521+
return $taxonomy['taxonomy'] === $tax['args']['taxonomy'];
522+
}
523+
);
524+
if ( empty( $this_tax ) || ! is_array( $this_tax ) ) {
525+
// Unable to find the ACF taxonomy. Don't do anything.
526+
return;
527+
}
528+
$acf_taxonomy = array_shift( $this_tax );
529+
$original_cb = isset( $acf_taxonomy['meta_box_cb'] ) ? $acf_taxonomy['meta_box_cb'] : false;
530+
531+
// Prevent access to any wp_ prefixed functions in a callback.
532+
if ( apply_filters( 'acf/taxonomy/prevent_access_to_wp_functions_in_meta_box_cb', true ) && substr( strtolower( $original_cb ), 0, 3 ) === 'wp_' ) {
533+
// Don't execute register meta box callbacks if an internal wp function by default.
534+
return;
535+
}
536+
537+
$original_post = $_POST; //phpcs:ignore -- Only used as temporary storage to prevent CSRFs in callbacks.
538+
$_POST = array();
539+
$return = false;
540+
if ( is_callable( $original_cb ) ) {
541+
$return = call_user_func( $original_cb, $post, $tax );
542+
}
543+
$_POST = $original_post;
544+
return $return;
545+
}
546+
507547
/**
508548
* Returns a string that can be used to create a taxonomy in PHP.
509549
*

readme.txt

+6-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Tags: acf, fields, custom fields, meta, repeater
44
Requires at least: 6.0
55
Tested up to: 6.6
66
Requires PHP: 7.4
7-
Stable tag: 6.3.7
7+
Stable tag: 6.3.8
88
License: GPLv2 or later
99
License URI: https://www.gnu.org/licenses/gpl-2.0.html
1010

@@ -94,6 +94,11 @@ From your WordPress dashboard
9494

9595
== Changelog ==
9696

97+
= 6.3.8 =
98+
*Release Date 7th October 2024*
99+
100+
* Security - ACF defined Post Type and Taxonomy metabox callbacks no longer have access to $_POST data. (Thanks to the Automattic Security Team for the disclosure)
101+
97102
= 6.3.7 =
98103
*Release Date 2nd October 2024*
99104

0 commit comments

Comments
 (0)