SlideShare uma empresa Scribd logo
1 de 51
Baixar para ler offline
Secure Coding
with WordPress

        Mark Jaquith
       markjaquith.com
   coveredwebservices.com
XSS     privilege




                    shell execution
       escalation


CSRF
SQL injection
Plugin
security is
hit-or-miss
Mostly
 miss
SQL
Injection
<?php
$wpdb->query(
	 quot;UPDATE $wpdb->posts
	 SET post_title = '$newtitle'
	 WHERE ID = $my_idquot;
	 );
?>
<?php
$newtitle =
	 	 	 	 	 $wpdb->escape( $newtitle );
$my_id = absint( $my_id );

$wpdb->query(
	 quot;UPDATE $wpdb->posts
	 SET post_title = '$newtitle'
	 WHERE ID = $my_idquot;
	 );
?>
$wpdb->update()
<?php
$wpdb->update(
	 $wpdb->posts,
	 array( 'post_title' => $newtitle ),
	 array( 'ID' => $my_id )
	 );
?>
$wpdb->insert()
<?php
$wpdb->insert(
	 $wpdb->posts,
	 array( 'post_title' => $newtitle )
	 );
?>
<?php
$wpdb->update(
	 $wpdb->posts,
	 array(
	 	 'post_title' => $newtitle,
	 	 'post_content' => $newcontent ),
	 array(
	 	 'ID' => $my_id,
	 	 'post_title' => $old_title )
	 );
?>
<?php
$post_title = 'New Title';
$wheres['ID'] = 123;
$wheres['post_title'] = 'Old Title';
$wpdb->update(
	 $wpdb->posts,
	 compact( 'post_title' ),
	 $wheres
	 );
?>
$wpdb->prepare()
<?php
$title = 'Post Title';
$ID = 123;
$content = $wpdb->get_var(
	 $wpdb->prepare(
	 quot;SELECT post_content
	    FROM  $wpdb->posts
	    WHERE post_title = %s
	    AND   ID = %dquot;,
	 $title, $ID )
	 );
?>
•Uses sprintf() formatting
•%s for strings
•%d for integers
•You should not quote or
 escape
Escape
 late
XSS
<h1>
<?php
	 echo $title;
?>
</h1>
<?php
	 $title =
	 	 	 	 '<script> pwnage(); </script>'
?>
<h1>
<?php
	 echo $title;
?>
</h1>
Anything that
isn’t hardcoded
   is suspect
Better:
Everything is suspect
wp_specialchars()
<?php
	 $title =
	 	 	 	 '<script> pwnage(); </script>'
?>
<h1>
<?php
	 echo wp_specialchars( $title );
?>
</h1>
<?php
$title = 'quot; onmouseover=quot;pwnd();';
?>
<a href=quot;#wordcampquot; title=quot;
<?php
	 echo wp_specialchars( $title );
?>
quot;>
Link Text
</a>
attribute_escape()
<?php
$title = 'quot; onmouseover=quot;pwnd();';
?>
<a href=quot;#wordcampquot; title=quot;
<?php
	 echo attribute_escape( $title );
?>
quot;>
Link Text
</a>
<?php
 $url = 'javascript:pwnage();';
?>
<a href=quot;
<?php
	 echo attribute_escape( $url );
?>
quot;>
Link Text
</a>
clean_url()
<?php
 $url = 'javascript:pwnage();';
?>
<a href=quot;
<?php
	 echo clean_url( $url );
?>
quot;>
Link Text
</a>
sanitize_url(),
sister of clean_url()
js_escape()
CSRF
Authorization
     vs.

Intention
Nonces
  action-, object-,
 user-specific time
limited secret keys
Specific to
•WordPress user
•Action attempted
•Object of attempted action
•Time window
wp_nonce_field()
<form action=quot;process.phpquot;
method=quot;postquot;>
<?php
	 wp_nonce_field('plugin-action_object');
?>

...
</form>
check_admin_referer( )
<?php
// before output goes to browser
check_admin_referer('plugin-	 	 	 	 	
	 	 	 	 	 	 	 	 	 	 action_object');
?>
Still need to use
current_user_can()
AJAX
CSRF
• wp_create_nonce(   'your_action' );

• &_ajax_nonce=YOUR_NONCE
• check_ajax_referer(   'your_action' );
Privilege
Escalation
current_user_can()
Set your salts!
http://api.wordpress.org/secret-key/1.1/
Stupid shit
 I see all
 the time
exec()
<form action=quot;<?php echo
$_SERVER['REQUEST_URI']; ?>quot;>
Thank you!

Mais conteúdo relacionado

Mais procurados

pasangh bendera di blog
pasangh bendera di blogpasangh bendera di blog
pasangh bendera di blog
ellyndra
 
Maritza
MaritzaMaritza
Maritza
ladyva
 
Simple Blue Blog Template XML 的副本
Simple Blue Blog Template XML 的副本Simple Blue Blog Template XML 的副本
Simple Blue Blog Template XML 的副本
a5494535
 
Itsecteam shell
Itsecteam shellItsecteam shell
Itsecteam shell
ady36
 
Class 4 handout w css3 using j fiddle
Class 4 handout w css3 using j fiddleClass 4 handout w css3 using j fiddle
Class 4 handout w css3 using j fiddle
Erin M. Kidwell
 

Mais procurados (20)

2009 Barcamp Nashville Web Security 101
2009 Barcamp Nashville   Web Security 1012009 Barcamp Nashville   Web Security 101
2009 Barcamp Nashville Web Security 101
 
PHPUG Presentation
PHPUG PresentationPHPUG Presentation
PHPUG Presentation
 
Ae internals
Ae internalsAe internals
Ae internals
 
pasangh bendera di blog
pasangh bendera di blogpasangh bendera di blog
pasangh bendera di blog
 
Wiidget
WiidgetWiidget
Wiidget
 
Earn money with banner and text ads for Clickbank
Earn money with banner and text ads for ClickbankEarn money with banner and text ads for Clickbank
Earn money with banner and text ads for Clickbank
 
Front End on Rails
Front End on RailsFront End on Rails
Front End on Rails
 
JQuery 101
JQuery 101JQuery 101
JQuery 101
 
Maritza
MaritzaMaritza
Maritza
 
Symfony 1, mi viejo amigo
Symfony 1, mi viejo amigoSymfony 1, mi viejo amigo
Symfony 1, mi viejo amigo
 
Htm
HtmHtm
Htm
 
Page Caching Resurrected
Page Caching ResurrectedPage Caching Resurrected
Page Caching Resurrected
 
2013-06-25 - HTML5 & JavaScript Security
2013-06-25 - HTML5 & JavaScript Security2013-06-25 - HTML5 & JavaScript Security
2013-06-25 - HTML5 & JavaScript Security
 
Simple Blue Blog Template XML 的副本
Simple Blue Blog Template XML 的副本Simple Blue Blog Template XML 的副本
Simple Blue Blog Template XML 的副本
 
Top 10 php classic traps confoo
Top 10 php classic traps confooTop 10 php classic traps confoo
Top 10 php classic traps confoo
 
Itsecteam shell
Itsecteam shellItsecteam shell
Itsecteam shell
 
Web Security
Web SecurityWeb Security
Web Security
 
Flickr Open Api Mashup
Flickr Open Api MashupFlickr Open Api Mashup
Flickr Open Api Mashup
 
Routing System In Symfony 1.2
Routing System In Symfony 1.2Routing System In Symfony 1.2
Routing System In Symfony 1.2
 
Class 4 handout w css3 using j fiddle
Class 4 handout w css3 using j fiddleClass 4 handout w css3 using j fiddle
Class 4 handout w css3 using j fiddle
 

Semelhante a Secure Coding With Wordpress (BarCamp Orlando 2009)

High-level Web Testing
High-level Web TestingHigh-level Web Testing
High-level Web Testing
petersergeant
 
Optimizing Drupal for Mobile Devices
Optimizing Drupal for Mobile DevicesOptimizing Drupal for Mobile Devices
Optimizing Drupal for Mobile Devices
Sugree Phatanapherom
 
4. Метапрограмиране
4. Метапрограмиране4. Метапрограмиране
4. Метапрограмиране
Stefan Kanev
 

Semelhante a Secure Coding With Wordpress (BarCamp Orlando 2009) (20)

Introduction to CodeIgniter (RefreshAugusta, 20 May 2009)
Introduction to CodeIgniter (RefreshAugusta, 20 May 2009)Introduction to CodeIgniter (RefreshAugusta, 20 May 2009)
Introduction to CodeIgniter (RefreshAugusta, 20 May 2009)
 
Os Nixon
Os NixonOs Nixon
Os Nixon
 
Ubi comp27nov04
Ubi comp27nov04Ubi comp27nov04
Ubi comp27nov04
 
Exploiting Php With Php
Exploiting Php With PhpExploiting Php With Php
Exploiting Php With Php
 
High-level Web Testing
High-level Web TestingHigh-level Web Testing
High-level Web Testing
 
Concern of Web Application Security
Concern of Web Application SecurityConcern of Web Application Security
Concern of Web Application Security
 
Zend framework 04 - forms
Zend framework 04 - formsZend framework 04 - forms
Zend framework 04 - forms
 
Php My Sql
Php My SqlPhp My Sql
Php My Sql
 
London XQuery Meetup: Querying the World (Web Scraping)
London XQuery Meetup: Querying the World (Web Scraping)London XQuery Meetup: Querying the World (Web Scraping)
London XQuery Meetup: Querying the World (Web Scraping)
 
Daily notes
Daily notesDaily notes
Daily notes
 
Javascript Basic
Javascript BasicJavascript Basic
Javascript Basic
 
Optimizing Drupal for Mobile Devices
Optimizing Drupal for Mobile DevicesOptimizing Drupal for Mobile Devices
Optimizing Drupal for Mobile Devices
 
Back to basics - PHP_Codesniffer
Back to basics - PHP_CodesnifferBack to basics - PHP_Codesniffer
Back to basics - PHP_Codesniffer
 
Php 3 1
Php 3 1Php 3 1
Php 3 1
 
4. Метапрограмиране
4. Метапрограмиране4. Метапрограмиране
4. Метапрограмиране
 
Developing and testing ajax components
Developing and testing ajax componentsDeveloping and testing ajax components
Developing and testing ajax components
 
WordPress Plugin & Theme Security - WordCamp Melbourne - February 2011
WordPress Plugin & Theme Security - WordCamp Melbourne - February 2011WordPress Plugin & Theme Security - WordCamp Melbourne - February 2011
WordPress Plugin & Theme Security - WordCamp Melbourne - February 2011
 
Php security3895
Php security3895Php security3895
Php security3895
 
PHP Security
PHP SecurityPHP Security
PHP Security
 
Seam Glassfish Slidecast
Seam Glassfish SlidecastSeam Glassfish Slidecast
Seam Glassfish Slidecast
 

Mais de Mark Jaquith

Creating and Maintaining WordPress Plugins
Creating and Maintaining WordPress PluginsCreating and Maintaining WordPress Plugins
Creating and Maintaining WordPress Plugins
Mark Jaquith
 
WordPress Custom Post Types
WordPress Custom Post TypesWordPress Custom Post Types
WordPress Custom Post Types
Mark Jaquith
 

Mais de Mark Jaquith (13)

Cache Money Business
Cache Money BusinessCache Money Business
Cache Money Business
 
Scaling WordPress
Scaling WordPressScaling WordPress
Scaling WordPress
 
Creating and Maintaining WordPress Plugins
Creating and Maintaining WordPress PluginsCreating and Maintaining WordPress Plugins
Creating and Maintaining WordPress Plugins
 
Coding, Scaling, and Deploys... Oh My!
Coding, Scaling, and Deploys... Oh My!Coding, Scaling, and Deploys... Oh My!
Coding, Scaling, and Deploys... Oh My!
 
WordPress Custom Post Types
WordPress Custom Post TypesWordPress Custom Post Types
WordPress Custom Post Types
 
Writing Your First WordPress Plugin
Writing Your First WordPress PluginWriting Your First WordPress Plugin
Writing Your First WordPress Plugin
 
What I Hate About Wordpress
What I Hate About WordpressWhat I Hate About Wordpress
What I Hate About Wordpress
 
Writing Secure Plugins — WordCamp New York 2009
Writing Secure Plugins — WordCamp New York 2009Writing Secure Plugins — WordCamp New York 2009
Writing Secure Plugins — WordCamp New York 2009
 
BuddyPress and the Future of WordPress Plugins
BuddyPress and the Future of WordPress PluginsBuddyPress and the Future of WordPress Plugins
BuddyPress and the Future of WordPress Plugins
 
"State of the Word" at WordCamp Mid-Atlantic, by Mark Jaquith
"State of the Word" at WordCamp Mid-Atlantic, by Mark Jaquith"State of the Word" at WordCamp Mid-Atlantic, by Mark Jaquith
"State of the Word" at WordCamp Mid-Atlantic, by Mark Jaquith
 
Wordcamp Charlotte: WordPress Today and Tomorrow
Wordcamp Charlotte: WordPress Today and TomorrowWordcamp Charlotte: WordPress Today and Tomorrow
Wordcamp Charlotte: WordPress Today and Tomorrow
 
Amping up your WordPress Blog
Amping up your WordPress BlogAmping up your WordPress Blog
Amping up your WordPress Blog
 
Contributing To WordPress
Contributing To WordPressContributing To WordPress
Contributing To WordPress
 

Último

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Último (20)

Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 

Secure Coding With Wordpress (BarCamp Orlando 2009)