SlideShare ist ein Scribd-Unternehmen logo
1 von 42
Ruby on Rails
Building and Breaking Rails App
http://www.3SLabs.com
• Released to the world as ‘extracted’ from BaseCamp
(37Signals) by @dhh during July 2004.
• Merged with Merb Project during December 2008 and Rails
3.0 was released.
• Two supported branch of development currently:
– Rails 3.x
– Rails 4.x
Acceptance of RoR
.. and LOT more
Building Web Applications using Ruby on Rails
RoR Application Structure
Image Source: http://blog.ifuturz.com/ruby-on-rails/ruby-on-rails-mvc-learn-with-fun.html
Building a RoR App
1. Ruby & Ruby Gem Installation
2. Generate RoR Project
3. Design ERD
4. Generate Scaffolds
5. Define Relationships
6. Create Database Schema
7. Start Application Server
RoR: Web Blog Example
Our Blog is a web application where one or more Users
can self-register and sign-in using their registered
credentials.
Upon sign-in each User should be able to publish Blog
Post that is visible to any user or visitor of the portal.
Any User or Visitor of the portal should optionally
Comment on any Blog Post.
RoR: Web Blog ERD
Step1: Generate Project
Step2: Generate Scaffolds
Step3: Setup Database Schema
Step4: Launch App Server
http://m.xkcd.org/844/
Now write some
code or customize
the views..
After some love of Bootstrap3
Learning Ruby on Rails
• Ruby on Rails Official Guide
– http://guides.rubyonrails.org/
• Agile Web Development with Rails
– http://pragprog.com/book/rails4/agile-web-development-with-rails
• Ruby on Rails Podcasts
– http://podcast.rubyonrails.org/
• Rails Code School
– https://www.codeschool.com/courses/rails-for-zombies-redux
• Rails Cast
– http://railscasts.com/
Breaking Ruby on Rails Applications
Image (Karate) by Nicholas Riggle from The Noun Project CC By 2.0
Penetration Testing Rails App
• Black/Gray Box Approach
– Conventional Testing
– Fingerprinting Rails Framework
– Rails specific Vulnerability Testing
– Rails specific Weakness Testing
• White Box Approach
– Automated Scan for known Vulnerabilities
• Brakeman
– Attack Surface enumeration through Routes
– Authentication & Authorization Testing
– Common Rails information disclosures (secret_token.rb)
– Model Attributes Security
– Custom/Unconventional SQL Queries Audit
– Responsive View Audit
Fingerprinting Rails Applications
• No generic and definitive technique!
– It’s a cat & mouse game really.
• Heuristics
– Session Identifier
– Asset Pipeline
– [ … ]
Fingerprinting Rails Application
Not so easy for an application served with a reverse
proxy which is almost always the case in production.
Fingerprinting Rails Application
Leveraging the assets pipeline which is enabled by default from Rails 3.1
Automated Testing: Brakeman
http://brakemanscanner.org/
Need source code access !
Automated Testing: grep(1)
eval
instance_eval class_eval
DRb.start_server
find_by_sql
system exec
popen
You will be surprised to see how effective this is !
/`(.*)`/
Attack Surface: Routes
Attack Surface: Routes
• Default Routing
– <Resource> is handled by app/controllers/<resources>_controller.rb
– CRUD on Resource
Session Security
• A whole set of attacks are possible on Session
Management functionality of any Web
Application.
– Session Hijack, Session Fixation, Session Id Prediction, Session
Data Tampering, Leveraging Session Data for RCE etc.
• Rails provide inbuilt Session Management
– The session object is available to application
developer as a Hash/Map to store arbitrary data.
– The session object is serialized and stored in
corresponding session storage as per configuration.
– Signed cookie is used for session storage by default.
Session Security
http://robertheaton.com/2013/07/22/how-to-hack-a-rails-app-using-its-secret-token/
Not a Good idea !
Session Security: Best Practices
Enforce SSL in order to avoid sniffing of session id
Re-generate session after authentication to avoid session fixation
Store session in database instead of Cookie which is default
Cookie based Session Store are susceptible to Replay Attacks
Authentication
• Multiple Popular Authentication Plugin
– Devise
– RESTful Authentication
– […]
• Devise
– Auto-generated Registration, Confirmation, Login,
Forgot Password etc.
– Controller filter for enforcing authentication.
Testing Authentication
• Generic Issues
– Weak Session Management
– Weak Authentication Enforcement
– Weak Password Encryption
• Plugin/Gem Specific
– Devise Vulnerabilities
– Lack of Authentication Enforcement
– Timing Attacks
– Information Gathering through default message
Are all controllers protected by Authentication System?
Authorization
• Not provided by default in the framework.
– Encourages RESTful design.
• Easy to implement RBAC on Resources
– Multiple Gem/Plugin available
Example usage of CanCan for Authorization
https://github.com/ryanb/cancan
Testing Authorization
• Authorization Plugin or Custom Coded?
• Every functionality is RESTful?
• Query scoping in Controller
Rails CSRF Protection
CSRF Token generation and checking is enforced by default.
• Application must use Rails Form Tag Helps to
generate forms rather than HTML directly.
• HTTP GET is not protected !
Killing Rails CSRF Protection
http://blog.codeclimate.com/blog/2013/03/27/rails-insecure-defaults/
Rails Model Security
• The Business Logic Layer
– Database Abstraction through ORM
– Entity Relationship Definition
– Business Logic
• Common Security Issues
– Attribute Mass Assignment
• Mitigated by default in newer version of Rails
– Custom (insecure) SQL Queries
– Business Logic Vulnerabilities
Rails Model: Attribute Mass Assignment
The Model
The Controller
The Malicious Input
Rails Model: SQL Queries
Model Scope
Chained Query Interface (ActiveRelation)
Parameterized Qury
Rails Model: Insecure SQL Queries
The application developer should ensure that the Query Interface
understand the difference between Query and Data.
Rails Model: SQL Injection Vectors
• ActiveRecord does not escape parameters for
certain options:
Source: http://rails-sqli.org/
View Rendering
• Dynamic parameters are encoded by default
unless explicitly marked as safe.
• There are scope for Reflected XSS
– Strings marked explicitly with html_safe method.
– Textile/Markdown Injection
– Insecure used of content_tag
Secure Headers
• Rails 3.x is vulnerable to Clickjacking & UI
Redressing Type of attacks in default
configuration.
– Easy Mitigation
• gem ‘secureheaders’ in Gemfile
– https://github.com/twitter/secureheaders
Rails: Framework Vulnerabilities
http://www.cvedetails.com/vulnerability-list/vendor_id-12043/product_id-22568/Rubyonrails-Ruby-On-Rails.html
References
• Ruby on Rails Security Guide
– http://guides.rubyonrails.org/security.html
• Brakeman Scanner
– http://brakemanscanner.org/
• Rails SQLi Examples
– http://rails-sqli.org/
• OWASP Cheatsheet for RoR
– https://www.owasp.org/index.php/Ruby_on_Rails_Cheatsheet
• Ruby Security Configuration
– http://blog.codeclimate.com/blog/2013/03/27/rails-insecure-defaults/
• Ruby Mechanize
– http://mechanize.rubyforge.org/
• Ruby Nokogiri
– http://nokogiri.org/
• The Noun Project
– http://thenounproject.com/

Weitere ähnliche Inhalte

Was ist angesagt?

Pentesting Rest API's by :- Gaurang Bhatnagar
Pentesting Rest API's by :- Gaurang BhatnagarPentesting Rest API's by :- Gaurang Bhatnagar
Pentesting Rest API's by :- Gaurang BhatnagarOWASP Delhi
 
Threat Modeling In 2021
Threat Modeling In 2021Threat Modeling In 2021
Threat Modeling In 2021Adam Shostack
 
Bug Bounty Hunter Methodology - Nullcon 2016
Bug Bounty Hunter Methodology - Nullcon 2016Bug Bounty Hunter Methodology - Nullcon 2016
Bug Bounty Hunter Methodology - Nullcon 2016bugcrowd
 
Pentesting react native application for fun and profit - Abdullah
Pentesting react native application for fun and profit - AbdullahPentesting react native application for fun and profit - Abdullah
Pentesting react native application for fun and profit - Abdullahidsecconf
 
Ekoparty 2017 - The Bug Hunter's Methodology
Ekoparty 2017 - The Bug Hunter's MethodologyEkoparty 2017 - The Bug Hunter's Methodology
Ekoparty 2017 - The Bug Hunter's Methodologybugcrowd
 
Derbycon - The Unintended Risks of Trusting Active Directory
Derbycon - The Unintended Risks of Trusting Active DirectoryDerbycon - The Unintended Risks of Trusting Active Directory
Derbycon - The Unintended Risks of Trusting Active DirectoryWill Schroeder
 
External to DA, the OS X Way
External to DA, the OS X WayExternal to DA, the OS X Way
External to DA, the OS X WayStephan Borosh
 
Racing The Web - Hackfest 2016
Racing The Web - Hackfest 2016Racing The Web - Hackfest 2016
Racing The Web - Hackfest 2016Aaron Hnatiw
 
The Secret Life of a Bug Bounty Hunter – Frans Rosén @ Security Fest 2016
The Secret Life of a Bug Bounty Hunter – Frans Rosén @ Security Fest 2016The Secret Life of a Bug Bounty Hunter – Frans Rosén @ Security Fest 2016
The Secret Life of a Bug Bounty Hunter – Frans Rosén @ Security Fest 2016Frans Rosén
 
Introduction to red team operations
Introduction to red team operationsIntroduction to red team operations
Introduction to red team operationsSunny Neo
 
Source Code Analysis with SAST
Source Code Analysis with SASTSource Code Analysis with SAST
Source Code Analysis with SASTBlueinfy Solutions
 
The Unintended Risks of Trusting Active Directory
The Unintended Risks of Trusting Active DirectoryThe Unintended Risks of Trusting Active Directory
The Unintended Risks of Trusting Active DirectoryWill Schroeder
 
Secure coding practices
Secure coding practicesSecure coding practices
Secure coding practicesScott Hurrey
 
Vulnerabilities in modern web applications
Vulnerabilities in modern web applicationsVulnerabilities in modern web applications
Vulnerabilities in modern web applicationsNiyas Nazar
 
Security DevOps - Staying secure in agile projects // OWASP AppSecEU 2015 - A...
Security DevOps - Staying secure in agile projects // OWASP AppSecEU 2015 - A...Security DevOps - Staying secure in agile projects // OWASP AppSecEU 2015 - A...
Security DevOps - Staying secure in agile projects // OWASP AppSecEU 2015 - A...Christian Schneider
 
A story of the passive aggressive sysadmin of AEM
A story of the passive aggressive sysadmin of AEMA story of the passive aggressive sysadmin of AEM
A story of the passive aggressive sysadmin of AEMFrans Rosén
 

Was ist angesagt? (20)

Pentesting Rest API's by :- Gaurang Bhatnagar
Pentesting Rest API's by :- Gaurang BhatnagarPentesting Rest API's by :- Gaurang Bhatnagar
Pentesting Rest API's by :- Gaurang Bhatnagar
 
Local File Inclusion to Remote Code Execution
Local File Inclusion to Remote Code ExecutionLocal File Inclusion to Remote Code Execution
Local File Inclusion to Remote Code Execution
 
Threat Modeling In 2021
Threat Modeling In 2021Threat Modeling In 2021
Threat Modeling In 2021
 
Building Advanced XSS Vectors
Building Advanced XSS VectorsBuilding Advanced XSS Vectors
Building Advanced XSS Vectors
 
Bug Bounty Hunter Methodology - Nullcon 2016
Bug Bounty Hunter Methodology - Nullcon 2016Bug Bounty Hunter Methodology - Nullcon 2016
Bug Bounty Hunter Methodology - Nullcon 2016
 
Pentesting react native application for fun and profit - Abdullah
Pentesting react native application for fun and profit - AbdullahPentesting react native application for fun and profit - Abdullah
Pentesting react native application for fun and profit - Abdullah
 
Ekoparty 2017 - The Bug Hunter's Methodology
Ekoparty 2017 - The Bug Hunter's MethodologyEkoparty 2017 - The Bug Hunter's Methodology
Ekoparty 2017 - The Bug Hunter's Methodology
 
Derbycon - The Unintended Risks of Trusting Active Directory
Derbycon - The Unintended Risks of Trusting Active DirectoryDerbycon - The Unintended Risks of Trusting Active Directory
Derbycon - The Unintended Risks of Trusting Active Directory
 
Web-App Remote Code Execution Via Scripting Engines
Web-App Remote Code Execution Via Scripting EnginesWeb-App Remote Code Execution Via Scripting Engines
Web-App Remote Code Execution Via Scripting Engines
 
External to DA, the OS X Way
External to DA, the OS X WayExternal to DA, the OS X Way
External to DA, the OS X Way
 
Racing The Web - Hackfest 2016
Racing The Web - Hackfest 2016Racing The Web - Hackfest 2016
Racing The Web - Hackfest 2016
 
The Secret Life of a Bug Bounty Hunter – Frans Rosén @ Security Fest 2016
The Secret Life of a Bug Bounty Hunter – Frans Rosén @ Security Fest 2016The Secret Life of a Bug Bounty Hunter – Frans Rosén @ Security Fest 2016
The Secret Life of a Bug Bounty Hunter – Frans Rosén @ Security Fest 2016
 
Introduction to red team operations
Introduction to red team operationsIntroduction to red team operations
Introduction to red team operations
 
Source Code Analysis with SAST
Source Code Analysis with SASTSource Code Analysis with SAST
Source Code Analysis with SAST
 
The Unintended Risks of Trusting Active Directory
The Unintended Risks of Trusting Active DirectoryThe Unintended Risks of Trusting Active Directory
The Unintended Risks of Trusting Active Directory
 
Secure coding practices
Secure coding practicesSecure coding practices
Secure coding practices
 
[AVTOKYO 2017] What is red team?
[AVTOKYO 2017] What is red team?[AVTOKYO 2017] What is red team?
[AVTOKYO 2017] What is red team?
 
Vulnerabilities in modern web applications
Vulnerabilities in modern web applicationsVulnerabilities in modern web applications
Vulnerabilities in modern web applications
 
Security DevOps - Staying secure in agile projects // OWASP AppSecEU 2015 - A...
Security DevOps - Staying secure in agile projects // OWASP AppSecEU 2015 - A...Security DevOps - Staying secure in agile projects // OWASP AppSecEU 2015 - A...
Security DevOps - Staying secure in agile projects // OWASP AppSecEU 2015 - A...
 
A story of the passive aggressive sysadmin of AEM
A story of the passive aggressive sysadmin of AEMA story of the passive aggressive sysadmin of AEM
A story of the passive aggressive sysadmin of AEM
 

Andere mochten auch

Django Web Application Security
Django Web Application SecurityDjango Web Application Security
Django Web Application Securitylevigross
 
Hacking Ruby on Rails at Railswaycon09
Hacking Ruby on Rails at Railswaycon09Hacking Ruby on Rails at Railswaycon09
Hacking Ruby on Rails at Railswaycon09heikowebers
 
IE Memory Protector
IE Memory ProtectorIE Memory Protector
IE Memory Protector3S Labs
 
Case Study of Django: Web Frameworks that are Secure by Default
Case Study of Django: Web Frameworks that are Secure by DefaultCase Study of Django: Web Frameworks that are Secure by Default
Case Study of Django: Web Frameworks that are Secure by DefaultMohammed ALDOUB
 
Nullcon HackIM 2012 Solutions
Nullcon HackIM 2012 SolutionsNullcon HackIM 2012 Solutions
Nullcon HackIM 2012 SolutionsNilanjan De
 

Andere mochten auch (6)

Django Web Application Security
Django Web Application SecurityDjango Web Application Security
Django Web Application Security
 
Hacking Ruby on Rails at Railswaycon09
Hacking Ruby on Rails at Railswaycon09Hacking Ruby on Rails at Railswaycon09
Hacking Ruby on Rails at Railswaycon09
 
IE Memory Protector
IE Memory ProtectorIE Memory Protector
IE Memory Protector
 
Case Study of Django: Web Frameworks that are Secure by Default
Case Study of Django: Web Frameworks that are Secure by DefaultCase Study of Django: Web Frameworks that are Secure by Default
Case Study of Django: Web Frameworks that are Secure by Default
 
Nullcon HackIM 2012 Solutions
Nullcon HackIM 2012 SolutionsNullcon HackIM 2012 Solutions
Nullcon HackIM 2012 Solutions
 
Ruby On Rails
Ruby On RailsRuby On Rails
Ruby On Rails
 

Ähnlich wie Ruby on Rails Penetration Testing

Security Goodness with Ruby on Rails
Security Goodness with Ruby on RailsSecurity Goodness with Ruby on Rails
Security Goodness with Ruby on RailsSource Conference
 
How do JavaScript frameworks impact the security of applications?
How do JavaScript frameworks impact the security of applications?How do JavaScript frameworks impact the security of applications?
How do JavaScript frameworks impact the security of applications?Ksenia Peguero
 
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
 
Thick Application Penetration Testing: Crash Course
Thick Application Penetration Testing: Crash CourseThick Application Penetration Testing: Crash Course
Thick Application Penetration Testing: Crash CourseScott Sutherland
 
Introduction to Laravel Framework (5.2)
Introduction to Laravel Framework (5.2)Introduction to Laravel Framework (5.2)
Introduction to Laravel Framework (5.2)Viral Solani
 
Lecture #5 Introduction to rails
Lecture #5 Introduction to railsLecture #5 Introduction to rails
Lecture #5 Introduction to railsEvgeniy Hinyuk
 
Introduction to Rails by Evgeniy Hinyuk
Introduction to Rails by Evgeniy HinyukIntroduction to Rails by Evgeniy Hinyuk
Introduction to Rails by Evgeniy HinyukPivorak MeetUp
 
Getting Started with MariaDB with Docker
Getting Started with MariaDB with DockerGetting Started with MariaDB with Docker
Getting Started with MariaDB with DockerMariaDB plc
 
Web Development with Laravel 5
Web Development with Laravel 5Web Development with Laravel 5
Web Development with Laravel 5Soheil Khodayari
 
Building CI/CD Pipelines for Serverless Applications - SRV302 - re:Invent 2017
Building CI/CD Pipelines for Serverless Applications - SRV302 - re:Invent 2017Building CI/CD Pipelines for Serverless Applications - SRV302 - re:Invent 2017
Building CI/CD Pipelines for Serverless Applications - SRV302 - re:Invent 2017Amazon Web Services
 
OWASP SF - Reviewing Modern JavaScript Applications
OWASP SF - Reviewing Modern JavaScript ApplicationsOWASP SF - Reviewing Modern JavaScript Applications
OWASP SF - Reviewing Modern JavaScript ApplicationsLewis Ardern
 
Server-side Web development via Ruby on Rails
Server-side Web development via Ruby on RailsServer-side Web development via Ruby on Rails
Server-side Web development via Ruby on Railsg3ppy
 
Backbonification for dummies - Arrrrug 10/1/2012
Backbonification for dummies - Arrrrug 10/1/2012Backbonification for dummies - Arrrrug 10/1/2012
Backbonification for dummies - Arrrrug 10/1/2012Dimitri de Putte
 
Instruments ruby on rails
Instruments ruby on railsInstruments ruby on rails
Instruments ruby on railspmashchak
 

Ähnlich wie Ruby on Rails Penetration Testing (20)

Meetup callback
Meetup callbackMeetup callback
Meetup callback
 
Security Goodness with Ruby on Rails
Security Goodness with Ruby on RailsSecurity Goodness with Ruby on Rails
Security Goodness with Ruby on Rails
 
How do JavaScript frameworks impact the security of applications?
How do JavaScript frameworks impact the security of applications?How do JavaScript frameworks impact the security of applications?
How do JavaScript frameworks impact the security of applications?
 
Rhodes
RhodesRhodes
Rhodes
 
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...
 
Apache Drill (ver. 0.2)
Apache Drill (ver. 0.2)Apache Drill (ver. 0.2)
Apache Drill (ver. 0.2)
 
Laravel 4 presentation
Laravel 4 presentationLaravel 4 presentation
Laravel 4 presentation
 
Thick Application Penetration Testing: Crash Course
Thick Application Penetration Testing: Crash CourseThick Application Penetration Testing: Crash Course
Thick Application Penetration Testing: Crash Course
 
Introduction to Laravel Framework (5.2)
Introduction to Laravel Framework (5.2)Introduction to Laravel Framework (5.2)
Introduction to Laravel Framework (5.2)
 
Lecture #5 Introduction to rails
Lecture #5 Introduction to railsLecture #5 Introduction to rails
Lecture #5 Introduction to rails
 
Introduction to Rails by Evgeniy Hinyuk
Introduction to Rails by Evgeniy HinyukIntroduction to Rails by Evgeniy Hinyuk
Introduction to Rails by Evgeniy Hinyuk
 
Getting Started with MariaDB with Docker
Getting Started with MariaDB with DockerGetting Started with MariaDB with Docker
Getting Started with MariaDB with Docker
 
Web Development with Laravel 5
Web Development with Laravel 5Web Development with Laravel 5
Web Development with Laravel 5
 
API SECURITY
API SECURITYAPI SECURITY
API SECURITY
 
Building CI/CD Pipelines for Serverless Applications - SRV302 - re:Invent 2017
Building CI/CD Pipelines for Serverless Applications - SRV302 - re:Invent 2017Building CI/CD Pipelines for Serverless Applications - SRV302 - re:Invent 2017
Building CI/CD Pipelines for Serverless Applications - SRV302 - re:Invent 2017
 
OWASP SF - Reviewing Modern JavaScript Applications
OWASP SF - Reviewing Modern JavaScript ApplicationsOWASP SF - Reviewing Modern JavaScript Applications
OWASP SF - Reviewing Modern JavaScript Applications
 
Server-side Web development via Ruby on Rails
Server-side Web development via Ruby on RailsServer-side Web development via Ruby on Rails
Server-side Web development via Ruby on Rails
 
Backbonification for dummies - Arrrrug 10/1/2012
Backbonification for dummies - Arrrrug 10/1/2012Backbonification for dummies - Arrrrug 10/1/2012
Backbonification for dummies - Arrrrug 10/1/2012
 
REST APIs
REST APIsREST APIs
REST APIs
 
Instruments ruby on rails
Instruments ruby on railsInstruments ruby on rails
Instruments ruby on rails
 

Kürzlich hochgeladen

What’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesWhat’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesVictoriaMetrics
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfDrew Moseley
 
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdfAndrey Devyatkin
 
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...Bert Jan Schrijver
 
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full RecordingOpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full RecordingShane Coughlan
 
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxUI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxAndreas Kunz
 
SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?Alexandre Beguel
 
Zer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdfZer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdfmaor17
 
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...OnePlan Solutions
 
Ronisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited CatalogueRonisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited Catalogueitservices996
 
Strategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero resultsStrategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero resultsJean Silva
 
2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shardsChristopher Curtin
 
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full RecordingOpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full RecordingShane Coughlan
 
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4jGraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4jNeo4j
 
Keeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldKeeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldRoberto Pérez Alcolea
 
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdfEnhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdfRTS corp
 
Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Rob Geurden
 
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxThe Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxRTS corp
 
Introduction to Firebase Workshop Slides
Introduction to Firebase Workshop SlidesIntroduction to Firebase Workshop Slides
Introduction to Firebase Workshop Slidesvaideheekore1
 
Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZABSYZ Inc
 

Kürzlich hochgeladen (20)

What’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesWhat’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 Updates
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdf
 
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
 
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
 
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full RecordingOpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
 
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxUI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
 
SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?
 
Zer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdfZer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdf
 
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
 
Ronisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited CatalogueRonisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited Catalogue
 
Strategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero resultsStrategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero results
 
2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards
 
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full RecordingOpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
 
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4jGraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
 
Keeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldKeeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository world
 
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdfEnhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
 
Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...
 
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxThe Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
 
Introduction to Firebase Workshop Slides
Introduction to Firebase Workshop SlidesIntroduction to Firebase Workshop Slides
Introduction to Firebase Workshop Slides
 
Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZ
 

Ruby on Rails Penetration Testing

  • 1. Ruby on Rails Building and Breaking Rails App http://www.3SLabs.com
  • 2. • Released to the world as ‘extracted’ from BaseCamp (37Signals) by @dhh during July 2004. • Merged with Merb Project during December 2008 and Rails 3.0 was released. • Two supported branch of development currently: – Rails 3.x – Rails 4.x
  • 3. Acceptance of RoR .. and LOT more
  • 4. Building Web Applications using Ruby on Rails
  • 5. RoR Application Structure Image Source: http://blog.ifuturz.com/ruby-on-rails/ruby-on-rails-mvc-learn-with-fun.html
  • 6. Building a RoR App 1. Ruby & Ruby Gem Installation 2. Generate RoR Project 3. Design ERD 4. Generate Scaffolds 5. Define Relationships 6. Create Database Schema 7. Start Application Server
  • 7. RoR: Web Blog Example Our Blog is a web application where one or more Users can self-register and sign-in using their registered credentials. Upon sign-in each User should be able to publish Blog Post that is visible to any user or visitor of the portal. Any User or Visitor of the portal should optionally Comment on any Blog Post.
  • 13. http://m.xkcd.org/844/ Now write some code or customize the views..
  • 14. After some love of Bootstrap3
  • 15. Learning Ruby on Rails • Ruby on Rails Official Guide – http://guides.rubyonrails.org/ • Agile Web Development with Rails – http://pragprog.com/book/rails4/agile-web-development-with-rails • Ruby on Rails Podcasts – http://podcast.rubyonrails.org/ • Rails Code School – https://www.codeschool.com/courses/rails-for-zombies-redux • Rails Cast – http://railscasts.com/
  • 16. Breaking Ruby on Rails Applications Image (Karate) by Nicholas Riggle from The Noun Project CC By 2.0
  • 17. Penetration Testing Rails App • Black/Gray Box Approach – Conventional Testing – Fingerprinting Rails Framework – Rails specific Vulnerability Testing – Rails specific Weakness Testing • White Box Approach – Automated Scan for known Vulnerabilities • Brakeman – Attack Surface enumeration through Routes – Authentication & Authorization Testing – Common Rails information disclosures (secret_token.rb) – Model Attributes Security – Custom/Unconventional SQL Queries Audit – Responsive View Audit
  • 18. Fingerprinting Rails Applications • No generic and definitive technique! – It’s a cat & mouse game really. • Heuristics – Session Identifier – Asset Pipeline – [ … ]
  • 19. Fingerprinting Rails Application Not so easy for an application served with a reverse proxy which is almost always the case in production.
  • 20. Fingerprinting Rails Application Leveraging the assets pipeline which is enabled by default from Rails 3.1
  • 22. Automated Testing: grep(1) eval instance_eval class_eval DRb.start_server find_by_sql system exec popen You will be surprised to see how effective this is ! /`(.*)`/
  • 24. Attack Surface: Routes • Default Routing – <Resource> is handled by app/controllers/<resources>_controller.rb – CRUD on Resource
  • 25. Session Security • A whole set of attacks are possible on Session Management functionality of any Web Application. – Session Hijack, Session Fixation, Session Id Prediction, Session Data Tampering, Leveraging Session Data for RCE etc. • Rails provide inbuilt Session Management – The session object is available to application developer as a Hash/Map to store arbitrary data. – The session object is serialized and stored in corresponding session storage as per configuration. – Signed cookie is used for session storage by default.
  • 27. Session Security: Best Practices Enforce SSL in order to avoid sniffing of session id Re-generate session after authentication to avoid session fixation Store session in database instead of Cookie which is default Cookie based Session Store are susceptible to Replay Attacks
  • 28. Authentication • Multiple Popular Authentication Plugin – Devise – RESTful Authentication – […] • Devise – Auto-generated Registration, Confirmation, Login, Forgot Password etc. – Controller filter for enforcing authentication.
  • 29. Testing Authentication • Generic Issues – Weak Session Management – Weak Authentication Enforcement – Weak Password Encryption • Plugin/Gem Specific – Devise Vulnerabilities – Lack of Authentication Enforcement – Timing Attacks – Information Gathering through default message Are all controllers protected by Authentication System?
  • 30. Authorization • Not provided by default in the framework. – Encourages RESTful design. • Easy to implement RBAC on Resources – Multiple Gem/Plugin available Example usage of CanCan for Authorization https://github.com/ryanb/cancan
  • 31. Testing Authorization • Authorization Plugin or Custom Coded? • Every functionality is RESTful? • Query scoping in Controller
  • 32. Rails CSRF Protection CSRF Token generation and checking is enforced by default. • Application must use Rails Form Tag Helps to generate forms rather than HTML directly. • HTTP GET is not protected !
  • 33. Killing Rails CSRF Protection http://blog.codeclimate.com/blog/2013/03/27/rails-insecure-defaults/
  • 34. Rails Model Security • The Business Logic Layer – Database Abstraction through ORM – Entity Relationship Definition – Business Logic • Common Security Issues – Attribute Mass Assignment • Mitigated by default in newer version of Rails – Custom (insecure) SQL Queries – Business Logic Vulnerabilities
  • 35. Rails Model: Attribute Mass Assignment The Model The Controller The Malicious Input
  • 36. Rails Model: SQL Queries Model Scope Chained Query Interface (ActiveRelation) Parameterized Qury
  • 37. Rails Model: Insecure SQL Queries The application developer should ensure that the Query Interface understand the difference between Query and Data.
  • 38. Rails Model: SQL Injection Vectors • ActiveRecord does not escape parameters for certain options: Source: http://rails-sqli.org/
  • 39. View Rendering • Dynamic parameters are encoded by default unless explicitly marked as safe. • There are scope for Reflected XSS – Strings marked explicitly with html_safe method. – Textile/Markdown Injection – Insecure used of content_tag
  • 40. Secure Headers • Rails 3.x is vulnerable to Clickjacking & UI Redressing Type of attacks in default configuration. – Easy Mitigation • gem ‘secureheaders’ in Gemfile – https://github.com/twitter/secureheaders
  • 42. References • Ruby on Rails Security Guide – http://guides.rubyonrails.org/security.html • Brakeman Scanner – http://brakemanscanner.org/ • Rails SQLi Examples – http://rails-sqli.org/ • OWASP Cheatsheet for RoR – https://www.owasp.org/index.php/Ruby_on_Rails_Cheatsheet • Ruby Security Configuration – http://blog.codeclimate.com/blog/2013/03/27/rails-insecure-defaults/ • Ruby Mechanize – http://mechanize.rubyforge.org/ • Ruby Nokogiri – http://nokogiri.org/ • The Noun Project – http://thenounproject.com/