SlideShare uma empresa Scribd logo
1 de 55
Baixar para ler offline
Daniel Peláez
                                dpelaez@gdssecurity.com




Security Goodness with Ruby On Rails
          SOURCE BARCELONA
           16th November 2011




                                             ©2011 Gotham Digital Science, Ltd
AGENDA



•   Who Am I?
•   Brief Introduction to Rails
•   How Secure is Ruby On Rails?
•   Auditing Applications
•   Building Secure Rails WebSites


                    Best practices, tools, security APIs.
               How to identify and fix common vulnerabilities.



                                    -2-
WHO AM I?


              IT Security Consultant at Gotham Digital Science (GDS)




o Another crazy Spaniard who recently moved to London
o I have some experience with Rails & also with Security:
   •   Pentests
   •   Source Code Reviews
   •   Consulting
   •   Blablabla :)




                                      -3-
ABOUT GDS




o Gotham Digital Science (GDS) is an international security services
  company specializing in Application and Network Infrastructure security,
  and Information Security Risk Management. GDS clients number among
  the largest financial services institutions and software development
  companies in the world.

o Offices in London and New York City




                                    -4-
ABOUT GDS



o Tools & Papers:
    o Padbuster, Blazentoo, GwtEnum … etc
o Publications with GDS Contributing Authors:




                                        -5-
Overview of what is Rails

BRIEF INTRODUCTION
SECURITY GOODNESS WITH RUBY ON RAILS




                            -6-
BRIEF INTRODUCTION TO RAILS




                www.rubyonrails.org




          -7-
BRIEF INTRODUCTION TO RAILS

• WebSite Industries




                       -8-
BRIEF INTRODUCTION TO RAILS

• Who uses Rails?
   Twitter (In the early days)            Hulu
   Groupon                                Zendesk
   Linkedin                               YellowPages
   Github                                 OneHub
   Basecamp                               Jobster
   SlideShare                             Heroku
   Funny or Die                           Rackspace
   Scribd                                 Engine Yard
   CrunchBase                             Shopify



                                  -9-
BRIEF INTRODUCTION TO RAILS

• Hulu.com




                       - 10 -
BRIEF INTRODUCTION TO RAILS

• basecamphq.com




                    - 11 -
BRIEF INTRODUCTION TO RAILS

• GitHub.com




                    - 12 -
Philosophy and Design

BRIEF INTRODUCTION
SECURITY GOODNESS WITH RUBY ON RAILS




                        - 13 -
BRIEF INTRODUCTION TO RAILS

• Ruby            • PHP                 • Java               • Python
   – Rails             –   Zend               –   Struts          –   Django
   – Sinatra           –   CakePHP            –   Spring          –   Pylons
   – Merb*             –   Symfony            –   Stripes         –   Zope
                       –   Zoop               –   Hivemind        –   TurboGears
                       –   Akelos             –   JBoss


                            FRAMEWORK
               Model-View-Controller (MVC) architecture pattern

         CONVENTION OVER CONFIGURATION (COC)
             DON’T REPEAT YOURSELF (DRY)
                                     - 14 -
BRIEF INTRODUCTION TO RAILS

    Rails Components & MVC




            - 15 -
BRIEF INTRODUCTION TO RAILS

    Rails Components & MVC




            - 16 -
BRIEF INTRODUCTION TO RAILS

                     Model-View-Controller (MVC) architecture pattern

•   Action Controller
     –   Processes incoming requests to a Rails application, extracts parameters, and dispatches them to the
         intended action.
     –   Services provided by Action Controller include session management, template rendering, and
         redirect management.
•   Action View
     –   It can create both HTML and XML output by default.
     –   Manages rendering templates, including nested and partial templates, and includes built-in AJAX
         support.
•   Action Dispatch
     –   Handles routing of web requests and dispatches them as you want, either to your application or any
         other Rack application.
•   Active Record
     –   It provides database independence, basic CRUD functionality, advanced finding capabilities, and the
         ability to relate models to one another, among other services.
•   Active Model
     –   Interface between the Action Pack gem services and Object Relationship Mapping gems such as
         Active Record. Active Model allows Rails to utilize other ORM frameworks in place of Active Record.




                                                  - 17 -
BRIEF INTRODUCTION TO RAILS

 Generic Rails Architecture Diagram




               - 18 -
BRIEF INTRODUCTION TO RAILS


• REST (Representational State Transfer)
   – Using resource identifiers such as URLs to represent resources.
   – Transferring representations of the state of that resource
     between system components.
   –   GET /orders/17
   –   PUT /orders/26
   –   POST /orders/17
   –   DELETE /orders/26




                                - 19 -
BRIEF INTRODUCTION TO RAILS




          - 20 -
BRIEF INTRODUCTION TO RAILS




          - 21 -
BRIEF INTRODUCTION TO RAILS




          - 22 -
BRIEF INTRODUCTION TO RAILS




          - 23 -
BRIEF INTRODUCTION TO RAILS




          - 24 -
Tools – Vulnerabilities - Recommendations

AUDITING APPLICATIONS
SECURITY GOODNESS WITH RUBY ON RAILS




                                    - 25 -
AUDITING RAILS APPLICATIONS

                            The Basic Defense Points

• Authentication:
    – Is the application enforcing an acceptable password policy for users?
    – Can the authentication process be bypassed?
• Authorization:
    – Does the application have authorization checks for all default and custom
      actions?
• Data Protection:
    – Are sensitive database fields encrypted or hashed?
    – Is TLS / SSL enforced during the transmission of sensitive information such
      as passwords or credit card numbers?
• Input Validation & Sanitization:
    – Is all input validated on the server?
    – When displaying information, are we sanitizing the output?

                                     - 26 -
AUDITING RAILS APPLICATIONS

            Information Leaks: How to Identify Rails WebSites

• MONGREL
  Server: Mongrel 1.1.5
• APACHE
  Server: Apache/1.3.34 (Unix) mod_deflate/1.0.21
    mod_fastcgi/2.4.2 mod_ssl/2.8.25 OpenSSL/0.9.7e-p1
• NGINX
   X-Powered-By: Phusion Passenger (mod_rails/mod_rack) 3.0.7
   X-Runtime: 0.008653
   Server: nginx/1.0.0 + Phusion Passenger 3.0.7
     (mod_rails/mod_rack)


                                 - 27 -
AUDITING RAILS APPLICATIONS

                        Removing HTTP Headers

• APACHE
  Add these lines to httpd.conf
       Header always unset "X-Powered-By"
       Header always unset "X-Runtime"
       Header always unset "Server"
• NGINX
   Add this directive to HttpHeadersMoreModule
       more_clear_headers Server X-Powered-By X-Runtime;




                                  - 28 -
AUDITING RAILS APPLICATIONS

               Information Leaks: How to Identify Rails WebSites

• Default Static Files:
   –   /javascripts/application.js
   –   /javascripts/prototype.js
   –   /stylesheets/application.css
   –   /images/rails.png
• Pretty URLs (RESTful):
   –   /posts/32/edit
   –   /project/create
   –   /folders/delete/54
   –   /users/81


                                    - 29 -
AUDITING RAILS APPLICATIONS

             Information Leaks: How to Identify Rails WebSites

• Different default pages depending on Rails version
• Default templates for 404 and 500 status pages
• 422.html only in applications generated with Rails >= 2.0




                                  - 30 -
AUDITING RAILS APPLICATIONS

             Information Leaks: How to Identify Rails WebSites

• Stack Traces / error pages




                                  - 31 -
AUDITING RAILS APPLICATIONS

                   Vulnerabilities: Mass Assignment

• Assign all the values received from a Form to model attributes
• Example: User sign-up process




                                - 32 -
AUDITING RAILS APPLICATIONS

                  Vulnerabilities: Mass Assignment




• What if ...




                               - 33 -
AUDITING RAILS APPLICATIONS

                   Vulnerabilities: Mass Assignment

• REMEDIATION:
  – Use attr_protected or attr_accessible




                                - 34 -
AUDITING RAILS APPLICATIONS

                    Vulnerabilities: Cross Site Scripting (XSS)
               <script>alert(‘Hello:I am not just a popup’)</script>


• Formatting Allowed?
   – Use HTML and remove unwanted tags and attributes
• Earlier versions of Rails:
   – Blacklist approach for the strip_tags(), strip_links() and sanitize()
     helpers.
   – Injection was possible:
    strip_tags("some<<b>script>alert('hello')<</b>/script>")




                                      - 35 -
AUDITING RAILS APPLICATIONS

                   Vulnerabilities: Cross Site Scripting (XSS)

• Updated Rails 2 sanitize() helper
   – Removes protocols like “javascript:”
   – Filters HTML nodes and attributes
   – Handles unicode/ascii/hex hacks


• Second step to protect against xss:
   – Rails h() helper to HTML escape user input (easy to forget)
   – escape_javascript()
   – safeERB plugin. Raises an exception whenever a tainted string is not
     escaped
   – rails_xss plugin (Rails 2.3)

                                     - 36 -
AUDITING RAILS APPLICATIONS

                    Vulnerabilities: Cross Site Scripting (XSS)

• Sanitize method:
   – Whitelisting (since Rails 2)




• Rails 3:
   –   Strings inside views are “automagically” scaped
   –   Tainted strings? --> Call "tainted text".html_safe
   –   Show the string as it is? raw("I am tainted, you know ...”)
   –   XSS protection based on rails_xss plugin

                                      - 37 -
AUDITING RAILS APPLICATIONS

   Vulnerabilities: SQL Injection




              - 38 -
AUDITING RAILS APPLICATIONS

                        Vulnerabilities: SQL Injection


• SELECT * FROM usuarios WHERE (nombre = '' AND password = '' ) LIMIT 1

• INPUT: something ' OR 'a'='a


• SELECT * FROM usuarios WHERE (nombre = 'GDS'
  AND password = 'something' OR 'a' = 'a' ) LIMIT 1




                                   - 39 -
AUDITING RAILS APPLICATIONS

                            Vulnerabilities: SQL Injection


• The right way:
    – Use the methods find_(id) or dynamic methods such as: find_by_something(something)
    – Use find conditions with named bind variables:

Usuario.find(:first, :conditions => ["nombre = ? AND password = ?",
  nombre_usuario, clave])

Usuario.find(:first, :conditions => {:nombre => nombre_usuario,
  :password => clave})

• If using connection.execute() or Model.find_by_sql() custom
  filtering needs to be implemented


                                        - 40 -
AUDITING RAILS APPLICATIONS

              Vulnerabilities: Cross Site Request Forgery (CSRF)

• Is the security token active in the controller?
   – protect_from_forgery :secret =>
     "123456789012345678901234567890"
• This does not check requests to XML APIs
• Restrict specific actions to specific HTTP methods:
verify :method => :delete, :only => [:destroy], :redirect_to =>
  {:action => :denegar}
         <img src="http://dominio/projecto/1/destroy">



                                    - 41 -
AUDITING RAILS APPLICATIONS

                  Vulnerabilities: Command Execution

• Ruby command execution:
   –   exec(command)
   –   system(command)         system(command, parameters)
   –   syscall(command)
   –   `command`




                                - 42 -
AUDITING RAILS APPLICATIONS

                   Vulnerabilities: Command Execution

• Redmine SCM Repository Arbitrary Command Execution:
• http://redminehost/projects/$project/repository/diff/?rev=`cmd`




                                 - 43 -
AUDITING RAILS APPLICATIONS

                         Checklist (Sort of)

• Search eRB files for <%= if its user input ensure it is HTML
  escaped
• Secure Access: check controllers and public actions
• Search for "forgery" make sure that
  config.action_controller.allow_forgery_protection = false is
  only disabled in test config
• Are passwords saved as clear-text in the db?, are being
  logged? filter_parameter_logging




                               - 44 -
AUDITING RAILS APPLICATIONS

                          Checklist (Sort of)

• Ensure private data is not stored in cookies
• Appropriate use of attr_accessible/attr_protected
• Is the application using validations inside models to prevent
  bad input?
• Are non-action controller methods private?
• Check for params[:id] usage
• Gems are up to date for latest security patches (rails security
  mailing list)
• Word search for "find", "first", and "all" "sql"
• Check for mass assignment

                                - 45 -
AUDITING RAILS APPLICATIONS

                                Tools: Brakeman

• Static analysis security scanner for Ruby on Rails
    – www.brakemanscanner.org
• Vulnerabilities Detected:
    –   Cross site scripting
    –   SQL injection
    –   Command injection
    –   Unprotected redirects
    –   Unsafe file access
    –   Version-specific security issues
    –   Unrestricted mass assignment
    –   Dangerous use of eval() Default routes
    –   Insufficient model validation


                                    - 46 -
AUDITING RAILS APPLICATIONS

                    Tools: Brakeman

• Using Brakeman



            gem install brakeman
     brakeman –p /path_to_your_rails_app




                        - 47 -
AUDITING RAILS APPLICATIONS

       Tools: Brakeman




           - 48 -
Tips – Gems – Plugins

BUILDING SECURE APPLICATIONS
SECURITY GOODNESS WITH RUBY ON RAILS




                        - 49 -
BUILDING SECURE APPLICATIONS

                      Recommendations: File uploads

•   Analyze the files with Antivirus
•   Random name. Save outside DocumentRoot
•   Avoid potential DOS (asyncronous tasks). Resque to the rescue!
•   Validate the MIME type
•   Ruby binding to libmagic (ruby-filemagic)
•   shared-mime-info gem. Not recognized? Modify MIME.check(file)
•   Serving the files later? send_file :disposition => 'attachment’




                                 - 50 -
BUILDING SECURE APPLICATIONS

                              Tips: Authentication

• Popular authentication plugins:
   – RestfulAuthentication
   – Authlogic

• Popular SSO systems:

   –   OpenID
   –   CAS
   –   Kerberos
   –   GSS-API
   –   SPNEGO
   –   OAuth (gem install oauth)
   –   LDAP (gem install ruby-net-ldap)

                                     - 51 -
BUILDING SECURE APPLICATIONS

                          Tips: Authorization

• Mandatory access control (MAC):
   – Grants access based on the sensitivity of the information (i.e.,
     clearance)
   – Example: Government information classification, such as Secret
     or Top Secret
• Discretionary access control (DAC):
   – Grants access to objects based on the identity of subjects
     and/or groups to which they belong.
   – Example: Windows and Unix file permissions
• Role-based access control (RBAC):
   – Access to actions is controlled through permission based on role
     assignments, not at the level of individual data objects.
   – Example: Active Directory

                                - 52 -
BUILDING SECURE APPLICATIONS

                       Tips: Authorization

• Simple Solutions: role_requirement
  (http://code.google.com/p/rolerequirement/).
• Complex Scenarios: DeclarativeAuthorization plugin (RBAC)
  (http://github.com/stffn/declarative_authorization)

• Other interesting plugins:
• ActiveRbac (http://active-rbac.rubyforge.org/).
• ModelSecurity
  (http://perens.com/FreeSoftware/ModelSecurity/).


                             - 53 -
BUILDING SECURE APPLICATIONS

                   Tips: Admin Interface & good practices

• Isolate administrative interface (subdomain, authentication,
  restricted)
• Check request.remote_ip
• Digital Certificates
• Two factor auth (ROTP - The Ruby One Time Password Library
  https://github.com/mdp/rotp)
• Alerts (invalid logins, suspicious activity)
• Mandatory use of secure protocols
  (ActionController::Base.session_options[:session_secure] = true)
• Cookies with httponly and secure flags
• Deployment:
   – Passwords inside database.yml
   – Subversion files
   – Test files

                                   - 54 -
THANKS FOR COMING! ANY QUESTIONS?




    dpelaez@gdssecurity.com

            - 55 -

Mais conteúdo relacionado

Mais procurados

Introduction to Ruby on Rails
Introduction to Ruby on RailsIntroduction to Ruby on Rails
Introduction to Ruby on RailsManoj Kumar
 
Introduction to Rails - presented by Arman Ortega
Introduction to Rails - presented by Arman OrtegaIntroduction to Rails - presented by Arman Ortega
Introduction to Rails - presented by Arman Ortegaarman o
 
Ruby on Rails workshop for beginner
Ruby on Rails workshop for beginnerRuby on Rails workshop for beginner
Ruby on Rails workshop for beginnerUmair Amjad
 
Ruby on Rails Presentation
Ruby on Rails PresentationRuby on Rails Presentation
Ruby on Rails PresentationJoost Hietbrink
 
Picking gem ruby for penetration testers
Picking gem ruby for penetration testersPicking gem ruby for penetration testers
Picking gem ruby for penetration testersPaolo Perego
 
Ruby on Rails Penetration Testing
Ruby on Rails Penetration TestingRuby on Rails Penetration Testing
Ruby on Rails Penetration Testing3S Labs
 
PECL Picks - Extensions to make your life better
PECL Picks - Extensions to make your life betterPECL Picks - Extensions to make your life better
PECL Picks - Extensions to make your life betterZendCon
 
.NET Architects Day - DNAD 2011
.NET Architects Day - DNAD 2011.NET Architects Day - DNAD 2011
.NET Architects Day - DNAD 2011Fabio Akita
 
Buildr In Action @devoxx france 2012
Buildr In Action @devoxx france 2012Buildr In Action @devoxx france 2012
Buildr In Action @devoxx france 2012alexismidon
 
Ruby on Rails survival guide of an aged Java developer
Ruby on Rails survival guide of an aged Java developerRuby on Rails survival guide of an aged Java developer
Ruby on Rails survival guide of an aged Java developergicappa
 
FITC - Here Be Dragons: Advanced JavaScript Debugging
FITC - Here Be Dragons: Advanced JavaScript DebuggingFITC - Here Be Dragons: Advanced JavaScript Debugging
FITC - Here Be Dragons: Advanced JavaScript DebuggingRami Sayar
 
Ruby on Rails : 簡介與入門
Ruby on Rails : 簡介與入門Ruby on Rails : 簡介與入門
Ruby on Rails : 簡介與入門Wen-Tien Chang
 
TorqueBox for Rubyists
TorqueBox for RubyistsTorqueBox for Rubyists
TorqueBox for Rubyistsbobmcwhirter
 
JCR - Java Content Repositories
JCR - Java Content RepositoriesJCR - Java Content Repositories
JCR - Java Content RepositoriesCarsten Ziegeler
 
DataMapper on Infinispan
DataMapper on InfinispanDataMapper on Infinispan
DataMapper on InfinispanLance Ball
 

Mais procurados (20)

Introduction to Ruby on Rails
Introduction to Ruby on RailsIntroduction to Ruby on Rails
Introduction to Ruby on Rails
 
Introduction to Rails - presented by Arman Ortega
Introduction to Rails - presented by Arman OrtegaIntroduction to Rails - presented by Arman Ortega
Introduction to Rails - presented by Arman Ortega
 
Ruby on Rails workshop for beginner
Ruby on Rails workshop for beginnerRuby on Rails workshop for beginner
Ruby on Rails workshop for beginner
 
Ruby on Rails Presentation
Ruby on Rails PresentationRuby on Rails Presentation
Ruby on Rails Presentation
 
Picking gem ruby for penetration testers
Picking gem ruby for penetration testersPicking gem ruby for penetration testers
Picking gem ruby for penetration testers
 
Ruby on Rails Penetration Testing
Ruby on Rails Penetration TestingRuby on Rails Penetration Testing
Ruby on Rails Penetration Testing
 
Supa fast Ruby + Rails
Supa fast Ruby + RailsSupa fast Ruby + Rails
Supa fast Ruby + Rails
 
How DSL works on Ruby
How DSL works on RubyHow DSL works on Ruby
How DSL works on Ruby
 
PECL Picks - Extensions to make your life better
PECL Picks - Extensions to make your life betterPECL Picks - Extensions to make your life better
PECL Picks - Extensions to make your life better
 
.NET Architects Day - DNAD 2011
.NET Architects Day - DNAD 2011.NET Architects Day - DNAD 2011
.NET Architects Day - DNAD 2011
 
Buildr In Action @devoxx france 2012
Buildr In Action @devoxx france 2012Buildr In Action @devoxx france 2012
Buildr In Action @devoxx france 2012
 
How Flipkart scales PHP
How Flipkart scales PHPHow Flipkart scales PHP
How Flipkart scales PHP
 
Ruby on Rails survival guide of an aged Java developer
Ruby on Rails survival guide of an aged Java developerRuby on Rails survival guide of an aged Java developer
Ruby on Rails survival guide of an aged Java developer
 
Till Vollmer Presentation
Till Vollmer PresentationTill Vollmer Presentation
Till Vollmer Presentation
 
Workin On The Rails Road
Workin On The Rails RoadWorkin On The Rails Road
Workin On The Rails Road
 
FITC - Here Be Dragons: Advanced JavaScript Debugging
FITC - Here Be Dragons: Advanced JavaScript DebuggingFITC - Here Be Dragons: Advanced JavaScript Debugging
FITC - Here Be Dragons: Advanced JavaScript Debugging
 
Ruby on Rails : 簡介與入門
Ruby on Rails : 簡介與入門Ruby on Rails : 簡介與入門
Ruby on Rails : 簡介與入門
 
TorqueBox for Rubyists
TorqueBox for RubyistsTorqueBox for Rubyists
TorqueBox for Rubyists
 
JCR - Java Content Repositories
JCR - Java Content RepositoriesJCR - Java Content Repositories
JCR - Java Content Repositories
 
DataMapper on Infinispan
DataMapper on InfinispanDataMapper on Infinispan
DataMapper on Infinispan
 

Semelhante a Security Goodness with Ruby on Rails

Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...
Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...
Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...Nilesh Panchal
 
(ARC309) Getting to Microservices: Cloud Architecture Patterns
(ARC309) Getting to Microservices: Cloud Architecture Patterns(ARC309) Getting to Microservices: Cloud Architecture Patterns
(ARC309) Getting to Microservices: Cloud Architecture PatternsAmazon Web Services
 
Cloud-native Data: Every Microservice Needs a Cache
Cloud-native Data: Every Microservice Needs a CacheCloud-native Data: Every Microservice Needs a Cache
Cloud-native Data: Every Microservice Needs a Cachecornelia davis
 
Introduction to Kong API Gateway
Introduction to Kong API GatewayIntroduction to Kong API Gateway
Introduction to Kong API GatewayYohann Ciurlik
 
Code for Startup MVP (Ruby on Rails) Session 1
Code for Startup MVP (Ruby on Rails) Session 1Code for Startup MVP (Ruby on Rails) Session 1
Code for Startup MVP (Ruby on Rails) Session 1Henry S
 
OWASP SF - Reviewing Modern JavaScript Applications
OWASP SF - Reviewing Modern JavaScript ApplicationsOWASP SF - Reviewing Modern JavaScript Applications
OWASP SF - Reviewing Modern JavaScript ApplicationsLewis Ardern
 
The Good, the Bad and the Ugly of Migrating Hundreds of Legacy Applications ...
 The Good, the Bad and the Ugly of Migrating Hundreds of Legacy Applications ... The Good, the Bad and the Ugly of Migrating Hundreds of Legacy Applications ...
The Good, the Bad and the Ugly of Migrating Hundreds of Legacy Applications ...Josef Adersberger
 
Migrating Hundreds of Legacy Applications to Kubernetes - The Good, the Bad, ...
Migrating Hundreds of Legacy Applications to Kubernetes - The Good, the Bad, ...Migrating Hundreds of Legacy Applications to Kubernetes - The Good, the Bad, ...
Migrating Hundreds of Legacy Applications to Kubernetes - The Good, the Bad, ...QAware GmbH
 
09 - Fábio Akita - Além do rails
09 - Fábio Akita - Além do rails09 - Fábio Akita - Além do rails
09 - Fábio Akita - Além do railsDNAD
 
Viridians on Rails
Viridians on RailsViridians on Rails
Viridians on RailsViridians
 
When Networks Meet Apps, Samuel Bercovici & Nati Shalom
When Networks Meet Apps, Samuel Bercovici & Nati ShalomWhen Networks Meet Apps, Samuel Bercovici & Nati Shalom
When Networks Meet Apps, Samuel Bercovici & Nati ShalomCloud Native Day Tel Aviv
 
When networks meets apps (open stack atlanta)
When networks meets apps (open stack atlanta)When networks meets apps (open stack atlanta)
When networks meets apps (open stack atlanta)Nati Shalom
 
Play Framework and Activator
Play Framework and ActivatorPlay Framework and Activator
Play Framework and ActivatorKevin Webber
 
Devopsdays london: Let’s talk about security
Devopsdays london:  Let’s talk about securityDevopsdays london:  Let’s talk about security
Devopsdays london: Let’s talk about securityJustin Cormack
 
PHP and the Cloud: The view from the bazaar
PHP and the Cloud: The view from the bazaarPHP and the Cloud: The view from the bazaar
PHP and the Cloud: The view from the bazaarvitoc
 

Semelhante a Security Goodness with Ruby on Rails (20)

Effective DevSecOps
Effective DevSecOpsEffective DevSecOps
Effective DevSecOps
 
Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...
Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...
Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...
 
(ARC309) Getting to Microservices: Cloud Architecture Patterns
(ARC309) Getting to Microservices: Cloud Architecture Patterns(ARC309) Getting to Microservices: Cloud Architecture Patterns
(ARC309) Getting to Microservices: Cloud Architecture Patterns
 
Rhodes
RhodesRhodes
Rhodes
 
Cloud-native Data: Every Microservice Needs a Cache
Cloud-native Data: Every Microservice Needs a CacheCloud-native Data: Every Microservice Needs a Cache
Cloud-native Data: Every Microservice Needs a Cache
 
Ruby On Rails
Ruby On RailsRuby On Rails
Ruby On Rails
 
Introduction to Kong API Gateway
Introduction to Kong API GatewayIntroduction to Kong API Gateway
Introduction to Kong API Gateway
 
Code for Startup MVP (Ruby on Rails) Session 1
Code for Startup MVP (Ruby on Rails) Session 1Code for Startup MVP (Ruby on Rails) Session 1
Code for Startup MVP (Ruby on Rails) Session 1
 
OWASP SF - Reviewing Modern JavaScript Applications
OWASP SF - Reviewing Modern JavaScript ApplicationsOWASP SF - Reviewing Modern JavaScript Applications
OWASP SF - Reviewing Modern JavaScript Applications
 
Intro to Sails.js
Intro to Sails.jsIntro to Sails.js
Intro to Sails.js
 
The Good, the Bad and the Ugly of Migrating Hundreds of Legacy Applications ...
 The Good, the Bad and the Ugly of Migrating Hundreds of Legacy Applications ... The Good, the Bad and the Ugly of Migrating Hundreds of Legacy Applications ...
The Good, the Bad and the Ugly of Migrating Hundreds of Legacy Applications ...
 
Migrating Hundreds of Legacy Applications to Kubernetes - The Good, the Bad, ...
Migrating Hundreds of Legacy Applications to Kubernetes - The Good, the Bad, ...Migrating Hundreds of Legacy Applications to Kubernetes - The Good, the Bad, ...
Migrating Hundreds of Legacy Applications to Kubernetes - The Good, the Bad, ...
 
09 - Fábio Akita - Além do rails
09 - Fábio Akita - Além do rails09 - Fábio Akita - Além do rails
09 - Fábio Akita - Além do rails
 
Viridians on Rails
Viridians on RailsViridians on Rails
Viridians on Rails
 
When Networks Meet Apps, Samuel Bercovici & Nati Shalom
When Networks Meet Apps, Samuel Bercovici & Nati ShalomWhen Networks Meet Apps, Samuel Bercovici & Nati Shalom
When Networks Meet Apps, Samuel Bercovici & Nati Shalom
 
When networks meets apps (open stack atlanta)
When networks meets apps (open stack atlanta)When networks meets apps (open stack atlanta)
When networks meets apps (open stack atlanta)
 
Play Framework and Activator
Play Framework and ActivatorPlay Framework and Activator
Play Framework and Activator
 
Devopsdays london: Let’s talk about security
Devopsdays london:  Let’s talk about securityDevopsdays london:  Let’s talk about security
Devopsdays london: Let’s talk about security
 
PHP and the Cloud: The view from the bazaar
PHP and the Cloud: The view from the bazaarPHP and the Cloud: The view from the bazaar
PHP and the Cloud: The view from the bazaar
 
SOHOpelessly Broken
SOHOpelessly BrokenSOHOpelessly Broken
SOHOpelessly Broken
 

Mais de Source Conference

iBanking - a botnet on Android
iBanking - a botnet on AndroidiBanking - a botnet on Android
iBanking - a botnet on AndroidSource Conference
 
I want the next generation web here SPDY QUIC
I want the next generation web here SPDY QUICI want the next generation web here SPDY QUIC
I want the next generation web here SPDY QUICSource Conference
 
From DNA Sequence Variation to .NET Bits and Bobs
From DNA Sequence Variation to .NET Bits and BobsFrom DNA Sequence Variation to .NET Bits and Bobs
From DNA Sequence Variation to .NET Bits and BobsSource Conference
 
Extracting Forensic Information From Zeus Derivatives
Extracting Forensic Information From Zeus DerivativesExtracting Forensic Information From Zeus Derivatives
Extracting Forensic Information From Zeus DerivativesSource Conference
 
How to Like Social Media Network Security
How to Like Social Media Network SecurityHow to Like Social Media Network Security
How to Like Social Media Network SecuritySource Conference
 
Wfuzz para Penetration Testers
Wfuzz para Penetration TestersWfuzz para Penetration Testers
Wfuzz para Penetration TestersSource Conference
 
Securty Testing For RESTful Applications
Securty Testing For RESTful ApplicationsSecurty Testing For RESTful Applications
Securty Testing For RESTful ApplicationsSource Conference
 
Men in the Server Meet the Man in the Browser
Men in the Server Meet the Man in the BrowserMen in the Server Meet the Man in the Browser
Men in the Server Meet the Man in the BrowserSource Conference
 
Advanced Data Exfiltration The Way Q Would Have Done It
Advanced Data Exfiltration The Way Q Would Have Done ItAdvanced Data Exfiltration The Way Q Would Have Done It
Advanced Data Exfiltration The Way Q Would Have Done ItSource Conference
 
Adapting To The Age Of Anonymous
Adapting To The Age Of AnonymousAdapting To The Age Of Anonymous
Adapting To The Age Of AnonymousSource Conference
 
Are Agile And Secure Development Mutually Exclusive?
Are Agile And Secure Development Mutually Exclusive?Are Agile And Secure Development Mutually Exclusive?
Are Agile And Secure Development Mutually Exclusive?Source Conference
 
Advanced (persistent) binary planting
Advanced (persistent) binary plantingAdvanced (persistent) binary planting
Advanced (persistent) binary plantingSource Conference
 
Legal/technical strategies addressing data risks as perimeter shifts to Cloud
Legal/technical strategies addressing data risks as perimeter shifts to CloudLegal/technical strategies addressing data risks as perimeter shifts to Cloud
Legal/technical strategies addressing data risks as perimeter shifts to CloudSource Conference
 
Who should the security team hire next?
Who should the security team hire next?Who should the security team hire next?
Who should the security team hire next?Source Conference
 
The Latest Developments in Computer Crime Law
The Latest Developments in Computer Crime LawThe Latest Developments in Computer Crime Law
The Latest Developments in Computer Crime LawSource Conference
 
How To: Find The Right Amount Of Security Spend
How To: Find The Right Amount Of Security SpendHow To: Find The Right Amount Of Security Spend
How To: Find The Right Amount Of Security SpendSource Conference
 
Everything you should already know about MS-SQL post-exploitation
Everything you should already know about MS-SQL post-exploitationEverything you should already know about MS-SQL post-exploitation
Everything you should already know about MS-SQL post-exploitationSource Conference
 

Mais de Source Conference (20)

Million Browser Botnet
Million Browser BotnetMillion Browser Botnet
Million Browser Botnet
 
iBanking - a botnet on Android
iBanking - a botnet on AndroidiBanking - a botnet on Android
iBanking - a botnet on Android
 
I want the next generation web here SPDY QUIC
I want the next generation web here SPDY QUICI want the next generation web here SPDY QUIC
I want the next generation web here SPDY QUIC
 
From DNA Sequence Variation to .NET Bits and Bobs
From DNA Sequence Variation to .NET Bits and BobsFrom DNA Sequence Variation to .NET Bits and Bobs
From DNA Sequence Variation to .NET Bits and Bobs
 
Extracting Forensic Information From Zeus Derivatives
Extracting Forensic Information From Zeus DerivativesExtracting Forensic Information From Zeus Derivatives
Extracting Forensic Information From Zeus Derivatives
 
How to Like Social Media Network Security
How to Like Social Media Network SecurityHow to Like Social Media Network Security
How to Like Social Media Network Security
 
Wfuzz para Penetration Testers
Wfuzz para Penetration TestersWfuzz para Penetration Testers
Wfuzz para Penetration Testers
 
Securty Testing For RESTful Applications
Securty Testing For RESTful ApplicationsSecurty Testing For RESTful Applications
Securty Testing For RESTful Applications
 
Esteganografia
EsteganografiaEsteganografia
Esteganografia
 
Men in the Server Meet the Man in the Browser
Men in the Server Meet the Man in the BrowserMen in the Server Meet the Man in the Browser
Men in the Server Meet the Man in the Browser
 
Advanced Data Exfiltration The Way Q Would Have Done It
Advanced Data Exfiltration The Way Q Would Have Done ItAdvanced Data Exfiltration The Way Q Would Have Done It
Advanced Data Exfiltration The Way Q Would Have Done It
 
Adapting To The Age Of Anonymous
Adapting To The Age Of AnonymousAdapting To The Age Of Anonymous
Adapting To The Age Of Anonymous
 
Are Agile And Secure Development Mutually Exclusive?
Are Agile And Secure Development Mutually Exclusive?Are Agile And Secure Development Mutually Exclusive?
Are Agile And Secure Development Mutually Exclusive?
 
Advanced (persistent) binary planting
Advanced (persistent) binary plantingAdvanced (persistent) binary planting
Advanced (persistent) binary planting
 
Legal/technical strategies addressing data risks as perimeter shifts to Cloud
Legal/technical strategies addressing data risks as perimeter shifts to CloudLegal/technical strategies addressing data risks as perimeter shifts to Cloud
Legal/technical strategies addressing data risks as perimeter shifts to Cloud
 
Who should the security team hire next?
Who should the security team hire next?Who should the security team hire next?
Who should the security team hire next?
 
The Latest Developments in Computer Crime Law
The Latest Developments in Computer Crime LawThe Latest Developments in Computer Crime Law
The Latest Developments in Computer Crime Law
 
JSF Security
JSF SecurityJSF Security
JSF Security
 
How To: Find The Right Amount Of Security Spend
How To: Find The Right Amount Of Security SpendHow To: Find The Right Amount Of Security Spend
How To: Find The Right Amount Of Security Spend
 
Everything you should already know about MS-SQL post-exploitation
Everything you should already know about MS-SQL post-exploitationEverything you should already know about MS-SQL post-exploitation
Everything you should already know about MS-SQL post-exploitation
 

Último

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
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
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
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????blackmambaettijean
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
"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
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
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
 
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
 
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
 
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
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 

Último (20)

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
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
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
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
"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
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
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
 
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.
 
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
 
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
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 

Security Goodness with Ruby on Rails

  • 1. Daniel Peláez dpelaez@gdssecurity.com Security Goodness with Ruby On Rails SOURCE BARCELONA 16th November 2011 ©2011 Gotham Digital Science, Ltd
  • 2. AGENDA • Who Am I? • Brief Introduction to Rails • How Secure is Ruby On Rails? • Auditing Applications • Building Secure Rails WebSites Best practices, tools, security APIs. How to identify and fix common vulnerabilities. -2-
  • 3. WHO AM I? IT Security Consultant at Gotham Digital Science (GDS) o Another crazy Spaniard who recently moved to London o I have some experience with Rails & also with Security: • Pentests • Source Code Reviews • Consulting • Blablabla :) -3-
  • 4. ABOUT GDS o Gotham Digital Science (GDS) is an international security services company specializing in Application and Network Infrastructure security, and Information Security Risk Management. GDS clients number among the largest financial services institutions and software development companies in the world. o Offices in London and New York City -4-
  • 5. ABOUT GDS o Tools & Papers: o Padbuster, Blazentoo, GwtEnum … etc o Publications with GDS Contributing Authors: -5-
  • 6. Overview of what is Rails BRIEF INTRODUCTION SECURITY GOODNESS WITH RUBY ON RAILS -6-
  • 7. BRIEF INTRODUCTION TO RAILS www.rubyonrails.org -7-
  • 8. BRIEF INTRODUCTION TO RAILS • WebSite Industries -8-
  • 9. BRIEF INTRODUCTION TO RAILS • Who uses Rails?  Twitter (In the early days)  Hulu  Groupon  Zendesk  Linkedin  YellowPages  Github  OneHub  Basecamp  Jobster  SlideShare  Heroku  Funny or Die  Rackspace  Scribd  Engine Yard  CrunchBase  Shopify -9-
  • 10. BRIEF INTRODUCTION TO RAILS • Hulu.com - 10 -
  • 11. BRIEF INTRODUCTION TO RAILS • basecamphq.com - 11 -
  • 12. BRIEF INTRODUCTION TO RAILS • GitHub.com - 12 -
  • 13. Philosophy and Design BRIEF INTRODUCTION SECURITY GOODNESS WITH RUBY ON RAILS - 13 -
  • 14. BRIEF INTRODUCTION TO RAILS • Ruby • PHP • Java • Python – Rails – Zend – Struts – Django – Sinatra – CakePHP – Spring – Pylons – Merb* – Symfony – Stripes – Zope – Zoop – Hivemind – TurboGears – Akelos – JBoss FRAMEWORK Model-View-Controller (MVC) architecture pattern CONVENTION OVER CONFIGURATION (COC) DON’T REPEAT YOURSELF (DRY) - 14 -
  • 15. BRIEF INTRODUCTION TO RAILS Rails Components & MVC - 15 -
  • 16. BRIEF INTRODUCTION TO RAILS Rails Components & MVC - 16 -
  • 17. BRIEF INTRODUCTION TO RAILS Model-View-Controller (MVC) architecture pattern • Action Controller – Processes incoming requests to a Rails application, extracts parameters, and dispatches them to the intended action. – Services provided by Action Controller include session management, template rendering, and redirect management. • Action View – It can create both HTML and XML output by default. – Manages rendering templates, including nested and partial templates, and includes built-in AJAX support. • Action Dispatch – Handles routing of web requests and dispatches them as you want, either to your application or any other Rack application. • Active Record – It provides database independence, basic CRUD functionality, advanced finding capabilities, and the ability to relate models to one another, among other services. • Active Model – Interface between the Action Pack gem services and Object Relationship Mapping gems such as Active Record. Active Model allows Rails to utilize other ORM frameworks in place of Active Record. - 17 -
  • 18. BRIEF INTRODUCTION TO RAILS Generic Rails Architecture Diagram - 18 -
  • 19. BRIEF INTRODUCTION TO RAILS • REST (Representational State Transfer) – Using resource identifiers such as URLs to represent resources. – Transferring representations of the state of that resource between system components. – GET /orders/17 – PUT /orders/26 – POST /orders/17 – DELETE /orders/26 - 19 -
  • 20. BRIEF INTRODUCTION TO RAILS - 20 -
  • 21. BRIEF INTRODUCTION TO RAILS - 21 -
  • 22. BRIEF INTRODUCTION TO RAILS - 22 -
  • 23. BRIEF INTRODUCTION TO RAILS - 23 -
  • 24. BRIEF INTRODUCTION TO RAILS - 24 -
  • 25. Tools – Vulnerabilities - Recommendations AUDITING APPLICATIONS SECURITY GOODNESS WITH RUBY ON RAILS - 25 -
  • 26. AUDITING RAILS APPLICATIONS The Basic Defense Points • Authentication: – Is the application enforcing an acceptable password policy for users? – Can the authentication process be bypassed? • Authorization: – Does the application have authorization checks for all default and custom actions? • Data Protection: – Are sensitive database fields encrypted or hashed? – Is TLS / SSL enforced during the transmission of sensitive information such as passwords or credit card numbers? • Input Validation & Sanitization: – Is all input validated on the server? – When displaying information, are we sanitizing the output? - 26 -
  • 27. AUDITING RAILS APPLICATIONS Information Leaks: How to Identify Rails WebSites • MONGREL Server: Mongrel 1.1.5 • APACHE Server: Apache/1.3.34 (Unix) mod_deflate/1.0.21 mod_fastcgi/2.4.2 mod_ssl/2.8.25 OpenSSL/0.9.7e-p1 • NGINX X-Powered-By: Phusion Passenger (mod_rails/mod_rack) 3.0.7 X-Runtime: 0.008653 Server: nginx/1.0.0 + Phusion Passenger 3.0.7 (mod_rails/mod_rack) - 27 -
  • 28. AUDITING RAILS APPLICATIONS Removing HTTP Headers • APACHE Add these lines to httpd.conf  Header always unset "X-Powered-By"  Header always unset "X-Runtime"  Header always unset "Server" • NGINX Add this directive to HttpHeadersMoreModule  more_clear_headers Server X-Powered-By X-Runtime; - 28 -
  • 29. AUDITING RAILS APPLICATIONS Information Leaks: How to Identify Rails WebSites • Default Static Files: – /javascripts/application.js – /javascripts/prototype.js – /stylesheets/application.css – /images/rails.png • Pretty URLs (RESTful): – /posts/32/edit – /project/create – /folders/delete/54 – /users/81 - 29 -
  • 30. AUDITING RAILS APPLICATIONS Information Leaks: How to Identify Rails WebSites • Different default pages depending on Rails version • Default templates for 404 and 500 status pages • 422.html only in applications generated with Rails >= 2.0 - 30 -
  • 31. AUDITING RAILS APPLICATIONS Information Leaks: How to Identify Rails WebSites • Stack Traces / error pages - 31 -
  • 32. AUDITING RAILS APPLICATIONS Vulnerabilities: Mass Assignment • Assign all the values received from a Form to model attributes • Example: User sign-up process - 32 -
  • 33. AUDITING RAILS APPLICATIONS Vulnerabilities: Mass Assignment • What if ... - 33 -
  • 34. AUDITING RAILS APPLICATIONS Vulnerabilities: Mass Assignment • REMEDIATION: – Use attr_protected or attr_accessible - 34 -
  • 35. AUDITING RAILS APPLICATIONS Vulnerabilities: Cross Site Scripting (XSS) <script>alert(‘Hello:I am not just a popup’)</script> • Formatting Allowed? – Use HTML and remove unwanted tags and attributes • Earlier versions of Rails: – Blacklist approach for the strip_tags(), strip_links() and sanitize() helpers. – Injection was possible: strip_tags("some<<b>script>alert('hello')<</b>/script>") - 35 -
  • 36. AUDITING RAILS APPLICATIONS Vulnerabilities: Cross Site Scripting (XSS) • Updated Rails 2 sanitize() helper – Removes protocols like “javascript:” – Filters HTML nodes and attributes – Handles unicode/ascii/hex hacks • Second step to protect against xss: – Rails h() helper to HTML escape user input (easy to forget) – escape_javascript() – safeERB plugin. Raises an exception whenever a tainted string is not escaped – rails_xss plugin (Rails 2.3) - 36 -
  • 37. AUDITING RAILS APPLICATIONS Vulnerabilities: Cross Site Scripting (XSS) • Sanitize method: – Whitelisting (since Rails 2) • Rails 3: – Strings inside views are “automagically” scaped – Tainted strings? --> Call "tainted text".html_safe – Show the string as it is? raw("I am tainted, you know ...”) – XSS protection based on rails_xss plugin - 37 -
  • 38. AUDITING RAILS APPLICATIONS Vulnerabilities: SQL Injection - 38 -
  • 39. AUDITING RAILS APPLICATIONS Vulnerabilities: SQL Injection • SELECT * FROM usuarios WHERE (nombre = '' AND password = '' ) LIMIT 1 • INPUT: something ' OR 'a'='a • SELECT * FROM usuarios WHERE (nombre = 'GDS' AND password = 'something' OR 'a' = 'a' ) LIMIT 1 - 39 -
  • 40. AUDITING RAILS APPLICATIONS Vulnerabilities: SQL Injection • The right way: – Use the methods find_(id) or dynamic methods such as: find_by_something(something) – Use find conditions with named bind variables: Usuario.find(:first, :conditions => ["nombre = ? AND password = ?", nombre_usuario, clave]) Usuario.find(:first, :conditions => {:nombre => nombre_usuario, :password => clave}) • If using connection.execute() or Model.find_by_sql() custom filtering needs to be implemented - 40 -
  • 41. AUDITING RAILS APPLICATIONS Vulnerabilities: Cross Site Request Forgery (CSRF) • Is the security token active in the controller? – protect_from_forgery :secret => "123456789012345678901234567890" • This does not check requests to XML APIs • Restrict specific actions to specific HTTP methods: verify :method => :delete, :only => [:destroy], :redirect_to => {:action => :denegar} <img src="http://dominio/projecto/1/destroy"> - 41 -
  • 42. AUDITING RAILS APPLICATIONS Vulnerabilities: Command Execution • Ruby command execution: – exec(command) – system(command) system(command, parameters) – syscall(command) – `command` - 42 -
  • 43. AUDITING RAILS APPLICATIONS Vulnerabilities: Command Execution • Redmine SCM Repository Arbitrary Command Execution: • http://redminehost/projects/$project/repository/diff/?rev=`cmd` - 43 -
  • 44. AUDITING RAILS APPLICATIONS Checklist (Sort of) • Search eRB files for <%= if its user input ensure it is HTML escaped • Secure Access: check controllers and public actions • Search for "forgery" make sure that config.action_controller.allow_forgery_protection = false is only disabled in test config • Are passwords saved as clear-text in the db?, are being logged? filter_parameter_logging - 44 -
  • 45. AUDITING RAILS APPLICATIONS Checklist (Sort of) • Ensure private data is not stored in cookies • Appropriate use of attr_accessible/attr_protected • Is the application using validations inside models to prevent bad input? • Are non-action controller methods private? • Check for params[:id] usage • Gems are up to date for latest security patches (rails security mailing list) • Word search for "find", "first", and "all" "sql" • Check for mass assignment - 45 -
  • 46. AUDITING RAILS APPLICATIONS Tools: Brakeman • Static analysis security scanner for Ruby on Rails – www.brakemanscanner.org • Vulnerabilities Detected: – Cross site scripting – SQL injection – Command injection – Unprotected redirects – Unsafe file access – Version-specific security issues – Unrestricted mass assignment – Dangerous use of eval() Default routes – Insufficient model validation - 46 -
  • 47. AUDITING RAILS APPLICATIONS Tools: Brakeman • Using Brakeman gem install brakeman brakeman –p /path_to_your_rails_app - 47 -
  • 48. AUDITING RAILS APPLICATIONS Tools: Brakeman - 48 -
  • 49. Tips – Gems – Plugins BUILDING SECURE APPLICATIONS SECURITY GOODNESS WITH RUBY ON RAILS - 49 -
  • 50. BUILDING SECURE APPLICATIONS Recommendations: File uploads • Analyze the files with Antivirus • Random name. Save outside DocumentRoot • Avoid potential DOS (asyncronous tasks). Resque to the rescue! • Validate the MIME type • Ruby binding to libmagic (ruby-filemagic) • shared-mime-info gem. Not recognized? Modify MIME.check(file) • Serving the files later? send_file :disposition => 'attachment’ - 50 -
  • 51. BUILDING SECURE APPLICATIONS Tips: Authentication • Popular authentication plugins: – RestfulAuthentication – Authlogic • Popular SSO systems: – OpenID – CAS – Kerberos – GSS-API – SPNEGO – OAuth (gem install oauth) – LDAP (gem install ruby-net-ldap) - 51 -
  • 52. BUILDING SECURE APPLICATIONS Tips: Authorization • Mandatory access control (MAC): – Grants access based on the sensitivity of the information (i.e., clearance) – Example: Government information classification, such as Secret or Top Secret • Discretionary access control (DAC): – Grants access to objects based on the identity of subjects and/or groups to which they belong. – Example: Windows and Unix file permissions • Role-based access control (RBAC): – Access to actions is controlled through permission based on role assignments, not at the level of individual data objects. – Example: Active Directory - 52 -
  • 53. BUILDING SECURE APPLICATIONS Tips: Authorization • Simple Solutions: role_requirement (http://code.google.com/p/rolerequirement/). • Complex Scenarios: DeclarativeAuthorization plugin (RBAC) (http://github.com/stffn/declarative_authorization) • Other interesting plugins: • ActiveRbac (http://active-rbac.rubyforge.org/). • ModelSecurity (http://perens.com/FreeSoftware/ModelSecurity/). - 53 -
  • 54. BUILDING SECURE APPLICATIONS Tips: Admin Interface & good practices • Isolate administrative interface (subdomain, authentication, restricted) • Check request.remote_ip • Digital Certificates • Two factor auth (ROTP - The Ruby One Time Password Library https://github.com/mdp/rotp) • Alerts (invalid logins, suspicious activity) • Mandatory use of secure protocols (ActionController::Base.session_options[:session_secure] = true) • Cookies with httponly and secure flags • Deployment: – Passwords inside database.yml – Subversion files – Test files - 54 -
  • 55. THANKS FOR COMING! ANY QUESTIONS? dpelaez@gdssecurity.com - 55 -