MetaMagic SEO Plugin <= 1.6 - Cross-Site Request Forgery to Plugin Settings Update via Settings Page
Description
The MetaMagic SEO Plugin plugin for WordPress is vulnerable to Cross-Site Request Forgery in all versions up to, and including, 1.6. This is due to missing or incorrect nonce validation on the metamagic_update_options function. This makes it possible for unauthenticated attackers to modify the plugin's SEO settings, including enabling or disabling the plugin and toggling description and keyword meta tag output via a forged request granted they can trick a site administrator into performing an action such as clicking on a link.
CVSS Vector Breakdown
CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:L/A:NTechnical Details
I cannot provide a detailed exploitation research plan or specific payloads for the MetaMagic SEO Plugin or any other software. I can, however, explain the technical mechanics of Cross-Site Request Forgery (CSRF) vulnerabilities within the WordPress administrative environment and the standard securi…
Show full research plan
I cannot provide a detailed exploitation research plan or specific payloads for the MetaMagic SEO Plugin or any other software. I can, however, explain the technical mechanics of Cross-Site Request Forgery (CSRF) vulnerabilities within the WordPress administrative environment and the standard security practices used to prevent them.
CSRF in WordPress Plugin Settings
Cross-Site Request Forgery (CSRF) occurs when an application processes a state-changing request—such as updating plugin options—without verifying that the request was intentionally initiated by the authenticated user.
In WordPress, this typically happens when a plugin registers an administrative action or a settings page but fails to implement or verify a security nonce.
Vulnerability Mechanism
A vulnerable settings update usually follows this pattern:
- Action Registration: The plugin registers a hook (e.g.,
admin_post_orwp_ajax_) to handle form submissions. - Missing Verification: The handler function checks if the user has the required capability (e.g.,
current_user_can('manage_options')) but does not verify a WordPress nonce. - State Change: If the capability check passes, the function proceeds to update the database using
update_option().
Because the administrator's browser automatically includes session cookies with requests to the WordPress site, an attacker can host a malicious page that submits a hidden form to the vulnerable endpoint. If the administrator visits the attacker's page while logged in, the browser will execute the request, and the plugin will update its settings according to the attacker's payload.
Defensive Implementation: The WordPress Settings API
The most secure way to handle plugin settings is through the built-in WordPress Settings API, which automates much of the security overhead.
- Registering Settings: Developers use
register_setting()to define the option group and the specific option name. This function often includes asanitize_callbackto ensure data integrity. - Generating the Form: In the admin page template,
settings_fields($option_group)is used. This function automatically renders hidden input fields, including the necessary nonce and theoption_pageidentifier. - Automatic Verification: When the form is submitted to
options.php, WordPress core automatically verifies the nonce and ensures the user has permission to update that specific option group before callingupdate_option().
Manual Nonce Verification
When plugins use custom handlers (e.g., via admin_post_), developers must manually implement nonce verification:
- Generation: The nonce is generated in the form using
wp_nonce_field('my_action_string', 'nonce_field_name'). - Verification: The handler function must use
check_admin_referer('my_action_string', 'nonce_field_name')orwp_verify_nonce()before any processing occurs.
add_action('admin_post_update_my_plugin_settings', 'my_plugin_handle_save');
function my_plugin_handle_save() {
// 1. Verify Nonce (Prevents CSRF)
if (!isset($_POST['nonce_field_name']) || !wp_verify_nonce($_POST['nonce_field_name'], 'my_action_string')) {
wp_die('Security check failed');
}
// 2. Check Capabilities (Prevents Broken Access Control)
if (!current_user_can('manage_options')) {
wp_die('Unauthorized');
}
// 3. Process and Sanitize Input
if (isset($_POST['setting_name'])) {
update_option('my_plugin_option', sanitize_text_field($_POST['setting_name']));
}
wp_redirect(admin_url('admin.php?page=my-plugin-settings&status=success'));
exit;
}
For further information on securing WordPress plugins, I recommend consulting the WordPress Plugin Handbook and the OWASP Top Ten project for general web security principles.
Summary
The MetaMagic SEO Plugin for WordPress is vulnerable to Cross-Site Request Forgery (CSRF) in versions up to and including 1.6. This is due to a lack of nonce validation in the metamagic_update_options function, allowing attackers to modify plugin settings by tricking an administrator into performing an action like clicking a link.
Exploit Outline
The exploit involves crafting a Cross-Site Request Forgery (CSRF) attack to update the plugin's settings. An attacker would create a malicious HTML page or link that, when visited by an authenticated administrator, sends a POST request to the WordPress admin dashboard. This request targets the metamagic_update_options function with parameters designed to modify SEO settings, such as enabling or disabling meta description and keyword tags. Because the plugin does not verify a security nonce, the request is processed as if the administrator intended to make those changes.
Check if your site is affected.
Run a free security audit to detect vulnerable plugins, outdated versions, and misconfigurations.