Skip to content

fix(security): builder preview, language switch and element requests require an admin and the admin nonce (6.4.x) - #260

Closed
RensTillmann wants to merge 1 commit into
release/6.4.xfrom
fix/64-builder-ajax-auth
Closed

RensTillmann wants to merge 1 commit into
release/6.4.xfrom
fix/64-builder-ajax-auth

Conversation

@RensTillmann

@RensTillmann RensTillmann commented Oct 20, 2026 •

Copy link
Copy Markdown
Owner

Summary

Security fix for #139 on 6.4. Five form-builder AJAX handlers had no nonce and no capability check, so any logged-in user (e.g. a subscriber) could render any form or its settings:

  • super_load_preview (form markup incl. drafts/private/backups), super_switch_language (full form settings HTML), super_undo_redo, and the AJAX entry of super_load_element_settings / super_get_element_builder_html.

They now use the existing authorize_admin_ajax_request() guard (manage_options + super_admin_ajax nonce); preview and language switch also reject backups/non-forms via require_admin_form(). The last two are only guarded on their AJAX path (doing_action), so internal PHP calls keep working. All six builder JS callers send the admin nonce (already localized).

No more silent failures: a rejected save/preview/element request (non-200, -1/0) now restores the button and shows a translatable alert ("The request was rejected (HTTP %s). Your session may have expired or a security plugin blocked it. Please reload the page and try again.") instead of hanging on "Saving..." or inserting the error into the form. Saving itself was already protected since 6.4.008.

Base branch

release/6.4.x: security fix for the beta channel. LTS counterpart: separate PR.

Tests

new tests/test-security-builder-ajax.php (forked AJAX requests; needs pcntl):
  without the fix: 23 of 30 fail (20 rejection cases, 2 backup cases, localization)
  with the fix:    OK (30 tests, 220 assertions)
full PHPUnit suite (g16-phpunit + MariaDB): OK, 642 tests, 10505 assertions, 1 skipped
php -l, node --check create-form.js: OK

Not run: a real-browser builder session. Changelog: "Unreleased - Version 6.4.010-beta" (same heading as #250/#254: expect a one-line conflict).

Merge

Draft: for QA and the next 6.4.0xx release session.

…require an admin and the admin nonce (6.4.x)
@RensTillmann

Copy link
Copy Markdown
Owner Author

The fix is already released in 6.4.010 (release PR #299, merged 21 Oct 2026): the admin capability and nonce checks are in src/includes/class-ajax.php and src/super-forms.php, and the rejected-request handling is SUPER.builder_request_rejected in src/assets/js/backend/create-form.js (line 1572, used for save, preview and language switch). This PR's test file tests/test-security-builder-ajax.php was not part of that release and stays on this branch. The browser suite covers this on 6.4.010 (builder-admin.spec.ts, passed).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant