Website Security for Developers

OKC WordPress Meetup – June 2018

 

Aaron D. Campbell
@AaronCampbell

The Biggest Risk That Developers Need to Care About?

Our Code

Our Users!

Make it EASY for Users to be Secure

But Never Trust Them

Basic Principles

  1. Never trust user input.
  2. Escape as late as possible.
  3. Escape everything from untrusted sources (like databases and users), third-parties (like Twitter), etc.
  4. Never assume anything.
  5. Never trust user input.
  6. Validation/rejection is better than sanitation.
  7. Never trust user input.

Validating: Checking

  • Never rely solely on client-side validation
  • Your friends: empty()/isset(), mb_strlen()/strlen(), in_array(), is_*(), *_exists(), wp_validate_*()

Sanitizing: Cleaning

  • Never rely solely on client-side sanitation
  • Your friends: sanitize_*(), esc_url_raw(), wp_filter_post_kses(), wp_filter_nohtml_kses()

Escaping: On Output

  • Escape ALL variable output
  • Your friends: esc_*()
  • Escape Late
// Okay, but not that great
$url = esc_url( $url );
$text = esc_html( $text );
echo '<a href="'. $url . '">' . $text . '</a>';
 
// Much better!
echo '<a href="'. esc_url( $url ) . '">' . esc_html( $text ) . '</a>';

It’s not if you get attacked, but rather how you prevent it from being successful.

Gerroald Barron

Q & A

Aaron D. Campbell – @AaronCampbell
GoDaddy

Slides: https://adcwp.me/okcmeetup2018

This presentation is running on WordPress using the Presenter plugin