SlideShare a Scribd company logo
Building Secure WordPress
Themes and Plugins
Tikaram Bhandari
Happiness Engineer / Theme Developer
Catch Themes
The State of WordPress Themes
and Plugins security...
Problems
Lack of Awareness
Lack of Concern
Attack #1
SQL Injection
$wpdb->query (
''UPDATE $wpdb -> $posts
SET post_title = '$newtitle'
WHERE id= $my_id''
);
Disregard Queries: Use API
$wpdb -> update()
$wpdb -> update (
$wpdb -> $posts,
array ( 'post_title' => '$newtitle' ),
array ( 'id' => $my_id )
);
$wpdb -> insert( $table, $data )
$wpdb -> prepare( )
Sanitize Early ( Rule #1)
Sanitizing in customizer
$wp_customize->add_setting(
'prefix_email_address',
array(
…
'sanitize_callback' => 'is_email',
) );
$wp_customize->add_setting(
'prefix_twitter_url',
array(
'default' => '',
'transport' => 'postMessage',
'sanitize_callback' => 'esc_url_raw',
) );
Attack #2
XSS
Cross-Site Scripting
<h1>
<?php echo $title; ?>
</h1>
$title = '<script>some_function();</script>';
Escape Late ( Rule #2)
{
esc_attr_e
Easy as 1 2 3
{
{
esc_html()
<h1>
<?php echo esc_html( $title ) ; ?>
</h1>
<?php $title=' ''onmouseover=''fucn();'; ?>
<a href =''#wordcamp'' title=''<?php echo $title;
?>''>
Text
</a>
esc_attr()
<?php $title=' '' onmouseover=''fucn();'; ?>
<a href =''#wordcamp'' title=''<?php echo
esc_attr( $title ) ; ?>''>
Text
</a>
<?php $url = 'javascript:func()'; ?>
<a href= ''<?php echo $url; ?> ''>
Text
</a>
esc_url()
<?php $url = 'javascript:func()'; ?>
<a href= ''<?php echo esc_url( $url ) ; ?> ''>
Text
</a>
esc_js()
<script>
var foo = ' <?php echo esc_js( $unsafe ); ?> ';
</script>
esc_textarea()
wp_kses family
wp_kses()
wp_kses_post()
wp_kses_allowed_html
Not Hardcoded = Suspect ( Rule #3)
Everything is suspect
Attack #3
CSRF : Cross-site Request Forgery
Authorization vs Intention
Nonces
action-, object- & user-specific time specific
secret keys
wp_nonce_field('theme-action_object')
check_admin_referer('theme-
action_object')
CSRF for Ajax/XHR requests
 On front end
$nonce = wp_create_nonce( 'your_action' )
 Add &_ajax_nonce = $nonce to your post/get
vars
 On backend
check_ajax_referer( 'your_action' ) ;
Some mistakes
 eval()
 <form action= '' <?php echo
$_SERVER['REQURES_URI']; ?> '' >
Common Vulnerabilities
Data Sanitization/Escaping
Using Nonces
Common Mistakes
Summary
References
Plugin Security
https://developer.wordpress.org/plugins/security
Theme Security
https://developer.wordpress.org/themes/theme-
security
Thanks, any questions?
Email: tikaram@catchthemes.com

More Related Content

PDF
50 Laravel Tricks in 50 Minutes
PDF
WordCamp Montreal 2015: Combining Custom Post Types, Fields, and Meta Boxes t...
PPTX
CakePHP workshop
PDF
WordPress Capabilities Magic
PDF
Be lazy, be ESI: HTTP caching and Symfony2 @ PHPDay 2011 05-13-2011
PDF
WordPress as an application framework
PPTX
Сергей Иващенко - Meet Magento Ukraine - Цены в Magento 2
PDF
Gail villanueva add muscle to your wordpress site
50 Laravel Tricks in 50 Minutes
WordCamp Montreal 2015: Combining Custom Post Types, Fields, and Meta Boxes t...
CakePHP workshop
WordPress Capabilities Magic
Be lazy, be ESI: HTTP caching and Symfony2 @ PHPDay 2011 05-13-2011
WordPress as an application framework
Сергей Иващенко - Meet Magento Ukraine - Цены в Magento 2
Gail villanueva add muscle to your wordpress site

What's hot (20)

PDF
WordPress-Powered Portfolios
PDF
Bag Of Tricks From Iusethis
PDF
Dig Deeper into WordPress - WD Meetup Cairo
KEY
Data::FormValidator Simplified
PDF
How I started to love design patterns
ZIP
First Steps in Drupal Code Driven Development
PDF
Introduction to CQRS and Event Sourcing
PPTX
Анатолий Поляков - Drupal.ajax framework from a to z
KEY
Who Needs Ruby When You've Got CodeIgniter
PDF
Symfony CoP: Form component
PDF
購物車程式架構簡介
PPTX
DrupalCamp Foz - Novas APIs Drupal 7
PPTX
11. CodeIgniter vederea unei singure inregistrari
PDF
WordPress Theme Workshop: Sidebars
PDF
Nickolay Shmalenuk.Render api eng.DrupalCamp Kyiv 2011
PPT
PHP cart
PDF
Flask 소수전공 강의자료 - 3차시
PPTX
Migration to jQuery 3.5.x
PPT
PHP webboard
PPT
Система рендеринга в Magento
WordPress-Powered Portfolios
Bag Of Tricks From Iusethis
Dig Deeper into WordPress - WD Meetup Cairo
Data::FormValidator Simplified
How I started to love design patterns
First Steps in Drupal Code Driven Development
Introduction to CQRS and Event Sourcing
Анатолий Поляков - Drupal.ajax framework from a to z
Who Needs Ruby When You've Got CodeIgniter
Symfony CoP: Form component
購物車程式架構簡介
DrupalCamp Foz - Novas APIs Drupal 7
11. CodeIgniter vederea unei singure inregistrari
WordPress Theme Workshop: Sidebars
Nickolay Shmalenuk.Render api eng.DrupalCamp Kyiv 2011
PHP cart
Flask 소수전공 강의자료 - 3차시
Migration to jQuery 3.5.x
PHP webboard
Система рендеринга в Magento
Ad

Similar to Building secured wordpress themes and plugins (20)

PDF
WordPress Security - WordCamp Phoenix
KEY
Unit testing zend framework apps
PDF
Add edit delete in Codeigniter in PHP
PDF
You Don't Know Query (WordCamp Netherlands 2012)
PDF
Unit testing with zend framework tek11
KEY
Unit testing with zend framework PHPBenelux
PPTX
Coding for Scale and Sanity
PDF
Secure Coding with WordPress - WordCamp SF 2008
DOCX
logic321
PDF
PHP-UK 2025: Ending Injection Vulnerabilities
TXT
Daily notes
PPTX
Wp query
PDF
laravel tricks in 50minutes
PDF
Min-Maxing Software Costs
PDF
Separation of concerns - DPC12
PDF
Advanced php testing in action
PDF
(PHPers Wrocław #5) How to write valuable unit test?
PPTX
[PHP] Zend_Db (Zend Framework)
PPTX
Custom Database Queries in WordPress
PPTX
Using shortcode in plugin development
WordPress Security - WordCamp Phoenix
Unit testing zend framework apps
Add edit delete in Codeigniter in PHP
You Don't Know Query (WordCamp Netherlands 2012)
Unit testing with zend framework tek11
Unit testing with zend framework PHPBenelux
Coding for Scale and Sanity
Secure Coding with WordPress - WordCamp SF 2008
logic321
PHP-UK 2025: Ending Injection Vulnerabilities
Daily notes
Wp query
laravel tricks in 50minutes
Min-Maxing Software Costs
Separation of concerns - DPC12
Advanced php testing in action
(PHPers Wrocław #5) How to write valuable unit test?
[PHP] Zend_Db (Zend Framework)
Custom Database Queries in WordPress
Using shortcode in plugin development
Ad

Recently uploaded (20)

PDF
Review of recent advances in non-invasive hemoglobin estimation
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPTX
Cloud computing and distributed systems.
PDF
Encapsulation theory and applications.pdf
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Machine learning based COVID-19 study performance prediction
PDF
Approach and Philosophy of On baking technology
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Unlocking AI with Model Context Protocol (MCP)
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Review of recent advances in non-invasive hemoglobin estimation
“AI and Expert System Decision Support & Business Intelligence Systems”
Cloud computing and distributed systems.
Encapsulation theory and applications.pdf
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Chapter 3 Spatial Domain Image Processing.pdf
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Machine learning based COVID-19 study performance prediction
Approach and Philosophy of On baking technology
Understanding_Digital_Forensics_Presentation.pptx
Advanced methodologies resolving dimensionality complications for autism neur...
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Mobile App Security Testing_ A Comprehensive Guide.pdf
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Building Integrated photovoltaic BIPV_UPV.pdf
Unlocking AI with Model Context Protocol (MCP)
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx

Building secured wordpress themes and plugins