SlideShare ist ein Scribd-Unternehmen logo
1 von 54
Downloaden Sie, um offline zu lesen
Dive into
                       Drupal Security
                            @greggles




Friday, May 18, 2012
Greg Knaddison
                          Pair programmer
                                  @greggles
                                   Acquian
                       Drupal Security Team




Friday, May 18, 2012
US$15 on kindle, US$26 paperback
                             crackingdrupal.com

Friday, May 18, 2012
Agenda


                       Overview

                       Warm up

                       CSRF, XSS, SQLi code




Friday, May 18, 2012
think like a diver




Friday, May 18, 2012
be the attacker



                         Say hello to $user_data




Friday, May 18, 2012
Drupal vulnerabilities by type

                                                 12%



                                            7%


                                       4%

                                       3%                                48%



                                        10%




                                                 16%




                  XSS                              Access Bypass                         CSRF
                  Authentication/Session           Arbitrary Code Execution              SQL Injection
                  Others
                          reported in core and contrib SAs from 6/1/2005 through 3/24/2010


Friday, May 18, 2012
Eddy Out: DeïŹnitions

                       A1 - Injection

                       A2 - XSS

                       A3 - Broken Authentication and Session Mgmt

                       A4 - Insecure Direct Object References

                       A5 - Cross Site Request Forgery



Friday, May 18, 2012
Eddy Out: DeïŹnitions

                       A6 - Security MisconïŹguration

                       A7 - Insecure Cryptographic Storage

                       A8 - Failure to Restrict URL Access

                       A9 - InsufïŹcient Transport Layer Protection

                       A10 - Unvalidated Redirects and Forwards



Friday, May 18, 2012
Eddy Out: Freebies

                       A3 - Broken Authentication and Session Mgmt

                       A7 - Insecure Cryptographic Storage

                       A9 - InsufïŹcient Transport Layer Protection



                       But don’t stop at the top 10...or today’s 3



Friday, May 18, 2012
The basics
                        Toes in the water




Friday, May 18, 2012
Security Review module

                       Free

                       Automated check of conïŹgurations

                       drupal.org/project/security_review

                       Demo

                       http://crackingdrupal.com/n/32



Friday, May 18, 2012
Captaining your ship

                       ssh or sftp, but never ftp

                       shared wiïŹ? https if you can, vpn if you can’t

                       Least privilege

                       Audit roles




Friday, May 18, 2012
Stay up to date



                             Seriously




Friday, May 18, 2012
Modernize your vessel

                        Update module (can email you)

                        Mailing list

                        @drupalsecurity

                        rss: d.o/security/ d.o/security/contrib etc.




Friday, May 18, 2012
Head for the lifeboats

                       Have backups

                       Test them periodically

                       Be able to restore them

                       Sanitize before traveling with them

                         http://crackingdrupal.com/n/53



Friday, May 18, 2012
XSS
                            aka: Cross Site Scripting
                       code in browser using your session




Friday, May 18, 2012
XSS
                       Code

                       Running in your browser

                       Using your cookies on your site

                       Requesting, sending, reading responses

                       Browser context

                                  Does that sound familiar?


Friday, May 18, 2012
Ajax

                                HTML
                       Drupal          User
                                 JS




Friday, May 18, 2012
Cross Site Scripting

                                         HTML
        Attacker          JS   Drupal           Victim
                                          JS




                                 = Bad

Friday, May 18, 2012
Validate input


                         “Why would I ever want
                        javascript in a node title?”
                           -developer who forgot to ïŹlter on output




Friday, May 18, 2012
Validate input
                       Is it an email?

                       Is it a nid (right type? that they have access to?)

                       Is this my beautiful wife?

                       Is this my beautiful house?

                                   Validation is NOT ïŹltering

                             Validation is “yes or no” - user ïŹxes it


Friday, May 18, 2012
Filter on output


                       “output”

                       â€œïŹlter”

                       “on”




Friday, May 18, 2012
Friday, May 18, 2012
Output Contexts
                       Mail context

                       Database context

                       Web context

                       Server context

                       http://acko.net/blog/safe-string-theory-for-
                       the-web


Friday, May 18, 2012
Filtering XSS

                       Input untrusted data

                       Output browser appropriate data

                       check_plain, check_markup

                       ïŹlter_xss, ïŹlter_xss_admin

                       free: l(), t() @ and %, drupal_set_title



Friday, May 18, 2012
Friday, May 18, 2012
html
                                html
                                 blah
                                html
                       <? print $node_title ?>
                                html



Friday, May 18, 2012
html
                          html
                          blah
                          html
                        <script>
                       alert(‘xss’);
                        <script>
                          html




Friday, May 18, 2012
html
                            html            html
                            blah            html
                            html            blah
                       &lt;script&gt;       html
                        alert(‘xss’);    alert(‘xss’);
                       &lt;/script&gt;      html
                            html




Friday, May 18, 2012
Are you my XSS?


                       drupal_set_message($user_data);

                       $output .= $node->title;

                       FAPI checkboxes, radios,
                       descriptions, etc.




Friday, May 18, 2012
Identifying XSS



                       <script>alert(‘xss’);</script>

                       <img src=”asdf.png” onerror=”alert(‘xss’)”>




Friday, May 18, 2012
Deep Dive on XSS
Friday, May 18, 2012
http://drupalscout.com/tags/xss




                         XSS Resources
Friday, May 18, 2012
SQL Injection



Friday, May 18, 2012
User modiïŹed data

                       Included into a query

                         Without ïŹltering




Friday, May 18, 2012
php
                            php
                       sql $user_data
                            php
                            php




Friday, May 18, 2012
php
                               php
                       sql ‘’;delete from
                              users;
                               php
                               php




Friday, May 18, 2012
Fixing SQL Injection


                       “Use Drupal’s database API”

                         Placeholders

                         DBTNG, ORM, Methods (not that complex)




Friday, May 18, 2012
Dive on SQL Injection
Friday, May 18, 2012
CSRF
                             Cross Site Request Forgery
                       Taking action without confirming intent.




Friday, May 18, 2012
Taking action without conïŹrming intent.



                             How do we conïŹrm intent?



                                   WTF is intent?



Friday, May 18, 2012
<a href=”/delete/user/1”>Delete user 1</a>




Friday, May 18, 2012
<a href=”/delete/1”>Delete user 1</a>

                              <img src=”/delete/1”>




Friday, May 18, 2012
CSRF Flow
                                /user
                                 html


                                cookie
                       Victim            Drupal




Friday, May 18, 2012
CSRF Flow
                                node/1
                                 html


                       Victim            Drupal




Friday, May 18, 2012
CSRF Flow
                                node/1
                                  html
                                jquery.js

                       Victim       js      Drupal
                                foo.css
                       cookie
                                   css
                                delete/1
                                                     object deleted
                                  etc.                   in db

Friday, May 18, 2012
How do you exploit it?

                        URL Shorteners

                        <img src=”http://example.com/delete/2”>

                        Send a message to a site admin

                          What is my email address or twitter?




Friday, May 18, 2012
Are you my CSRF?


                       menu call back with an action verb and not
                       drupal_get_form

                       directly use $_POST, $_GET, arg(), menu object

                       not using form_submit OR drupal_get_token




Friday, May 18, 2012
Tokens (aka nonce)

                       Form API includes tokens by default

                       do form, form_validate, form_submit

                         don’t $_POST

                       OR: drupal_get_token, drupal_valid_token




Friday, May 18, 2012
Deep Dive on CSRF
Friday, May 18, 2012
http://drupalscout.com/tags/csrf




                        CSRF Resources
Friday, May 18, 2012
Resources
                       drupal.org/security

                       groups.drupal.org/best-practices-drupal-
                       security

                       drupalscout.com

                       acquia.com

                       crackingdrupal.com


Friday, May 18, 2012
Thanks!
                                       questions?
                                         contact?
                                        @greggles
                        greg.knaddison@acquia.com




Friday, May 18, 2012

Weitere Àhnliche Inhalte

Ähnlich wie Drupal Security Dive Into the Code

Protect you site from CSRF
Protect you site from CSRFProtect you site from CSRF
Protect you site from CSRF
Acquia
 
Gluecon miller horizon
Gluecon miller horizonGluecon miller horizon
Gluecon miller horizon
Mike Miller
 
A JCR View of the World - adaptTo() 2012 Berlin
A JCR View of the World - adaptTo() 2012 BerlinA JCR View of the World - adaptTo() 2012 Berlin
A JCR View of the World - adaptTo() 2012 Berlin
Alexander Klimetschek
 
Desperately seeking a lightweight Perl framework
Desperately seeking a lightweight Perl frameworkDesperately seeking a lightweight Perl framework
Desperately seeking a lightweight Perl framework
Peter Edwards
 
CodeCamp Iasi 10 march 2012 - Infrastructure as code
CodeCamp Iasi 10 march 2012 - Infrastructure as codeCodeCamp Iasi 10 march 2012 - Infrastructure as code
CodeCamp Iasi 10 march 2012 - Infrastructure as code
Codecamp Romania
 
Current Testing Challenges Ireland
Current Testing Challenges IrelandCurrent Testing Challenges Ireland
Current Testing Challenges Ireland
David O'Dowd
 
Building real time apps with node.js, socket.io, knockout.js
Building real time apps with node.js, socket.io, knockout.jsBuilding real time apps with node.js, socket.io, knockout.js
Building real time apps with node.js, socket.io, knockout.js
betabeers
 

Ähnlich wie Drupal Security Dive Into the Code (20)

Symfony2 and MongoDB
Symfony2 and MongoDBSymfony2 and MongoDB
Symfony2 and MongoDB
 
Protect you site from CSRF
Protect you site from CSRFProtect you site from CSRF
Protect you site from CSRF
 
Sandboxing JS and HTML. A lession Learned
Sandboxing JS and HTML. A lession LearnedSandboxing JS and HTML. A lession Learned
Sandboxing JS and HTML. A lession Learned
 
No-Java Enterprise Applications: It’s All About JavaScript [DEV5107]
No-Java Enterprise Applications: It’s All About JavaScript [DEV5107]No-Java Enterprise Applications: It’s All About JavaScript [DEV5107]
No-Java Enterprise Applications: It’s All About JavaScript [DEV5107]
 
Humans Are The Weakest Link – How DLP Can Help
Humans Are The Weakest Link – How DLP Can HelpHumans Are The Weakest Link – How DLP Can Help
Humans Are The Weakest Link – How DLP Can Help
 
Best Practices for Interoperable XML Databinding with JAXB
Best Practices for Interoperable XML Databinding with JAXBBest Practices for Interoperable XML Databinding with JAXB
Best Practices for Interoperable XML Databinding with JAXB
 
Gluecon miller horizon
Gluecon miller horizonGluecon miller horizon
Gluecon miller horizon
 
HTML5 Real-Time and Connectivity
HTML5 Real-Time and ConnectivityHTML5 Real-Time and Connectivity
HTML5 Real-Time and Connectivity
 
Enyo for JS Nerds - Austin JS Meetup, April 2012
Enyo for JS Nerds - Austin JS Meetup, April 2012Enyo for JS Nerds - Austin JS Meetup, April 2012
Enyo for JS Nerds - Austin JS Meetup, April 2012
 
A JCR View of the World - adaptTo() 2012 Berlin
A JCR View of the World - adaptTo() 2012 BerlinA JCR View of the World - adaptTo() 2012 Berlin
A JCR View of the World - adaptTo() 2012 Berlin
 
GAS - Google Analytics on Steroids
GAS - Google Analytics on SteroidsGAS - Google Analytics on Steroids
GAS - Google Analytics on Steroids
 
Cached and Confused: Web Cache Deception in the Wild
Cached and Confused: Web Cache Deception in the WildCached and Confused: Web Cache Deception in the Wild
Cached and Confused: Web Cache Deception in the Wild
 
Sightly_techInsight
Sightly_techInsightSightly_techInsight
Sightly_techInsight
 
çœ‘ç«™ć‰æź”æ€§èƒœäŒ˜ćŒ–-擁揋äș’抚
 çœ‘ç«™ć‰æź”æ€§èƒœäŒ˜ćŒ–-擁揋äș’抚 çœ‘ç«™ć‰æź”æ€§èƒœäŒ˜ćŒ–-擁揋äș’抚
çœ‘ç«™ć‰æź”æ€§èƒœäŒ˜ćŒ–-擁揋äș’抚
 
Lessons Learned Migrating 2+ Billion Documents at Craigslist
Lessons Learned Migrating 2+ Billion Documents at CraigslistLessons Learned Migrating 2+ Billion Documents at Craigslist
Lessons Learned Migrating 2+ Billion Documents at Craigslist
 
Desperately seeking a lightweight Perl framework
Desperately seeking a lightweight Perl frameworkDesperately seeking a lightweight Perl framework
Desperately seeking a lightweight Perl framework
 
CodeCamp Iasi 10 march 2012 - Infrastructure as code
CodeCamp Iasi 10 march 2012 - Infrastructure as codeCodeCamp Iasi 10 march 2012 - Infrastructure as code
CodeCamp Iasi 10 march 2012 - Infrastructure as code
 
Current Testing Challenges Ireland
Current Testing Challenges IrelandCurrent Testing Challenges Ireland
Current Testing Challenges Ireland
 
Janet Gregory presents Current Testing Challenges with SoftTest Ireland
Janet Gregory presents Current Testing Challenges with SoftTest IrelandJanet Gregory presents Current Testing Challenges with SoftTest Ireland
Janet Gregory presents Current Testing Challenges with SoftTest Ireland
 
Building real time apps with node.js, socket.io, knockout.js
Building real time apps with node.js, socket.io, knockout.jsBuilding real time apps with node.js, socket.io, knockout.js
Building real time apps with node.js, socket.io, knockout.js
 

KĂŒrzlich hochgeladen

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 

KĂŒrzlich hochgeladen (20)

Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Mcleodganj Call Girls đŸ„° 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls đŸ„° 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls đŸ„° 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls đŸ„° 8617370543 Service Offer VIP Hot Model
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
AI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by Anitaraj
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
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
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptx
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
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
 
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
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 

Drupal Security Dive Into the Code

  • 1. Dive into Drupal Security @greggles Friday, May 18, 2012
  • 2. Greg Knaddison Pair programmer @greggles Acquian Drupal Security Team Friday, May 18, 2012
  • 3. US$15 on kindle, US$26 paperback crackingdrupal.com Friday, May 18, 2012
  • 4. Agenda Overview Warm up CSRF, XSS, SQLi code Friday, May 18, 2012
  • 5. think like a diver Friday, May 18, 2012
  • 6. be the attacker Say hello to $user_data Friday, May 18, 2012
  • 7. Drupal vulnerabilities by type 12% 7% 4% 3% 48% 10% 16% XSS Access Bypass CSRF Authentication/Session Arbitrary Code Execution SQL Injection Others reported in core and contrib SAs from 6/1/2005 through 3/24/2010 Friday, May 18, 2012
  • 8. Eddy Out: DeïŹnitions A1 - Injection A2 - XSS A3 - Broken Authentication and Session Mgmt A4 - Insecure Direct Object References A5 - Cross Site Request Forgery Friday, May 18, 2012
  • 9. Eddy Out: DeïŹnitions A6 - Security MisconïŹguration A7 - Insecure Cryptographic Storage A8 - Failure to Restrict URL Access A9 - InsufïŹcient Transport Layer Protection A10 - Unvalidated Redirects and Forwards Friday, May 18, 2012
  • 10. Eddy Out: Freebies A3 - Broken Authentication and Session Mgmt A7 - Insecure Cryptographic Storage A9 - InsufïŹcient Transport Layer Protection But don’t stop at the top 10...or today’s 3 Friday, May 18, 2012
  • 11. The basics Toes in the water Friday, May 18, 2012
  • 12. Security Review module Free Automated check of conïŹgurations drupal.org/project/security_review Demo http://crackingdrupal.com/n/32 Friday, May 18, 2012
  • 13. Captaining your ship ssh or sftp, but never ftp shared wiïŹ? https if you can, vpn if you can’t Least privilege Audit roles Friday, May 18, 2012
  • 14. Stay up to date Seriously Friday, May 18, 2012
  • 15. Modernize your vessel Update module (can email you) Mailing list @drupalsecurity rss: d.o/security/ d.o/security/contrib etc. Friday, May 18, 2012
  • 16. Head for the lifeboats Have backups Test them periodically Be able to restore them Sanitize before traveling with them http://crackingdrupal.com/n/53 Friday, May 18, 2012
  • 17. XSS aka: Cross Site Scripting code in browser using your session Friday, May 18, 2012
  • 18. XSS Code Running in your browser Using your cookies on your site Requesting, sending, reading responses Browser context Does that sound familiar? Friday, May 18, 2012
  • 19. Ajax HTML Drupal User JS Friday, May 18, 2012
  • 20. Cross Site Scripting HTML Attacker JS Drupal Victim JS = Bad Friday, May 18, 2012
  • 21. Validate input “Why would I ever want javascript in a node title?” -developer who forgot to ïŹlter on output Friday, May 18, 2012
  • 22. Validate input Is it an email? Is it a nid (right type? that they have access to?) Is this my beautiful wife? Is this my beautiful house? Validation is NOT ïŹltering Validation is “yes or no” - user ïŹxes it Friday, May 18, 2012
  • 23. Filter on output “output” â€œïŹlter” “on” Friday, May 18, 2012
  • 25. Output Contexts Mail context Database context Web context Server context http://acko.net/blog/safe-string-theory-for- the-web Friday, May 18, 2012
  • 26. Filtering XSS Input untrusted data Output browser appropriate data check_plain, check_markup ïŹlter_xss, ïŹlter_xss_admin free: l(), t() @ and %, drupal_set_title Friday, May 18, 2012
  • 28. html html blah html <? print $node_title ?> html Friday, May 18, 2012
  • 29. html html blah html <script> alert(‘xss’); <script> html Friday, May 18, 2012
  • 30. html html html blah html html blah &lt;script&gt; html alert(‘xss’); alert(‘xss’); &lt;/script&gt; html html Friday, May 18, 2012
  • 31. Are you my XSS? drupal_set_message($user_data); $output .= $node->title; FAPI checkboxes, radios, descriptions, etc. Friday, May 18, 2012
  • 32. Identifying XSS <script>alert(‘xss’);</script> <img src=”asdf.png” onerror=”alert(‘xss’)”> Friday, May 18, 2012
  • 33. Deep Dive on XSS Friday, May 18, 2012
  • 34. http://drupalscout.com/tags/xss XSS Resources Friday, May 18, 2012
  • 36. User modiïŹed data Included into a query Without ïŹltering Friday, May 18, 2012
  • 37. php php sql $user_data php php Friday, May 18, 2012
  • 38. php php sql ‘’;delete from users; php php Friday, May 18, 2012
  • 39. Fixing SQL Injection “Use Drupal’s database API” Placeholders DBTNG, ORM, Methods (not that complex) Friday, May 18, 2012
  • 40. Dive on SQL Injection Friday, May 18, 2012
  • 41. CSRF Cross Site Request Forgery Taking action without confirming intent. Friday, May 18, 2012
  • 42. Taking action without conïŹrming intent. How do we conïŹrm intent? WTF is intent? Friday, May 18, 2012
  • 44. <a href=”/delete/1”>Delete user 1</a> <img src=”/delete/1”> Friday, May 18, 2012
  • 45. CSRF Flow /user html cookie Victim Drupal Friday, May 18, 2012
  • 46. CSRF Flow node/1 html Victim Drupal Friday, May 18, 2012
  • 47. CSRF Flow node/1 html jquery.js Victim js Drupal foo.css cookie css delete/1 object deleted etc. in db Friday, May 18, 2012
  • 48. How do you exploit it? URL Shorteners <img src=”http://example.com/delete/2”> Send a message to a site admin What is my email address or twitter? Friday, May 18, 2012
  • 49. Are you my CSRF? menu call back with an action verb and not drupal_get_form directly use $_POST, $_GET, arg(), menu object not using form_submit OR drupal_get_token Friday, May 18, 2012
  • 50. Tokens (aka nonce) Form API includes tokens by default do form, form_validate, form_submit don’t $_POST OR: drupal_get_token, drupal_valid_token Friday, May 18, 2012
  • 51. Deep Dive on CSRF Friday, May 18, 2012
  • 52. http://drupalscout.com/tags/csrf CSRF Resources Friday, May 18, 2012
  • 53. Resources drupal.org/security groups.drupal.org/best-practices-drupal- security drupalscout.com acquia.com crackingdrupal.com Friday, May 18, 2012
  • 54. Thanks! questions? contact? @greggles greg.knaddison@acquia.com Friday, May 18, 2012