SlideShare a Scribd company logo
Secure Wordpress Coding
        Aaron Saray
Why Trust This Guy?
                 ● PHP programmer
                   > than a decade
                 ● Nerd since 8 yrs
                   old
                 ● MKEPUG
                 ● Author

                 ● you paid? :)
Why at WordCamp?
● I use WordPress
  ○ even programmers do, yup

● I like WordPress

● WordPress is everywhere
  ○ I actually care about the
    world... you should too!
What is Security?
● Physical, mental, emotional, resources

● Secure programming?
  ○ protecting the user from...
    ■ themselves
    ■ the bad guys
    ■ glitches
Why you should care?
Yay - it's time for everyone's favorite game show!
Myth: ...
Fact: you should care - you're a nice person.
Otherwise you wouldn't be here...
Myth: No one will attack me
Fact: Yes they will.

● No one cares about my little website

● I'm not doing anything important

● They can have it all, I have nothing they want
That's Wrong!
Examples:
● Testing Credit Cards

● Hosting bad stuff

● Stealing User Accounts (and passwords)

● installing trojans
   ○ google now hates you

● Who cares about Google ads?
   ○ They're only $0.02...
$132,994.97
Myth: PHP is so insecure that...
● Bank vault is insecure with the door open

● Haters be hatin'

● PHP users
   ○ Facebook
   ○ Yahoo
   ○ etc
     ■ if it were so bad, then why?
What Security Concerns in Web
Projects Do We Have?
● HTML begat PHP begat WordPress

 ●   SQL Injection

 ●   XSS

 ●   CSRF




 *NOTE: examples are simple, and not
 necessarily indicative of real code.
SQL Injection
● An attack that injects unknown SQL
  commands
  ○ usually done through a form filed
  ○ can be done in a query string

● Consequence?
  ○ read all data
  ○ write / update / delete
  ○ drop tables!
SQL Injection Example
SQL Injection Example



$sql = "select * from user where email='me@aaronsaray.com' and password='monkey'
SQL Injection Example
 What about password of ... say...
 x' or userid=1; --

$sql = "select * from user where email='me@aaronsaray.
com' and
password='x' or userid=1; --'";
SQL Injection Solution
Filter user input!!
Cross Site Scripting (XSS)
● An attack that allows a third party to add and
  execute client side scripts into a web page
   ○ Client side scripting (such as javascript) is fine (and
     useful)
   ○ but not if the site creator didn't approve it

● Consequence?
   ○ form submission
   ○ steal cookie (login token)
   ○ Sammy!
XSS Example
XSS Example
Is this really that bad?

Yup.
XSS Solution
Filter user input!!
Cross Site Request Forgery (CSRF)
● An attack that sends a request from a
  malicious site masquerading as a legitimate
  request.

● Submission or action originating not on your website

● Consequence?
   ○ forms submitted
   ○ any user action done
      ■ potentially authorized users without knowledge
CSRF Example
CSRF Example
CSRF Solution
Multi pronged:
● Use POST for data changes (RFC 2616)
● Use $_POST, not $_REQUEST
● Use a token
    ○ in Wordpress, they're called "nonce"
CSRF Solution
CSRF Solution
CSRF Solution in Wordpress
... so, who cares?
Wordpress is a web project

●   It's PHP
●   It's HTML
●   It's Javascript
●   It's CSS
●   It takes user input
●   It displays user input
What can I do about it?
Thanks for asking!

● Security Scanning Plugin

● Theme Creation Security

● Practice safe plugin'
If you remember just one thing...
Use these Security Plugins:

● Secure Wordpress
  http://wordpress.org/extend/plugins/secure-wordpress/


● WP Security
  http://wordpress.org/extend/plugins/wp-security-scan/
Secure Themes
●   This isn't just filler
    ○    people focus on plugins usually. *slap*

●   Things to consider:
    ○    when using other themes or child themes
    ○    creating your own theme
Themes that you... borrow
●   Everyone grabs a theme
    ○   be smart about it
    ○   if it's too good to be true...

●   Things to remember:
    ○   update themes when they ask you to
        ■    Remember the TimThumb-amo!
    ○   take a look at them
        ■    cdn.google.com/jquery.js
        ■    myhotbride.ru/funfreemoney.js
Themes that you sorta borrow
●   If you see a cool theme...
    ○   Child theme it!
    ○   Stay up to date with the parent security
and if you're in a rush...
●   Theme Authenticity Checker
    ○   http://builtbackwards.com/projects/tac/
so which security issues exist?
● All of them!
Let's check out some best practices
Use built in functions
● set_theme_mod()
● Settings API
Use built in filters
●   esc_attr()
●   esc_html()
●   esc_textarea()
●   esc_url()
●   esc_js()
●   wp_filter_kses()
Filter example
Security through Obscurity
● Not always that bad...
    ○   automated tools - why give them a freebie?

●   remove versions from your themes
Version examples...
O.P.P.
● Other People's
  Plugins!
General Security
● Security is really shared between plugins
  and themes

●   These can be applied to all of your programming, or other people's
    programming.
    ○ For security's sake - be careful when you're hacking other people's
        plugins.
2 Parts Left:
First, and foremost
●   Clean yo' house
Clean it up
●   Update your Wordpress


●   Delete old things:
    ○   plugins
    ○   themes
    ○   user uploads from that hot babe

●   http://codex.wordpress.org/Hardening_WordPress
#2, Code Securely
●   Use NONCE


●   Don't let AJAX files sit around


●   Watch your SQL
Use $wpdb
● It is a global variable
    ○ yup, I hate it too

● Use these methods instead of creating your
  new wheel

http://codex.wordpress.org/Function_Reference/wpdb_Class
$wpdb example
My Final Advice
It's Open Source Software for a reason
Aaron Saray
                     Open Source Developer
                     Milwaukee, WI
Questions?
                         http://aaronsaray.com

● Questions about        @aaronsaray
  Secure Wordpress
  Coding?
                     Milwaukee PHP Users Group
                     http://mkepug.org
                     @mkepug

More Related Content

PPTX
Pen Testing Development
PDF
Rails Girls Resources
PPTX
Pen Testing, Red Teaming, and More
PDF
What Goes In Must Come Out: Egress-Assess and Data Exfiltration
PDF
The Evil tester's Guide to Web Testing
PDF
My Bug Hunting With Open Source
PDF
Fun & profit with bug bounties
PPTX
Coding standard let’s do it
Pen Testing Development
Rails Girls Resources
Pen Testing, Red Teaming, and More
What Goes In Must Come Out: Egress-Assess and Data Exfiltration
The Evil tester's Guide to Web Testing
My Bug Hunting With Open Source
Fun & profit with bug bounties
Coding standard let’s do it

What's hot (8)

PDF
Copy & Pest - A case-study on the clipboard, blind trust and invisible cross-...
PDF
Generic Attack Detection - ph-Neutral 0x7d8
PDF
An Abusive Relationship with AngularJS
PDF
HTML5 - The Good, the Bad, the Ugly
PDF
JavaScript From Hell - CONFidence 2.0 2009
PDF
The innerHTML Apocalypse
PDF
Locking the Throne Room - How ES5+ might change views on XSS and Client Side ...
PDF
DEF CON 23 - Ryan Mitchell - separating bots from humans
Copy & Pest - A case-study on the clipboard, blind trust and invisible cross-...
Generic Attack Detection - ph-Neutral 0x7d8
An Abusive Relationship with AngularJS
HTML5 - The Good, the Bad, the Ugly
JavaScript From Hell - CONFidence 2.0 2009
The innerHTML Apocalypse
Locking the Throne Room - How ES5+ might change views on XSS and Client Side ...
DEF CON 23 - Ryan Mitchell - separating bots from humans
Ad

Viewers also liked (20)

PDF
Categories, Tags, Custom Post Types! Oh My!
PDF
Outside the WordPress Bubble
PPTX
The Best SEO Plugin for WordPress
PPTX
Website Performance, Engagement, and Leads
PDF
A Plugin For That presentation
PDF
BuddyPress Tips: How We Built chekmrk
PDF
Money Making Blogs
PPTX
Building Your First Widget
KEY
CSI: WordPress -- Getting Into the Guts
PDF
Wcoc preso
PPTX
WordPress Security & Backups 101
PDF
Optimizing WordPress Performance
KEY
Supporting Wordpress
PPTX
WordPress 101 - Foundation Friday at WordCamp Chicago 2014 #WCChi
PDF
Cómo crear plugins para Wordpress
KEY
Stop Creating Data For Sake of Creating Data
PDF
Power Up Your Non-Profit Website With WordPress
PPTX
WordPress as a CMS
PPTX
Website Security - It Begins With Good Posture
PDF
Word Camp Philly 2014: Good Content
Categories, Tags, Custom Post Types! Oh My!
Outside the WordPress Bubble
The Best SEO Plugin for WordPress
Website Performance, Engagement, and Leads
A Plugin For That presentation
BuddyPress Tips: How We Built chekmrk
Money Making Blogs
Building Your First Widget
CSI: WordPress -- Getting Into the Guts
Wcoc preso
WordPress Security & Backups 101
Optimizing WordPress Performance
Supporting Wordpress
WordPress 101 - Foundation Friday at WordCamp Chicago 2014 #WCChi
Cómo crear plugins para Wordpress
Stop Creating Data For Sake of Creating Data
Power Up Your Non-Profit Website With WordPress
WordPress as a CMS
Website Security - It Begins With Good Posture
Word Camp Philly 2014: Good Content
Ad

Similar to WordCamp Milwaukee 2012 - Aaron Saray - Secure Wordpress Coding (20)

PDF
Security .NET.pdf
PDF
Pentester++
PDF
Your first 5 PHP design patterns - ThatConference 2012
PPTX
Hacking - Breaking Into It
PDF
ShopekLobek first term work summary
ODP
Wordpress Plugins Scanner
PDF
Ever Present Persistence - Established Footholds Seen in the Wild
PDF
Harnessing the cloud_for_saa_s_hosted_platfor
ODP
Security and why you need to review yours.
PDF
Secrets of Google VRP by: Krzysztof Kotowicz, Google Security Team
PDF
Developing Applications for Android - Lecture#3
PDF
The Supporting Role of Antivirus Evasion while Persisting
PDF
Android "Fight Club" : In pursuit of APPiness -- null Humla Delhi Chapter
PPTX
Top front-end techniques for OutSystems
PDF
Training Webinar: Top front-end techniques for OutSystems
PPTX
Developing Better Software
PDF
Hacking Vulnerable Websites to Bypass Firewalls
PDF
Services, tools & practices for a software house
PDF
Best practices for JavaScript RIAs
PDF
Confessions of an Accidental Security Tester
Security .NET.pdf
Pentester++
Your first 5 PHP design patterns - ThatConference 2012
Hacking - Breaking Into It
ShopekLobek first term work summary
Wordpress Plugins Scanner
Ever Present Persistence - Established Footholds Seen in the Wild
Harnessing the cloud_for_saa_s_hosted_platfor
Security and why you need to review yours.
Secrets of Google VRP by: Krzysztof Kotowicz, Google Security Team
Developing Applications for Android - Lecture#3
The Supporting Role of Antivirus Evasion while Persisting
Android "Fight Club" : In pursuit of APPiness -- null Humla Delhi Chapter
Top front-end techniques for OutSystems
Training Webinar: Top front-end techniques for OutSystems
Developing Better Software
Hacking Vulnerable Websites to Bypass Firewalls
Services, tools & practices for a software house
Best practices for JavaScript RIAs
Confessions of an Accidental Security Tester

Recently uploaded (20)

PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Machine learning based COVID-19 study performance prediction
PPTX
Spectroscopy.pptx food analysis technology
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Electronic commerce courselecture one. Pdf
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Approach and Philosophy of On baking technology
PPTX
Programs and apps: productivity, graphics, security and other tools
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Empathic Computing: Creating Shared Understanding
Understanding_Digital_Forensics_Presentation.pptx
Machine learning based COVID-19 study performance prediction
Spectroscopy.pptx food analysis technology
Encapsulation_ Review paper, used for researhc scholars
Electronic commerce courselecture one. Pdf
Spectral efficient network and resource selection model in 5G networks
The Rise and Fall of 3GPP – Time for a Sabbatical?
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Building Integrated photovoltaic BIPV_UPV.pdf
Digital-Transformation-Roadmap-for-Companies.pptx
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Approach and Philosophy of On baking technology
Programs and apps: productivity, graphics, security and other tools
“AI and Expert System Decision Support & Business Intelligence Systems”
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
MIND Revenue Release Quarter 2 2025 Press Release
Empathic Computing: Creating Shared Understanding

WordCamp Milwaukee 2012 - Aaron Saray - Secure Wordpress Coding

  • 2. Why Trust This Guy? ● PHP programmer > than a decade ● Nerd since 8 yrs old ● MKEPUG ● Author ● you paid? :)
  • 3. Why at WordCamp? ● I use WordPress ○ even programmers do, yup ● I like WordPress ● WordPress is everywhere ○ I actually care about the world... you should too!
  • 4. What is Security? ● Physical, mental, emotional, resources ● Secure programming? ○ protecting the user from... ■ themselves ■ the bad guys ■ glitches
  • 5. Why you should care? Yay - it's time for everyone's favorite game show!
  • 6. Myth: ... Fact: you should care - you're a nice person. Otherwise you wouldn't be here...
  • 7. Myth: No one will attack me Fact: Yes they will. ● No one cares about my little website ● I'm not doing anything important ● They can have it all, I have nothing they want
  • 9. Examples: ● Testing Credit Cards ● Hosting bad stuff ● Stealing User Accounts (and passwords) ● installing trojans ○ google now hates you ● Who cares about Google ads? ○ They're only $0.02...
  • 11. Myth: PHP is so insecure that... ● Bank vault is insecure with the door open ● Haters be hatin' ● PHP users ○ Facebook ○ Yahoo ○ etc ■ if it were so bad, then why?
  • 12. What Security Concerns in Web Projects Do We Have? ● HTML begat PHP begat WordPress ● SQL Injection ● XSS ● CSRF *NOTE: examples are simple, and not necessarily indicative of real code.
  • 13. SQL Injection ● An attack that injects unknown SQL commands ○ usually done through a form filed ○ can be done in a query string ● Consequence? ○ read all data ○ write / update / delete ○ drop tables!
  • 15. SQL Injection Example $sql = "select * from user where email='me@aaronsaray.com' and password='monkey'
  • 16. SQL Injection Example What about password of ... say... x' or userid=1; -- $sql = "select * from user where email='me@aaronsaray. com' and password='x' or userid=1; --'";
  • 18. Cross Site Scripting (XSS) ● An attack that allows a third party to add and execute client side scripts into a web page ○ Client side scripting (such as javascript) is fine (and useful) ○ but not if the site creator didn't approve it ● Consequence? ○ form submission ○ steal cookie (login token) ○ Sammy!
  • 21. Is this really that bad? Yup.
  • 23. Cross Site Request Forgery (CSRF) ● An attack that sends a request from a malicious site masquerading as a legitimate request. ● Submission or action originating not on your website ● Consequence? ○ forms submitted ○ any user action done ■ potentially authorized users without knowledge
  • 26. CSRF Solution Multi pronged: ● Use POST for data changes (RFC 2616) ● Use $_POST, not $_REQUEST ● Use a token ○ in Wordpress, they're called "nonce"
  • 29. CSRF Solution in Wordpress
  • 30. ... so, who cares? Wordpress is a web project ● It's PHP ● It's HTML ● It's Javascript ● It's CSS ● It takes user input ● It displays user input
  • 31. What can I do about it? Thanks for asking! ● Security Scanning Plugin ● Theme Creation Security ● Practice safe plugin'
  • 32. If you remember just one thing... Use these Security Plugins: ● Secure Wordpress http://wordpress.org/extend/plugins/secure-wordpress/ ● WP Security http://wordpress.org/extend/plugins/wp-security-scan/
  • 33. Secure Themes ● This isn't just filler ○ people focus on plugins usually. *slap* ● Things to consider: ○ when using other themes or child themes ○ creating your own theme
  • 34. Themes that you... borrow ● Everyone grabs a theme ○ be smart about it ○ if it's too good to be true... ● Things to remember: ○ update themes when they ask you to ■ Remember the TimThumb-amo! ○ take a look at them ■ cdn.google.com/jquery.js ■ myhotbride.ru/funfreemoney.js
  • 35. Themes that you sorta borrow ● If you see a cool theme... ○ Child theme it! ○ Stay up to date with the parent security
  • 36. and if you're in a rush... ● Theme Authenticity Checker ○ http://builtbackwards.com/projects/tac/
  • 37. so which security issues exist? ● All of them!
  • 38. Let's check out some best practices
  • 39. Use built in functions ● set_theme_mod() ● Settings API
  • 40. Use built in filters ● esc_attr() ● esc_html() ● esc_textarea() ● esc_url() ● esc_js() ● wp_filter_kses()
  • 42. Security through Obscurity ● Not always that bad... ○ automated tools - why give them a freebie? ● remove versions from your themes
  • 45. General Security ● Security is really shared between plugins and themes ● These can be applied to all of your programming, or other people's programming. ○ For security's sake - be careful when you're hacking other people's plugins.
  • 47. First, and foremost ● Clean yo' house
  • 48. Clean it up ● Update your Wordpress ● Delete old things: ○ plugins ○ themes ○ user uploads from that hot babe ● http://codex.wordpress.org/Hardening_WordPress
  • 49. #2, Code Securely ● Use NONCE ● Don't let AJAX files sit around ● Watch your SQL
  • 50. Use $wpdb ● It is a global variable ○ yup, I hate it too ● Use these methods instead of creating your new wheel http://codex.wordpress.org/Function_Reference/wpdb_Class
  • 52. My Final Advice It's Open Source Software for a reason
  • 53. Aaron Saray Open Source Developer Milwaukee, WI Questions? http://aaronsaray.com ● Questions about @aaronsaray Secure Wordpress Coding? Milwaukee PHP Users Group http://mkepug.org @mkepug