SlideShare uma empresa Scribd logo
1 de 23
Protecting Web App users in
today’s hostile environment
Ajit Dhumale
OWASP Pune meetup
29th Sep 2016
Say I operate website www.verysecurebank.com
and I have made sure it doesn’t have any
vulnerability (I am kidding, but lets assume)
Does that make it safe for my customers to use
it?
• Almost impossible to say my website is
completely secure
• Even if it is it, it’s not enough
Browser Network Internet Infra Web Server/App
Web App Access Echo System
CDN
CA
Under user’s control Under app owner’s controlHostile
Images for various sources from the internet
• What if environment between the browser
and webapp gets compromised?
– Network, wifi hotspots
– CDN
– Trusted CA
– …
What if my customer is using my site from public
wifi hotspot?
A bad guy may have compromised the network
to perform MITM.
I use strong SSL security for https://www.verysecurebank.com to avoid
MITM.
My users can still frequently shoot themselves in foot by…
The request goes to
http://www.mysecurebank.com (plain text)
and is wide open for MITM
HTTP Strict Transport Security: HSTS
HTTP response header:
Strict-Transport-Security: max-age=31536000
Tells browsers to use only https for the future requests to the
domain (no more http requests, no more MITM).
Strict certificate checks without user override
Domains can be preloaded in browsers
– To eliminate Trust On First Use (TOFU)
HSTS Prevents
Unintentional access to website over HTTP
Hijacking of HTTP links unintentionally remaining on
HTTPS website.
MITM attack redirect using invalid certificates
HSTS: Caution
User is still vulnerable to MITM on the first contact
HSTS setting is at domain level and can be extended to all the subdomains as well
(using includeSubDomains).
Using ‘includeSubDomains’ on mydomain.com ? Beware
– It turns HSTS ON for *.mydomain.com e.g. images.mydomain.com, js. mydomain.com
which is good (provided the subdomains are running HTTPS with valid cert).
– But also turns it ON for intranet.mydomain.com. Are you sure ‘intranet.mydomain.com’
is running HTTPS with a valid cert?
HSTS preloading is hard to undo, be sure before submitting your domain for
preloading.
I am using CDN for fast loading of sub resource
javascript, css on my site.
e.g. page source for https://www.verysecurebank.com
<HTML>
…
<SCRIPT SRC="https://veryfastcdn.com/jquery.js"></SCRIPT>
…
</HTML>
My web server is secure but what if the CDN
gets compromised?
Sub Resource Integrity (SRI)
<script src="https://veryfastcdn.com/jquery.js"
integrity="sha384-
R4/ztc4ZlRqWjqIuvf6RX5yb/v90qNGx6fS48N0tRxiGkqveZETq72KgDVJCp2TC"
crossorigin="anonymous"></script>
Load JS, CSS from CDN but ask browser to check it’s
integrity using pre computed hash.
Currently only supported for scripts and CSS
SRI: Caution
Better suited for static resources, frequently changing ones
would be problematic
Updating content of SRI protected resource needs planning
1. First change webpage to add HASH for the new version of the
resource, along with the old one (multiple hashes are supported).
2. Then update the resource on CDN to new version
3. After new resources propagates to all CDNs, the old hash can be
removed from the webpage
MITM and CDN are taken care of
but what if a trusted CA gets compromised?
Hackers can now create valid looking fraudulent
cert for my website.
HTTP Public Key Pinning (HPKP)
Public-Key-Pins:
pin-sha256="cUPcTAZWKaASuYWhhneDttWpY3oBAkE3h2+soZS7sWs=";
pin-sha256="M8HztCzM3elUxkcjR2S5P4hhyBNf6lHkmjAHKhpGPWE=";
max-age=5184000; includeSubDomains; report-
uri=https://www.example.net/hpkp-report
Uses HTTP header to tell the browser to ‘pin’ a
domain to certain public key.
Pins can also be preloaded in browsers
HPKP: Caution
It is complicated, procced with extreme caution
– Used mainly for extreme high security websites
– If you need it, start with ‘Public-Key-Pins-Report-Only’ followed by ‘Public-Key-Pins’ with
short ‘max-age’ and increase it incrementally
– Carefully decide which keys to pin
HPKP suicide: If you loose control of your pined keys.
Cert renewal/rotation needs to be managed correctly using a backup pin.
HSTS validation is bypassed for user installed root CA
- To support corporate proxies, AVs, Fiddler
- Risky: Superfish/Lenovo, eDellRoot/Dell
Read: https://blog.qualys.com/ssllabs/2016/09/06/is-http-public-key-pinning-dead
I want to embed 3rd party components on my
website like CDN, google analytics, ads, social
media widgets.
How can I do it securely?
CSP
Allows whitelist controlled external resources on your
page:
– Tell the browser to load resources to load on the page only
from the trusted sources. Scripts, images, media, styles,
frames, fonts, plugins etc.
– Provides protection against attacker injecting harmful
resources, script on the page.
CSP: Caution
• Excessively tight CSP could break websites functionality. E.g. Security
zealous engineer might add ‘Content-Security-Policy: default-src
'self';’. It might work well in dev environment but in production 3rd
party analytics, ads, social media widgets would be broken.
• CSP is complex, needs correct configuration to get desired protection.
• Read: CSP Is Dead, Long Live CSP! On the Insecurity of Whitelists and the Future of Content
Security Policy
(https://static.googleusercontent.com/media/research.google.com/en//pubs/archive/45542.
pdf)
Few more protection mechanisms
X-XSS-Protection Force XSS protection (useful if XSS protection was disabled by
the user)
X-Frame-Options Dis-allow framing at a page level and avoid click jacking.
CORS Allow controlled cross domain access to partner websites
General precautions
• Check browser support
– All browsers may not support all the security mechanisms fully.
– Pay special attention to mobile browsers
• Weigh-in security vs availability
– Most of the new mechanisms are complex
– HPKP/CSP/HSTS misconfiguration can make your website inaccessible for your customers
– ‘one-size-fits-all’ doesn’t work.
– Central security design is needed, fragmented control would lead to misconfigurations
• Browser bugs
– Advisable to wait till browser implementations mature
• Adhere strictly to the specifications
– Invalid settings means no security. e.g.
• Valid: X-Frame-Options: DENY
• Invalid (with quotes): X-Frame-Options: 'DENY‘
• Test thoroughly to ensure the desired security is achieved and there is no
undesired loss of availability
Thanks
OWASP Pune Chapter
Website
https://www.owasp.org/index.php/Pune
OWASP Pune Twitter account
@OWASP_PUNE
OWASP Pune LinkedIn Group
https://www.linkedin.com/grp/home?gid=7022347

Mais conteúdo relacionado

Mais procurados

Wp security presentation
Wp security presentationWp security presentation
Wp security presentation
Nik Cree
 

Mais procurados (20)

WORDPRESS SECURITY: HOW TO AVOID BEING HACKED
WORDPRESS SECURITY: HOW TO AVOID BEING HACKEDWORDPRESS SECURITY: HOW TO AVOID BEING HACKED
WORDPRESS SECURITY: HOW TO AVOID BEING HACKED
 
Security 101
Security 101Security 101
Security 101
 
Sucuri Webinar: WAF (Firewall) and CDN Feature Benefit Guide
Sucuri Webinar: WAF (Firewall) and CDN Feature Benefit GuideSucuri Webinar: WAF (Firewall) and CDN Feature Benefit Guide
Sucuri Webinar: WAF (Firewall) and CDN Feature Benefit Guide
 
Click jacking
Click jackingClick jacking
Click jacking
 
Word campktm speed-security
Word campktm speed-securityWord campktm speed-security
Word campktm speed-security
 
Wordpress security best practices - WordCamp Waukesha 2017
Wordpress security best practices - WordCamp Waukesha 2017Wordpress security best practices - WordCamp Waukesha 2017
Wordpress security best practices - WordCamp Waukesha 2017
 
The Ultimate Guide to Wordpress Security
The Ultimate Guide to Wordpress SecurityThe Ultimate Guide to Wordpress Security
The Ultimate Guide to Wordpress Security
 
Hacked - What do you do now?
Hacked - What do you do now?Hacked - What do you do now?
Hacked - What do you do now?
 
Tips to improve word press security ppt
Tips to improve word press security pptTips to improve word press security ppt
Tips to improve word press security ppt
 
Wp security presentation
Wp security presentationWp security presentation
Wp security presentation
 
Iframe width
Iframe widthIframe width
Iframe width
 
QA Fest 2016. Per Thorsheim. Website security 101
QA Fest 2016. Per Thorsheim. Website security 101QA Fest 2016. Per Thorsheim. Website security 101
QA Fest 2016. Per Thorsheim. Website security 101
 
Introduction To Wordpress By Keng
Introduction To Wordpress By KengIntroduction To Wordpress By Keng
Introduction To Wordpress By Keng
 
Steps to Keep Your Site Clean
Steps to Keep Your Site CleanSteps to Keep Your Site Clean
Steps to Keep Your Site Clean
 
WordPress Security Essential Tips & Tricks
WordPress Security Essential Tips & TricksWordPress Security Essential Tips & Tricks
WordPress Security Essential Tips & Tricks
 
Sucuri Webinar: How to Clean a Hacked Magento Website
Sucuri Webinar: How to Clean a Hacked Magento WebsiteSucuri Webinar: How to Clean a Hacked Magento Website
Sucuri Webinar: How to Clean a Hacked Magento Website
 
Sucuri Webinar: Website Security Primer for Digital Marketers
Sucuri Webinar: Website Security Primer for Digital MarketersSucuri Webinar: Website Security Primer for Digital Marketers
Sucuri Webinar: Website Security Primer for Digital Marketers
 
Access Denied
Access DeniedAccess Denied
Access Denied
 
Locking down word press
Locking down word pressLocking down word press
Locking down word press
 
WordPress Security is like a HHAM Sandwich
WordPress Security is like a HHAM SandwichWordPress Security is like a HHAM Sandwich
WordPress Security is like a HHAM Sandwich
 

Destaque

Network Function Virtualization : Overview
Network Function Virtualization : OverviewNetwork Function Virtualization : Overview
Network Function Virtualization : Overview
sidneel
 

Destaque (11)

How should we perceive Security in the Cloud
How should we perceive Security in the CloudHow should we perceive Security in the Cloud
How should we perceive Security in the Cloud
 
INTO-CPS: An integrated “tool chain” for comprehensive Model-Based Design of ...
INTO-CPS: An integrated “tool chain” for comprehensive Model-Based Design of ...INTO-CPS: An integrated “tool chain” for comprehensive Model-Based Design of ...
INTO-CPS: An integrated “tool chain” for comprehensive Model-Based Design of ...
 
Network Function Virtualization (NFV) BoF
Network Function Virtualization (NFV) BoFNetwork Function Virtualization (NFV) BoF
Network Function Virtualization (NFV) BoF
 
Decision Trees
Decision TreesDecision Trees
Decision Trees
 
Fin presentation
Fin presentationFin presentation
Fin presentation
 
Network Function Virtualization : Overview
Network Function Virtualization : OverviewNetwork Function Virtualization : Overview
Network Function Virtualization : Overview
 
5 pen pc technology
5 pen pc technology5 pen pc technology
5 pen pc technology
 
EVO - Gamification in healthcare - Manu Melwin Joy
EVO - Gamification in healthcare - Manu Melwin JoyEVO - Gamification in healthcare - Manu Melwin Joy
EVO - Gamification in healthcare - Manu Melwin Joy
 
Sales forecasting
Sales forecastingSales forecasting
Sales forecasting
 
Introduction to Network Function Virtualization (NFV)
Introduction to Network Function Virtualization (NFV)Introduction to Network Function Virtualization (NFV)
Introduction to Network Function Virtualization (NFV)
 
Network Function Virtualization - Telkomsel Perspective (SDN NFV Day ITB 2016)
Network Function Virtualization - Telkomsel Perspective (SDN NFV Day ITB 2016)Network Function Virtualization - Telkomsel Perspective (SDN NFV Day ITB 2016)
Network Function Virtualization - Telkomsel Perspective (SDN NFV Day ITB 2016)
 

Semelhante a Protecting Web App users in today’s hostile environment

Browser Wars 2019 - Implementing a Content Security Policy
Browser Wars 2019 - Implementing a Content Security PolicyBrowser Wars 2019 - Implementing a Content Security Policy
Browser Wars 2019 - Implementing a Content Security Policy
George Boobyer
 
W3 conf hill-html5-security-realities
W3 conf hill-html5-security-realitiesW3 conf hill-html5-security-realities
W3 conf hill-html5-security-realities
Brad Hill
 
CMS Website Security Threat Protection Oriented Analyzer System
CMS Website Security Threat Protection Oriented Analyzer SystemCMS Website Security Threat Protection Oriented Analyzer System
CMS Website Security Threat Protection Oriented Analyzer System
Editor IJCATR
 

Semelhante a Protecting Web App users in today’s hostile environment (20)

HTTP_Header_Security.pdf
HTTP_Header_Security.pdfHTTP_Header_Security.pdf
HTTP_Header_Security.pdf
 
Tsc summit #2 - HTTP Header Security
Tsc summit #2  - HTTP Header SecurityTsc summit #2  - HTTP Header Security
Tsc summit #2 - HTTP Header Security
 
Web Security - CSP & Web Cryptography
Web Security - CSP & Web CryptographyWeb Security - CSP & Web Cryptography
Web Security - CSP & Web Cryptography
 
A Practical Guide to Securing Modern Web Applications
A Practical Guide to Securing Modern Web ApplicationsA Practical Guide to Securing Modern Web Applications
A Practical Guide to Securing Modern Web Applications
 
Browser Wars 2019 - Implementing a Content Security Policy
Browser Wars 2019 - Implementing a Content Security PolicyBrowser Wars 2019 - Implementing a Content Security Policy
Browser Wars 2019 - Implementing a Content Security Policy
 
Rails security: above and beyond the defaults
Rails security: above and beyond the defaultsRails security: above and beyond the defaults
Rails security: above and beyond the defaults
 
W3 conf hill-html5-security-realities
W3 conf hill-html5-security-realitiesW3 conf hill-html5-security-realities
W3 conf hill-html5-security-realities
 
Analysis of HTTP Security Headers in Turkey
Analysis of HTTP Security Headers in TurkeyAnalysis of HTTP Security Headers in Turkey
Analysis of HTTP Security Headers in Turkey
 
Why Traditional Web Security Technologies no Longer Suffice to Keep You Safe
Why Traditional Web Security Technologies no Longer Suffice to Keep You SafeWhy Traditional Web Security Technologies no Longer Suffice to Keep You Safe
Why Traditional Web Security Technologies no Longer Suffice to Keep You Safe
 
Content Security Policy (CSP)
Content Security Policy (CSP)Content Security Policy (CSP)
Content Security Policy (CSP)
 
List of useful security related http headers
List of useful security related http headersList of useful security related http headers
List of useful security related http headers
 
Content Security Policy - Lessons learned at Yahoo
Content Security Policy - Lessons learned at YahooContent Security Policy - Lessons learned at Yahoo
Content Security Policy - Lessons learned at Yahoo
 
How to Ensure You're Launching the Most Secure Website - Michael Tremante
How to Ensure You're Launching the Most Secure Website - Michael TremanteHow to Ensure You're Launching the Most Secure Website - Michael Tremante
How to Ensure You're Launching the Most Secure Website - Michael Tremante
 
Security and Privacy on the Web in 2015
Security and Privacy on the Web in 2015Security and Privacy on the Web in 2015
Security and Privacy on the Web in 2015
 
Http security response headers
Http security response headers Http security response headers
Http security response headers
 
Weird new tricks for browser fingerprinting
Weird new tricks for browser fingerprintingWeird new tricks for browser fingerprinting
Weird new tricks for browser fingerprinting
 
Css
CssCss
Css
 
CSS.ppt
CSS.pptCSS.ppt
CSS.ppt
 
CMS Website Security Threat Protection Oriented Analyzer System
CMS Website Security Threat Protection Oriented Analyzer SystemCMS Website Security Threat Protection Oriented Analyzer System
CMS Website Security Threat Protection Oriented Analyzer System
 
Top Ten Web Hacking Techniques of 2012
Top Ten Web Hacking Techniques of 2012Top Ten Web Hacking Techniques of 2012
Top Ten Web Hacking Techniques of 2012
 

Último

Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
chiefasafspells
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
masabamasaba
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
VictoriaMetrics
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 

Último (20)

Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptx
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 

Protecting Web App users in today’s hostile environment

  • 1. Protecting Web App users in today’s hostile environment Ajit Dhumale OWASP Pune meetup 29th Sep 2016
  • 2. Say I operate website www.verysecurebank.com and I have made sure it doesn’t have any vulnerability (I am kidding, but lets assume) Does that make it safe for my customers to use it?
  • 3. • Almost impossible to say my website is completely secure • Even if it is it, it’s not enough
  • 4. Browser Network Internet Infra Web Server/App Web App Access Echo System CDN CA Under user’s control Under app owner’s controlHostile Images for various sources from the internet
  • 5. • What if environment between the browser and webapp gets compromised? – Network, wifi hotspots – CDN – Trusted CA – …
  • 6. What if my customer is using my site from public wifi hotspot? A bad guy may have compromised the network to perform MITM.
  • 7. I use strong SSL security for https://www.verysecurebank.com to avoid MITM. My users can still frequently shoot themselves in foot by… The request goes to http://www.mysecurebank.com (plain text) and is wide open for MITM
  • 8. HTTP Strict Transport Security: HSTS HTTP response header: Strict-Transport-Security: max-age=31536000 Tells browsers to use only https for the future requests to the domain (no more http requests, no more MITM). Strict certificate checks without user override Domains can be preloaded in browsers – To eliminate Trust On First Use (TOFU)
  • 9. HSTS Prevents Unintentional access to website over HTTP Hijacking of HTTP links unintentionally remaining on HTTPS website. MITM attack redirect using invalid certificates
  • 10. HSTS: Caution User is still vulnerable to MITM on the first contact HSTS setting is at domain level and can be extended to all the subdomains as well (using includeSubDomains). Using ‘includeSubDomains’ on mydomain.com ? Beware – It turns HSTS ON for *.mydomain.com e.g. images.mydomain.com, js. mydomain.com which is good (provided the subdomains are running HTTPS with valid cert). – But also turns it ON for intranet.mydomain.com. Are you sure ‘intranet.mydomain.com’ is running HTTPS with a valid cert? HSTS preloading is hard to undo, be sure before submitting your domain for preloading.
  • 11. I am using CDN for fast loading of sub resource javascript, css on my site. e.g. page source for https://www.verysecurebank.com <HTML> … <SCRIPT SRC="https://veryfastcdn.com/jquery.js"></SCRIPT> … </HTML> My web server is secure but what if the CDN gets compromised?
  • 12. Sub Resource Integrity (SRI) <script src="https://veryfastcdn.com/jquery.js" integrity="sha384- R4/ztc4ZlRqWjqIuvf6RX5yb/v90qNGx6fS48N0tRxiGkqveZETq72KgDVJCp2TC" crossorigin="anonymous"></script> Load JS, CSS from CDN but ask browser to check it’s integrity using pre computed hash. Currently only supported for scripts and CSS
  • 13. SRI: Caution Better suited for static resources, frequently changing ones would be problematic Updating content of SRI protected resource needs planning 1. First change webpage to add HASH for the new version of the resource, along with the old one (multiple hashes are supported). 2. Then update the resource on CDN to new version 3. After new resources propagates to all CDNs, the old hash can be removed from the webpage
  • 14. MITM and CDN are taken care of but what if a trusted CA gets compromised? Hackers can now create valid looking fraudulent cert for my website.
  • 15. HTTP Public Key Pinning (HPKP) Public-Key-Pins: pin-sha256="cUPcTAZWKaASuYWhhneDttWpY3oBAkE3h2+soZS7sWs="; pin-sha256="M8HztCzM3elUxkcjR2S5P4hhyBNf6lHkmjAHKhpGPWE="; max-age=5184000; includeSubDomains; report- uri=https://www.example.net/hpkp-report Uses HTTP header to tell the browser to ‘pin’ a domain to certain public key. Pins can also be preloaded in browsers
  • 16. HPKP: Caution It is complicated, procced with extreme caution – Used mainly for extreme high security websites – If you need it, start with ‘Public-Key-Pins-Report-Only’ followed by ‘Public-Key-Pins’ with short ‘max-age’ and increase it incrementally – Carefully decide which keys to pin HPKP suicide: If you loose control of your pined keys. Cert renewal/rotation needs to be managed correctly using a backup pin. HSTS validation is bypassed for user installed root CA - To support corporate proxies, AVs, Fiddler - Risky: Superfish/Lenovo, eDellRoot/Dell Read: https://blog.qualys.com/ssllabs/2016/09/06/is-http-public-key-pinning-dead
  • 17. I want to embed 3rd party components on my website like CDN, google analytics, ads, social media widgets. How can I do it securely?
  • 18. CSP Allows whitelist controlled external resources on your page: – Tell the browser to load resources to load on the page only from the trusted sources. Scripts, images, media, styles, frames, fonts, plugins etc. – Provides protection against attacker injecting harmful resources, script on the page.
  • 19. CSP: Caution • Excessively tight CSP could break websites functionality. E.g. Security zealous engineer might add ‘Content-Security-Policy: default-src 'self';’. It might work well in dev environment but in production 3rd party analytics, ads, social media widgets would be broken. • CSP is complex, needs correct configuration to get desired protection. • Read: CSP Is Dead, Long Live CSP! On the Insecurity of Whitelists and the Future of Content Security Policy (https://static.googleusercontent.com/media/research.google.com/en//pubs/archive/45542. pdf)
  • 20. Few more protection mechanisms X-XSS-Protection Force XSS protection (useful if XSS protection was disabled by the user) X-Frame-Options Dis-allow framing at a page level and avoid click jacking. CORS Allow controlled cross domain access to partner websites
  • 21. General precautions • Check browser support – All browsers may not support all the security mechanisms fully. – Pay special attention to mobile browsers • Weigh-in security vs availability – Most of the new mechanisms are complex – HPKP/CSP/HSTS misconfiguration can make your website inaccessible for your customers – ‘one-size-fits-all’ doesn’t work. – Central security design is needed, fragmented control would lead to misconfigurations • Browser bugs – Advisable to wait till browser implementations mature • Adhere strictly to the specifications – Invalid settings means no security. e.g. • Valid: X-Frame-Options: DENY • Invalid (with quotes): X-Frame-Options: 'DENY‘ • Test thoroughly to ensure the desired security is achieved and there is no undesired loss of availability
  • 23. OWASP Pune Chapter Website https://www.owasp.org/index.php/Pune OWASP Pune Twitter account @OWASP_PUNE OWASP Pune LinkedIn Group https://www.linkedin.com/grp/home?gid=7022347