SlideShare une entreprise Scribd logo
1  sur  55
Dive into
                       Drupal Security
                            @greggles




Sunday, November 20, 2011
Greg Knaddison
                               Pair programmer
                                       @greggles
                                        Acquian
                            Drupal Security Team




Sunday, November 20, 2011
mobro.co/gregknaddison




Sunday, November 20, 2011
US$15 on kindle, US$26 paperback
                                  crackingdrupal.com

Sunday, November 20, 2011
Agenda


                            Overview

                            Warm up

                            CSRF, XSS code




Sunday, November 20, 2011
think like a diver




Sunday, November 20, 2011
be the attacker



                              Say hello to $user_data




Sunday, November 20, 2011
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


Sunday, November 20, 2011
Eddy Out: Definitions

                            A1 - Injection

                            A2 - XSS

                            A3 - Broken Authentication and Session Mgmt

                            A4 - Insecure Direct Object References

                            A5 - Cross Site Request Forgery



Sunday, November 20, 2011
Eddy Out: Definitions

                            A6 - Security Misconfiguration

                            A7 - Insecure Cryptographic Storage

                            A8 - Failure to Restrict URL Access

                            A9 - Insufficient Transport Layer Protection

                            A10 - Unvalidated Redirects and Forwards



Sunday, November 20, 2011
Eddy Out: Freebies

                        A3 - Broken Authentication and Session Mgmt

                        A7 - Insecure Cryptographic Storage

                        A9 - Insufficient Transport Layer Protection



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



Sunday, November 20, 2011
The basics
                             Toes in the water




Sunday, November 20, 2011
Security Review module

                            Free

                            Automated check of configurations

                            drupal.org/project/security_review

                            Demo

                            http://crackingdrupal.com/n/32



Sunday, November 20, 2011
Captaining your ship

                            ssh or sftp, but never ftp

                            shared wifi? https if you can, vpn if you can’t

                            Least privilege

                            Audit roles




Sunday, November 20, 2011
Stay up to date



                                  Seriously




Sunday, November 20, 2011
Modernize your vessel

                            Update module

                            Mailing list

                            @drupal_security

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




Sunday, November 20, 2011
Head for the lifeboats

                            Have backups

                            Test them periodically

                            Be able to restore them

                            Sanitize before traveling with them

                              http://crackingdrupal.com/n/53



Sunday, November 20, 2011
CSRF
                             Cross Site Request Forgery
                       Taking action without confirming intent.




Sunday, November 20, 2011
Taking action without confirming intent.



                                  How do we confirm intent?



                                        WTF is intent?



Sunday, November 20, 2011
<a href=”/delete/user/1”>Delete user 1</a>




Sunday, November 20, 2011
<a href=”/delete/1”>Delete user 1</a>

                                   <img src=”/delete/1”>




Sunday, November 20, 2011
CSRF Flow
                                     /user
                                      html


                                     cookie
                            Victim            Drupal




Sunday, November 20, 2011
CSRF Flow
                                     node/1
                                      html


                            Victim            Drupal




Sunday, November 20, 2011
CSRF Flow
                                     node/1
                                       html
                                     jquery.js

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

Sunday, November 20, 2011
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?




Sunday, November 20, 2011
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




Sunday, November 20, 2011
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




Sunday, November 20, 2011
Deep Dive on CSRF
Sunday, November 20, 2011
http://drupalscout.com/tags/csrf




                             CSRF Resources
Sunday, November 20, 2011
XSS
                                 aka: Cross Site Scripting
                            code in browser using your session




Sunday, November 20, 2011
XSS
                        Code

                        Running in your browser

                        Using your cookies on your site

                        Requesting, sending, reading responses

                        Browser context

                                   Does that sound familiar?


Sunday, November 20, 2011
Ajax

                                     HTML
                            Drupal          User
                                      JS




Sunday, November 20, 2011
Cross Site Scripting

                                              HTML
        Attacker               JS   Drupal           Victim
                                               JS




                                      = Bad

Sunday, November 20, 2011
Validate input


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




Sunday, November 20, 2011
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 filtering

                              Validation is “yes or no” - user fixes it


Sunday, November 20, 2011
Filter on output


                            “output”

                            “filter”

                            “on”




Sunday, November 20, 2011
Sunday, November 20, 2011
Output Contexts
                            Mail context

                            Database context

                            Web context

                            Server context

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


Sunday, November 20, 2011
Filtering XSS

                            Input untrusted data

                            Output browser appropriate data

                            check_plain, check_markup

                            filter_xss, filter_xss_admin

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



Sunday, November 20, 2011
Sunday, November 20, 2011
Are you my XSS?


                            drupal_set_message($user_data);

                            $output .= $node->title;

                            FAPI checkboxes, radios,
                            descriptions, etc.




Sunday, November 20, 2011
Deep Dive on XSS
Sunday, November 20, 2011
http://drupalscout.com/tags/xss




                              XSS Resources
Sunday, November 20, 2011
But Greg, only admins can enter
                                     ickyquickies.



                                  d.o/security-policy

                                        and...



Sunday, November 20, 2011
Access Bypass



Sunday, November 20, 2011
Access Bypass
                               Authentication
                               Authorization




Sunday, November 20, 2011
What is it?



                            See something they shouldn’t see

                            Do something they shouldn’t do




Sunday, November 20, 2011
Stop Access Bypass



                            Check before showing the feature

                            Check before taking action




Sunday, November 20, 2011
Where should we do this?




Sunday, November 20, 2011
Where do we check?
                            Request arrives

                            Find menu callback

                            Call it

                            Alter that

                            Preprocess it

                            Theme it


Sunday, November 20, 2011
'access callback' => TRUE,

                            Page callback

                            $form['#access'] = whatevs();

                            $form['f']['#access'] = whatevs();

                            $o = theme(‘username’, $account);



Sunday, November 20, 2011
R U my Access Bypass?

                            Menu callbacks - kind of important

                            node_access()

                            ->addTag('node_access')

                            hook_permissions/user_access




Sunday, November 20, 2011
Dive on Access Bypass
Sunday, November 20, 2011
Resources
                            drupal.org/security

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

                            drupalscout.com

                            acquia.com

                            crackingdrupal.com


Sunday, November 20, 2011
Thanks!
                                            questions?
                                              contact?
                                             @greggles
                             greg.knaddison@acquia.com




Sunday, November 20, 2011

Contenu connexe

Similaire à Intro drupal security

Macruby - RubyConf Presentation 2010
Macruby - RubyConf Presentation 2010Macruby - RubyConf Presentation 2010
Macruby - RubyConf Presentation 2010Matt Aimonetti
 
AlpesJUG - Communautés opensource, stratégies et écueils
AlpesJUG - Communautés opensource, stratégies et écueilsAlpesJUG - Communautés opensource, stratégies et écueils
AlpesJUG - Communautés opensource, stratégies et écueilsjulien.ponge
 
A Look at the Future of HTML5
A Look at the Future of HTML5A Look at the Future of HTML5
A Look at the Future of HTML5Tim Wright
 
distilling the Web of Data drop by drop (with Java)
distilling the Web of Data drop by drop (with Java)distilling the Web of Data drop by drop (with Java)
distilling the Web of Data drop by drop (with Java)Davide Palmisano
 
Layer 7 denial of services attack mitigation
Layer 7 denial of services attack mitigationLayer 7 denial of services attack mitigation
Layer 7 denial of services attack mitigationAmmar WK
 
[Wroclaw #7] Why So Serial?
[Wroclaw #7] Why So Serial?[Wroclaw #7] Why So Serial?
[Wroclaw #7] Why So Serial?OWASP
 
So, you think you know widgets.
So, you think you know widgets.So, you think you know widgets.
So, you think you know widgets.danielericlee
 
Symony2 A Next Generation PHP Framework
Symony2 A Next Generation PHP FrameworkSymony2 A Next Generation PHP Framework
Symony2 A Next Generation PHP FrameworkRyan Weaver
 
Dom XSS: Encounters of the3rd kind
Dom XSS: Encounters of the3rd kindDom XSS: Encounters of the3rd kind
Dom XSS: Encounters of the3rd kindBishan Singh
 
HTML5: A complete overview
HTML5: A complete overviewHTML5: A complete overview
HTML5: A complete overviewKristof Degrave
 
Redis and Groovy and Grails - gr8conf 2011
Redis and Groovy and Grails - gr8conf 2011Redis and Groovy and Grails - gr8conf 2011
Redis and Groovy and Grails - gr8conf 2011Ted Naleid
 

Similaire à Intro drupal security (14)

Macruby - RubyConf Presentation 2010
Macruby - RubyConf Presentation 2010Macruby - RubyConf Presentation 2010
Macruby - RubyConf Presentation 2010
 
Symfony2 and Ror3 friends for an hour
Symfony2 and Ror3 friends for an hourSymfony2 and Ror3 friends for an hour
Symfony2 and Ror3 friends for an hour
 
AlpesJUG - Communautés opensource, stratégies et écueils
AlpesJUG - Communautés opensource, stratégies et écueilsAlpesJUG - Communautés opensource, stratégies et écueils
AlpesJUG - Communautés opensource, stratégies et écueils
 
A Look at the Future of HTML5
A Look at the Future of HTML5A Look at the Future of HTML5
A Look at the Future of HTML5
 
distilling the Web of Data drop by drop (with Java)
distilling the Web of Data drop by drop (with Java)distilling the Web of Data drop by drop (with Java)
distilling the Web of Data drop by drop (with Java)
 
Layer 7 denial of services attack mitigation
Layer 7 denial of services attack mitigationLayer 7 denial of services attack mitigation
Layer 7 denial of services attack mitigation
 
[Wroclaw #7] Why So Serial?
[Wroclaw #7] Why So Serial?[Wroclaw #7] Why So Serial?
[Wroclaw #7] Why So Serial?
 
So, you think you know widgets.
So, you think you know widgets.So, you think you know widgets.
So, you think you know widgets.
 
Symony2 A Next Generation PHP Framework
Symony2 A Next Generation PHP FrameworkSymony2 A Next Generation PHP Framework
Symony2 A Next Generation PHP Framework
 
Dom XSS: Encounters of the3rd kind
Dom XSS: Encounters of the3rd kindDom XSS: Encounters of the3rd kind
Dom XSS: Encounters of the3rd kind
 
OpenDj Fossa2011
OpenDj Fossa2011OpenDj Fossa2011
OpenDj Fossa2011
 
HTML5: A complete overview
HTML5: A complete overviewHTML5: A complete overview
HTML5: A complete overview
 
Redis and Groovy and Grails - gr8conf 2011
Redis and Groovy and Grails - gr8conf 2011Redis and Groovy and Grails - gr8conf 2011
Redis and Groovy and Grails - gr8conf 2011
 
Life after sun solaris death - open dj - fossa2011
Life after sun solaris death - open dj - fossa2011Life after sun solaris death - open dj - fossa2011
Life after sun solaris death - open dj - fossa2011
 

Dernier

"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 

Dernier (20)

DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 

Intro drupal security

  • 1. Dive into Drupal Security @greggles Sunday, November 20, 2011
  • 2. Greg Knaddison Pair programmer @greggles Acquian Drupal Security Team Sunday, November 20, 2011
  • 4. US$15 on kindle, US$26 paperback crackingdrupal.com Sunday, November 20, 2011
  • 5. Agenda Overview Warm up CSRF, XSS code Sunday, November 20, 2011
  • 6. think like a diver Sunday, November 20, 2011
  • 7. be the attacker Say hello to $user_data Sunday, November 20, 2011
  • 8. 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 Sunday, November 20, 2011
  • 9. Eddy Out: Definitions A1 - Injection A2 - XSS A3 - Broken Authentication and Session Mgmt A4 - Insecure Direct Object References A5 - Cross Site Request Forgery Sunday, November 20, 2011
  • 10. Eddy Out: Definitions A6 - Security Misconfiguration A7 - Insecure Cryptographic Storage A8 - Failure to Restrict URL Access A9 - Insufficient Transport Layer Protection A10 - Unvalidated Redirects and Forwards Sunday, November 20, 2011
  • 11. Eddy Out: Freebies A3 - Broken Authentication and Session Mgmt A7 - Insecure Cryptographic Storage A9 - Insufficient Transport Layer Protection But don’t stop at the top 10...or today’s 3 Sunday, November 20, 2011
  • 12. The basics Toes in the water Sunday, November 20, 2011
  • 13. Security Review module Free Automated check of configurations drupal.org/project/security_review Demo http://crackingdrupal.com/n/32 Sunday, November 20, 2011
  • 14. Captaining your ship ssh or sftp, but never ftp shared wifi? https if you can, vpn if you can’t Least privilege Audit roles Sunday, November 20, 2011
  • 15. Stay up to date Seriously Sunday, November 20, 2011
  • 16. Modernize your vessel Update module Mailing list @drupal_security rss: d.o/security/ d.o/security/contrib etc. Sunday, November 20, 2011
  • 17. Head for the lifeboats Have backups Test them periodically Be able to restore them Sanitize before traveling with them http://crackingdrupal.com/n/53 Sunday, November 20, 2011
  • 18. CSRF Cross Site Request Forgery Taking action without confirming intent. Sunday, November 20, 2011
  • 19. Taking action without confirming intent. How do we confirm intent? WTF is intent? Sunday, November 20, 2011
  • 20. <a href=”/delete/user/1”>Delete user 1</a> Sunday, November 20, 2011
  • 21. <a href=”/delete/1”>Delete user 1</a> <img src=”/delete/1”> Sunday, November 20, 2011
  • 22. CSRF Flow /user html cookie Victim Drupal Sunday, November 20, 2011
  • 23. CSRF Flow node/1 html Victim Drupal Sunday, November 20, 2011
  • 24. CSRF Flow node/1 html jquery.js Victim js Drupal foo.css cookie css delete/1 object deleted etc. in db Sunday, November 20, 2011
  • 25. 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? Sunday, November 20, 2011
  • 26. 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 Sunday, November 20, 2011
  • 27. 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 Sunday, November 20, 2011
  • 28. Deep Dive on CSRF Sunday, November 20, 2011
  • 29. http://drupalscout.com/tags/csrf CSRF Resources Sunday, November 20, 2011
  • 30. XSS aka: Cross Site Scripting code in browser using your session Sunday, November 20, 2011
  • 31. XSS Code Running in your browser Using your cookies on your site Requesting, sending, reading responses Browser context Does that sound familiar? Sunday, November 20, 2011
  • 32. Ajax HTML Drupal User JS Sunday, November 20, 2011
  • 33. Cross Site Scripting HTML Attacker JS Drupal Victim JS = Bad Sunday, November 20, 2011
  • 34. Validate input “Why would I ever want javascript in a node title?” -developer who forgot to filter on output Sunday, November 20, 2011
  • 35. 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 filtering Validation is “yes or no” - user fixes it Sunday, November 20, 2011
  • 36. Filter on output “output” “filter” “on” Sunday, November 20, 2011
  • 38. Output Contexts Mail context Database context Web context Server context http://acko.net/blog/safe-string-theory-for- the-web Sunday, November 20, 2011
  • 39. Filtering XSS Input untrusted data Output browser appropriate data check_plain, check_markup filter_xss, filter_xss_admin free: l(), t() @ and %, drupal_set_title Sunday, November 20, 2011
  • 41. Are you my XSS? drupal_set_message($user_data); $output .= $node->title; FAPI checkboxes, radios, descriptions, etc. Sunday, November 20, 2011
  • 42. Deep Dive on XSS Sunday, November 20, 2011
  • 43. http://drupalscout.com/tags/xss XSS Resources Sunday, November 20, 2011
  • 44. But Greg, only admins can enter ickyquickies. d.o/security-policy and... Sunday, November 20, 2011
  • 46. Access Bypass Authentication Authorization Sunday, November 20, 2011
  • 47. What is it? See something they shouldn’t see Do something they shouldn’t do Sunday, November 20, 2011
  • 48. Stop Access Bypass Check before showing the feature Check before taking action Sunday, November 20, 2011
  • 49. Where should we do this? Sunday, November 20, 2011
  • 50. Where do we check? Request arrives Find menu callback Call it Alter that Preprocess it Theme it Sunday, November 20, 2011
  • 51. 'access callback' => TRUE, Page callback $form['#access'] = whatevs(); $form['f']['#access'] = whatevs(); $o = theme(‘username’, $account); Sunday, November 20, 2011
  • 52. R U my Access Bypass? Menu callbacks - kind of important node_access() ->addTag('node_access') hook_permissions/user_access Sunday, November 20, 2011
  • 53. Dive on Access Bypass Sunday, November 20, 2011
  • 54. Resources drupal.org/security groups.drupal.org/best-practices-drupal- security drupalscout.com acquia.com crackingdrupal.com Sunday, November 20, 2011
  • 55. Thanks! questions? contact? @greggles greg.knaddison@acquia.com Sunday, November 20, 2011