Secure WordPress

Null Bangalore Bachaav Session

30 November 2013

AI Generated Summary

AI Generated Content Disclaimer

Note: This summary is AI-generated and may contain inaccuracies, errors, or omissions. If you spot any issues, please contact the site owner for corrections. Errors or omissions are unintended.

Presented as a Null Bachaav community workshop, “Secure Wordpress: Bachaav Session” is a Null community initiative. The session walks through WordPress internals, setup procedures, and comprehensive security hardening, covering attack vectors at the core, plugin, and theme levels along with practical defense strategies using .htaccess rules and child themes.

Summary

The agenda moves through three phases: understand how WordPress works and how its files and folders relate, how to set it up, and how to apply security configuration through basic server hardening, understanding attack vectors, and implementing protections. The demo environment is a VirtualBox VM with a NAT interface for internet access and a host-only connection for normal testing, exposing the WordPress install and phpMyAdmin over the local IP with wordpress/wordpress credentials.

The internals section traces the execution flow: index.php defines WP_USE_THEMES and includes wp-blog-header.php; wp-blog-header includes wp-config.php (database and other constants) and wp-settings.php, after which lots and lots of includes follow: plugins load from PLUGIN_DIR, pluggable functions load (and can be overridden by plugins), then path declaration, query parsing and assignment, HTTP headers, request parsing, template redirections, and theme rendering through header, loop, widget/sidebar, and footer. The reference implementation of this flow is credited to the WordPress codex page on WordPress code flow. The file and folder map covers wp-config.php, wp-settings.php, index.php, .htaccess, /wp-admin/, /wp-content/ (with /plugins and /themes), and /wp-includes/.

Setup splits by hosting type: shared hosting users can use the hosting control panel or upload via FTP and run install.php, while VPS, dedicated, and cloud server users can upload via SSH/FTP or sync via SVN for version control. Server hardening is acknowledged but set aside: the session is WordPress-focused so server hardening details are not covered.

The attack vectors section starts at core level, dividing issues into those still present unpatched (full path disclosures; enumeration issues across usernames, attachments, plugins, and themes; account brute force; and version disclosure at multiple places) and previously exploited issues (XMLRPC-based SSRF attacks and DDoS, among more). Other attacks come from plugins or themes using old files, vulnerable code in core, vulnerable code in plugins or themes, and permission and access issues. Specific techniques are demonstrated: index.php?author=1 redirects to /author/ and index.php?attachment=1 redirects to the individual attachment URL, enabling user and attachment enumeration; plugin and theme enumeration relies on predictable URLs (wp-content/plugin and themes) and predictable files (readme.txt and plugin-specific assets like JS or CSS); and account brute forcing is possible because different error messages distinguish invalid usernames from invalid passwords.

The defense section establishes the governing principle: core modification is not recommended since every upgrade modifies core files, and even theme modification is an absolute no-no since a new update will override it. The sanctioned paths are custom .htaccess-based restrictions and hook/function overrides via custom theme templates. The .htaccess section demonstrates redirections with RewriteCond and RewriteRule (including a robots.txt condition and an abracadabra redirect to Google with the [R=301,L] flag) and custom directives (DirectoryIndex, ServerSignature Off, Header unset Etag). Theme modification the right way uses a child theme folder whose files are picked up first before the parent theme: style.css carries the theme headers (Theme Name, Theme URI, Description, Author, Author URI, Template: twentytwelve, Version) and imports the parent stylesheet via @import url("../twentytwelve/style.css"), while functions.php provides all function overrides through remove_action and add_action calls.

The closing mitigation checklist gathers the remaining issues: full path disclosures addressed by setting display_error to Off in php.ini, clickjacking protection headers, SWF and timthumb related attacks, issues related to the wp-includes folder, comment spam, dangerous HTTP methods (PUT and more), XMLRPC issues, automated scanners for continuous monitoring, and the WordPress header code. The session ends on an empowering note: this should help get started, and since the audience is now aware of the various functions and ways to control them, it is an open playground.

Key Themes

Notable Points

  1. Takeaway: WordPress security starts with understanding the execution flow and file structure.
  2. Takeaway: never modify core or parent theme files directly; use .htaccess and child themes.
  3. Takeaway: username enumeration through ?author=1 is a commonly overlooked information leak.
  4. Takeaway: XMLRPC presents significant attack surface for SSRF and DDoS.
  5. Takeaway: plugin and theme enumeration is trivial due to predictable URL patterns.
  6. The demo ran on a VirtualBox VM with a NAT interface for internet access and a host-only connection for testing, serving http://IP/wordpress and http://IP/phpmyadmin with username wordpress and password wordpress.
  7. Enumeration specifics demonstrated: index.php?author=1 redirects to /author/, index.php?attachment=1 redirects to the individual attachment URL, plugin and theme discovery uses predictable wp-content/plugin and themes URLs plus readme.txt and plugin-specific JS/CSS assets, and login error messages differentiate invalid usernames from invalid passwords.
  8. The child theme recipe uses style.css with the Template header set to twentytwelve and @import url("../twentytwelve/style.css"), plus functions.php overrides such as remove_action(‘widgets_init’, ‘xyz_widgets_init’) paired with add_action(‘widgets_init’, ‘abc_widgets_init’).
  9. The .htaccess examples include RewriteCond on %{REQUEST_URI} robots.txt, a RewriteRule sending ^abracadabra/ to google.com with [R=301,L], and the directives DirectoryIndex index.html, ServerSignature Off, and Header unset Etag.
  10. The mitigations checklist covers display_error Off in php.ini, clickjacking protection, SWF and timthumb attacks, wp-includes folder issues, comment spam, dangerous methods (PUT and more), XMLRPC issues, automated scanners, and the WordPress header code.

Notable Quotes

“A Null Community Initiative”

“lots and lots of includes”

“This session is wordpress focused so we will not cover about server hardening in details”

“Core Modifications is not recommended as every upgrade modifies core files.”

“Implement Hook / function override via custom theme templates”

“Possible to Enumerate Accounts due to different Error Messages”

“This should help us in getting started and since you are now aware of various functions and ways to control them its an open playground now.”

Social chatter