Skip to content

[security] Fixed a issue where hundreds of Warning "first argument of wpdb::prepare should have a placeholder" are displayed while define('WP_DEBUG', true); #32

Merged
headstash merged 1 commit into
masterfrom
unknown repository
Oct 1, 2014
Merged

Conversation

@ghost
Copy link
Copy Markdown

@ghost ghost commented Jun 20, 2014

Hi, I was recently using your plugin whilst debugging a multi-site configuration and noticed several small errors and possible vulnerabilities in your plugin. Please see my change log for more information, fix is simple and only 3 lines.

I was doing a little debugging with WordPress 3.9 using your plugin and notice that when your plugin is enabled and wp_debug is set to true. Certain pages on the admin side can generate hundreds possibly thousands of warning for "first argument of wpdb::prepare should have a placeholder".

Summary of the change:

  • Orignial: $wpdb->get_col($wpdb->prepare("SELECT domain FROM " . $wpdb->blogs, NULL));
  • New: $wpdb->get_col($wpdb->prepare("SELECT domain FROM %d", $wpdb->blogs));

For information see the ticket that introduced the notice in WP3.9 https://core.trac.wordpress.org/ticket/25604

My configuration:

  • WP3.9.1
  • Multisite enabled
  • WordPress-HTTPS was networked enabled

Anyway I hope that helps!

Thanks and kind regards,

Steven

…WP_DEBUG', true); is present; more details: "first argument of wpdb::prepare should have a placeholder".

A checked was performed to find all files containing $wpdb->prepare, using
- grep -ri 'wpdb->prepare' *

And the result showed:
- plugins/wordpress-https/lib/WordPressHTTPS.php:
- $multisite_hosts = $wpdb->get_col($wpdb->prepare("SELECT domain FROM " . $wpdb->blogs, NULL));

- plugins/wordpress-https/lib/WordPressHTTPS.php:
- $blogs = $wpdb->get_col($wpdb->prepare("SELECT blog_id FROM " . $wpdb->blogs, NULL));

- plugins/wordpress-https/uninstall.php:
- $blogs = $wpdb->get_col($wpdb->prepare("SELECT blog_id FROM " . $wpdb->blogs, NULL));

Replaced 3 instances of where $wpdb->prepare() second argument was passed as null and possibly opens up a vulnerability.

Summary of the change:
- Orignial: $wpdb->get_col($wpdb->prepare("SELECT domain FROM " . $wpdb->blogs, NULL));
- New:      $wpdb->get_col($wpdb->prepare("SELECT domain FROM %d", $wpdb->blogs));

For information see the ticket that introduced the notice in WP3.9 https://core.trac.wordpress.org/ticket/25604
@ghost ghost changed the title Fixed an issue where hundreds of Warning are displayed while define('WP_... [security] Fixed a issue where hundreds of Warning "first argument of wpdb::prepare should have a placeholder" are displayed while define('WP_DEBUG', true); Jun 20, 2014
headstash added a commit that referenced this pull request Oct 1, 2014
[security] Fixed a issue where hundreds of Warning "first argument of wpdb::prepare should have a placeholder" are displayed while define('WP_DEBUG', true);
@headstash headstash merged commit 7b328bf into mvied:master Oct 1, 2014
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.

2 participants