SlideShare uma empresa Scribd logo
1 de 54
Baixar para ler offline
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: Definitions

                       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: Definitions

                       A6 - Security Misconfiguration

                       A7 - Insecure Cryptographic Storage

                       A8 - Failure to Restrict URL Access

                       A9 - Insufficient 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 - Insufficient 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 configurations

                       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 wifi? 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 filter 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 filtering

                             Validation is “yes or no” - user fixes it


Friday, May 18, 2012
Filter on output


                       “output”

                       “filter”

                       “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

                       filter_xss, filter_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 modified data

                       Included into a query

                         Without filtering




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 confirming intent.



                             How do we confirm 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

Mais conteúdo relacionado

Semelhante a Drupal Security Dive Into the Code

Symfony2 and MongoDB
Symfony2 and MongoDBSymfony2 and MongoDB
Symfony2 and MongoDBPablo Godel
 
Protect you site from CSRF
Protect you site from CSRFProtect you site from CSRF
Protect you site from CSRFAcquia
 
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 LearnedMinded Security
 
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]Soham Dasgupta
 
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 HelpValery Boronin
 
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 JAXBMartin Grebac
 
Gluecon miller horizon
Gluecon miller horizonGluecon miller horizon
Gluecon miller horizonMike Miller
 
HTML5 Real-Time and Connectivity
HTML5 Real-Time and ConnectivityHTML5 Real-Time and Connectivity
HTML5 Real-Time and ConnectivityPeter Lubbers
 
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 2012Ben Combee
 
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 BerlinAlexander Klimetschek
 
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 WildSajjad "JJ" Arshad
 
网站前段性能优化-品友互动
 网站前段性能优化-品友互动 网站前段性能优化-品友互动
网站前段性能优化-品友互动Shaoning Pan
 
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 CraigslistJeremy Zawodny
 
Desperately seeking a lightweight Perl framework
Desperately seeking a lightweight Perl frameworkDesperately seeking a lightweight Perl framework
Desperately seeking a lightweight Perl frameworkPeter 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 codeCodecamp Romania
 
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 IrelandDavid O'Dowd
 
Current Testing Challenges Ireland
Current Testing Challenges IrelandCurrent Testing Challenges Ireland
Current Testing Challenges IrelandDavid 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.jsbetabeers
 

Semelhante a 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
 
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
 
Current Testing Challenges Ireland
Current Testing Challenges IrelandCurrent Testing Challenges Ireland
Current Testing Challenges 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
 

Último

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
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
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
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
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
 
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
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
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
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
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
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 

Último (20)

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.
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
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
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
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
 
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
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
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
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
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
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 

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: Definitions 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: Definitions A6 - Security Misconfiguration A7 - Insecure Cryptographic Storage A8 - Failure to Restrict URL Access A9 - Insufficient 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 - Insufficient 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 configurations 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 wifi? 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 filter 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 filtering Validation is “yes or no” - user fixes it Friday, May 18, 2012
  • 23. Filter on output “output” “filter” “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 filter_xss, filter_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 modified data Included into a query Without filtering 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 confirming intent. How do we confirm intent? WTF is intent? Friday, May 18, 2012
  • 43. <a href=”/delete/user/1”>Delete user 1</a> 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