Securing your web application through HTTP headers

A
Andre N. KlingsheimSelf employed consultant
SECURING YOUR WEB APPLICATION THROUGH
            HTTP HEADERS
             Booster — 14. March 2013


           André N. Klingsheim (@klingsen)
                     AppSec AS




                                             1
OUTLINE
•   HTTP headers
•   Attacks and security headers
     • Cross site scripting (XSS) — Content Security Policy
     • Clickjacking — X-Frame-options
     • SSL stripping++ — HTTP Strict Transport Security
     • Session hijacking — Cookie security settings
     • MIME type attacks — X-Download-Options, X-Content-Type-options




                                                                        2
DEMO




       3
HYGIENE: VERSION HEADERS
•   Web servers and web application frameworks tend to include version headers in the HTTP responses
•   There really is no reason to leak this information to an attacker
•   Get rid of them and save the bandwith!
•   Demo




                                                                                                       4
Cross site scripting (XSS)

CONTENT SECURITY POLICY

                             5
CROSS SITE SCRIPTING (XSS)
•   Reflected
     • User controlled data from the request is included in the response
•   Persistent
     • Attacker is able to store the attack server side, the stored attack is later included in response(s)
•   DOM based
     • Does not involve the server, happens on the client side




- XSS (Cross Site Scripting) Prevention Cheat Sheet
- OWASP Top 10 for JavaScript – A2: Cross Site Scripting – XSS                                                6
DEMO




       7
CONTENT SECURITY POLICY (CSP)
•   Lets you specify a policy for where content in your webpages can be loaded from
•   Lets you put restrictions on script execution
•   Headers
     • Content-Security-Policy – Chrome 25
     • X-Content-Security-Policy – Firefox 4+
     • X-WebKit-Csp – WebKit browsers (Chrome/Safari)
•   W3C Candidate recommendation
     • Will end up being a proper standard!




                                                                                      8
CSP DIRECTIVES
•   default-src — Specifies the default for other sources
•   script-src
•   style-src
•   object-src — plugins
•   img-src
•   media-src — video/audio
•   frame-src
•   font-src
•   connect-src
•   report-uri — Specifies where CSP violations can be reported




                                                                  9
CSP SOURCES (FOR THE DIRECTIVES)
•   'none' — No content of this type is allowed (All directives)
•   'self' — Content of this type can only be loaded from the same origin (no content from other sites) (All directives)
•   'unsafe-inline' — Allows unsafe inline content.
     •   Supported by style-src (inline css) and script-src (inline script)
•   'unsafe-eval' — Allows script functions considered unsafe (such as eval())
     •   Supported by script-src
•   And you can specify custom sources:
     •    * — Allow content from anywhere
     •   https: — Scheme only, load only content served over https
     •   *.nwebsec.com — Wildcard host, allow content from any nwebsec.com sub-domain.
     •   www.nwebsec.com:81 — You can specify a port number
     •   https://www.nwebsec.com — You can of specify an absolute URI for a host (path has no effect though)



                                                                                                                           10
AND THEN IT ALL COMES TOGETHER
• Content-Security-Policy: default-src 'self'; script-src 'self' scripts.nwebsec.codeplex.com

•   This policy sets a default source of 'self' for all directives.
•   script-src defines its own sources, replacing the default (hence the inclusion of 'self')


•   In effect, scripts, stylesheets, images, flash animations, Java applets etc can only be loaded from the same origin as the
    page
•   Scripts can also be loaded from scripts.nwebsec.codeplex.com
•   This policy denies inline scripts and CSS!




                                                                                                                                 11
THE "SPECIAL" SOURCES
•   'unsafe-inline' can allow inline scripts (script-src) and styles (style-src)
•   'unsafe-eval' allows certain JavaScript functions considered high risk (eval())
•   Use these special sources with care




                                                                                      12
CSP REPORTING
•   You can specify a "report-uri" in the CSP header
•   Must be a relative URI
•   Will post violation reports as JSON back to the web application


•   Content-Security-Policy-Report-Only
     • Will not block scripts or resources violating the policy
     • Will report them to the web application




                                                                      13
XSS SUMMARIZED
•   Make sure you validate your inputs
•   Make sure you encode everything you output
     • Input to the web application
     • Data from backend systems
     • EVERYTHING!
•   Use CSP as an extra level of defense, it's not the cure!




                                                               14
X-Frame-Options

CLICKJACKING

                  15
CLICKJACKING
•   A malicious site loads the vulnerable site in an iframe
•   The iframe is invisible, and positioned in front of something the user is likely to click on
•   The user clicks on what appears to be an element on the malicious site
     • The user really clicks in the iframe, triggering some operation on the vulnerable site




                                                                                                   16
CLICKJACKING DEMO


   Vulnerable site      Evil site

       Delete
     something!
                     Click me!




                                    17
FRAMESNIFFING
•   You can specify an URL with an anchor when loading an iFrame
•   Browsers would scroll to the anchor tag, or the html element with the relevant id attribute
•   This scrolling can be detected with JavaScript
•   Note: Vulnerability has been fixed in latest versions of browsers




                                                                                                  18
X-FRAME-OPTIONS
•   X-Frame-Options: Deny | SameOrigin
•   Instructs the browser to not display the page in a frame
     • When the page isn’t displayed, there’s nothing to click on!
•   Browser support: Opera 10.5, Chrome 4.1, IE 8, Firefox 3.6.9, Safari 4


•   Remember: The request is still sent to — and prosessed by — the web server!




                                                                                  19
X-FRAME-OPTIONS SEQUENCE DIAGRAM



                                   Attacker




                                   Target




                                              20
Strict-Transport-Security

HTTPS STRIPPING

                            21
HTTPS STRIPPING EXPLAINED
•   "Secure" websites use SSL/TLS to preserve the confidentiality and integrity of the communication with a browser
•   For usability, "secure" websites are still accessible through insecure channels (HTTP on port 80)
     • They’ll redirect the user to HTTPS
     • User enters www.onlinebank.com — and is redirected to https://www.onlinebank.com
     • The very first request is insecure, and open to attack!
•   SSL stripping is a middleperson attack
     • Attacker keeps the victim on HTTP, but passes requests on over HTTPS to the target website
     • Practical attack demoed at Black Hat in 2009 (sslstrip)




http://www.thoughtcrime.org/software/sslstrip/                                                                        22
HOW "SECURE BROWSING" USUALLY WORKS


                    www.onlinebank.com (unprotected)

             Redirect: https://www.onlinebank.com (unprotected)

                  https://www.onlinebank.com (protected)
                                                                  Online bank




                                                                                23
HTTPS STRIPPING


      www.onlinebank.com (unprotected)                  https://www.onlinebank.com (protected)

          Response (unprotected)                               Response (protected)

   http://www.onlinebank.com (unprotected)              https://www.onlinebank.com (protected)
                                             Attacker                                            Online bank
          Response (unprotected)                               Response (protected)




                                                                                                          24
DEMO




       25
HTTP STRICT TRANSPORT SECURITY
•   Strict-Transport-Security: max-age=31536000; includeSubDomains
     • Max-age specifies for how many seconds the policy should be in effect
     • includeSubDomains — optional
•   Instructs the browser to only communicate to that hostname over SSL/TLS
•   Fails hard on certificate errors
     • The user does not have the option to click through certificate warnings


     • Browser support: Chrome 4+, Firefox 4+, Opera 12




                                                                                 26
Securing cookies

SESSION HIJACKING

                    27
SESSION HIJACKING EXPLAINED
•   Means getting access to a user's privileged session -> steal session tokens
•   On the web, session tokens mean cookies
•   Protect the cookies!


•   Cookies can be marked with the "httpOnly" flag -> makes them inaccessible to JS, they won't be included in requests from
    applets.
•   Cookies can be marked with the "secure" flag -> instructs the browser to only send them with HTTPS requests




                                                                                                                           28
DEMO




       29
X-Content-Type-Options: nosniff

IE MIME SNIFFING

                                  30
IE MIME SNIFFING
•   HTTP responses include a header stating what type of content is included
     • E.g. Content-Type: text/html; charset=utf-8
•   To compensate for misconfigured servers and bad programming, IE introduced MIME sniffing back in the days (IE4)
•   Some undesires side effects when IE guesses wrong
•   They introduced the "X-Content-Type-Options: nosniff " header in IE9 to disable the behaviour


•   Always serve your content with the correct content type, and the "X-Content-Type-Options" header
•   Demo!




                                                                                                                      31
COST/BENEFIT OF SECURITY HEADERS

                                   32
ADDING HEADERS IS EASY
•   Benefits
     • Usually a single line of code in any "webpage"
     • Can often be added through config
     • Prevents well known attacks


•   Cost
     • Low
     • CSP can be expensive, might require rewrite of existing applications




                                                                              33
SOME REFERENCES
•   Blog: Security through HTTP response headers
     • http://www.dotnetnoob.com/2012/09/security-through-http-response-headers.html
•   The NWebsec security library for ASP.NET
     • http://nwebsec.codeplex.com/
•   The NWebsec demo site
     • http://www.nwebsec.com/
•   The application used for demo here
     • https://github.com/klings/Booster2013




                                                                                       34
@klingsen

THANK YOU!

             35
1 of 35

Recommended

Modern Web Application Defense by
Modern Web Application DefenseModern Web Application Defense
Modern Web Application DefenseFrank Kim
1.1K views30 slides
Protecting Java EE Web Apps with Secure HTTP Headers by
Protecting Java EE Web Apps with Secure HTTP HeadersProtecting Java EE Web Apps with Secure HTTP Headers
Protecting Java EE Web Apps with Secure HTTP HeadersFrank Kim
13.7K views46 slides
Java EE 6 Security in practice with GlassFish by
Java EE 6 Security in practice with GlassFishJava EE 6 Security in practice with GlassFish
Java EE 6 Security in practice with GlassFishMarkus Eisele
2.5K views61 slides
HTTP Security Headers Every Java Developer Must Know by
HTTP Security Headers Every Java Developer Must KnowHTTP Security Headers Every Java Developer Must Know
HTTP Security Headers Every Java Developer Must KnowAyoma Wijethunga
2.3K views52 slides
Security vulnerabilities - 2018 by
Security vulnerabilities - 2018Security vulnerabilities - 2018
Security vulnerabilities - 2018Marius Vorster
220 views55 slides
DefCamp 2013 - Http header analysis by
DefCamp 2013 - Http header analysisDefCamp 2013 - Http header analysis
DefCamp 2013 - Http header analysisDefCamp
2.4K views62 slides

More Related Content

What's hot

Something wicked this way comes - CONFidence by
Something wicked this way comes - CONFidenceSomething wicked this way comes - CONFidence
Something wicked this way comes - CONFidenceKrzysztof Kotowicz
2.8K views51 slides
Html5: Something wicked this way comes (Hack in Paris) by
Html5: Something wicked this way comes (Hack in Paris)Html5: Something wicked this way comes (Hack in Paris)
Html5: Something wicked this way comes (Hack in Paris)Krzysztof Kotowicz
15.4K views47 slides
Web Application Security in front end by
Web Application Security in front endWeb Application Security in front end
Web Application Security in front endErlend Oftedal
9.9K views83 slides
Krzysztof Kotowicz - Hacking HTML5 by
Krzysztof Kotowicz - Hacking HTML5Krzysztof Kotowicz - Hacking HTML5
Krzysztof Kotowicz - Hacking HTML5DefconRussia
9.3K views39 slides
Advanced Chrome extension exploitation by
Advanced Chrome extension exploitationAdvanced Chrome extension exploitation
Advanced Chrome extension exploitationKrzysztof Kotowicz
9.7K views57 slides
Html5 security by
Html5 securityHtml5 security
Html5 securityKrishna T
2.6K views34 slides

What's hot(20)

Something wicked this way comes - CONFidence by Krzysztof Kotowicz
Something wicked this way comes - CONFidenceSomething wicked this way comes - CONFidence
Something wicked this way comes - CONFidence
Krzysztof Kotowicz2.8K views
Html5: Something wicked this way comes (Hack in Paris) by Krzysztof Kotowicz
Html5: Something wicked this way comes (Hack in Paris)Html5: Something wicked this way comes (Hack in Paris)
Html5: Something wicked this way comes (Hack in Paris)
Krzysztof Kotowicz15.4K views
Web Application Security in front end by Erlend Oftedal
Web Application Security in front endWeb Application Security in front end
Web Application Security in front end
Erlend Oftedal9.9K views
Krzysztof Kotowicz - Hacking HTML5 by DefconRussia
Krzysztof Kotowicz - Hacking HTML5Krzysztof Kotowicz - Hacking HTML5
Krzysztof Kotowicz - Hacking HTML5
DefconRussia9.3K views
Html5 security by Krishna T
Html5 securityHtml5 security
Html5 security
Krishna T2.6K views
Joomla! security jday2015 by kriptonium
Joomla! security jday2015Joomla! security jday2015
Joomla! security jday2015
kriptonium652 views
An Overview of Common Vulnerabilities in Wordpress by Analytive
An Overview of Common Vulnerabilities in WordpressAn Overview of Common Vulnerabilities in Wordpress
An Overview of Common Vulnerabilities in Wordpress
Analytive1.6K views
MITM Attacks on HTTPS: Another Perspective by GreenD0g
MITM Attacks on HTTPS: Another PerspectiveMITM Attacks on HTTPS: Another Perspective
MITM Attacks on HTTPS: Another Perspective
GreenD0g3.6K views
Case Study of Django: Web Frameworks that are Secure by Default by Mohammed ALDOUB
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
Mohammed ALDOUB9.3K views
Django (Web Applications that are Secure by Default) by Kishor Kumar
Django �(Web Applications that are Secure by Default�)Django �(Web Applications that are Secure by Default�)
Django (Web Applications that are Secure by Default)
Kishor Kumar644 views
Evolution Of The Web Platform & Browser Security by Sanjeev Verma, PhD
Evolution Of The Web Platform & Browser SecurityEvolution Of The Web Platform & Browser Security
Evolution Of The Web Platform & Browser Security
Sanjeev Verma, PhD396 views
I'm in ur browser, pwning your stuff - Attacking (with) Google Chrome Extensions by Krzysztof Kotowicz
I'm in ur browser, pwning your stuff - Attacking (with) Google Chrome ExtensionsI'm in ur browser, pwning your stuff - Attacking (with) Google Chrome Extensions
I'm in ur browser, pwning your stuff - Attacking (with) Google Chrome Extensions
Krzysztof Kotowicz9.7K views
Browser Serving Your Web Application Security - Madison PHP 2017 by Philippe Gamache
Browser Serving Your Web Application Security - Madison PHP 2017Browser Serving Your Web Application Security - Madison PHP 2017
Browser Serving Your Web Application Security - Madison PHP 2017
Philippe Gamache339 views
Html5 localstorage attack vectors by Shreeraj Shah
Html5 localstorage attack vectorsHtml5 localstorage attack vectors
Html5 localstorage attack vectors
Shreeraj Shah7.4K views

Viewers also liked

Mobile Api and Caching by
Mobile Api and CachingMobile Api and Caching
Mobile Api and CachingNew Relic
4.5K views42 slides
[Wroclaw #2] Web Application Security Headers by
[Wroclaw #2] Web Application Security Headers[Wroclaw #2] Web Application Security Headers
[Wroclaw #2] Web Application Security HeadersOWASP
1K views35 slides
Csp and http headers by
Csp and http headersCsp and http headers
Csp and http headersdevObjective
1K views35 slides
Online banking trojans by
Online banking trojansOnline banking trojans
Online banking trojansAndre N. Klingsheim
894 views24 slides
Secure HTTP Headers c0c0n 2011 Akash Mahajan by
Secure HTTP Headers c0c0n 2011 Akash MahajanSecure HTTP Headers c0c0n 2011 Akash Mahajan
Secure HTTP Headers c0c0n 2011 Akash MahajanAkash Mahajan
1.6K views14 slides
HTTP Strict Transport Security (HSTS), English version by
HTTP Strict Transport Security (HSTS), English versionHTTP Strict Transport Security (HSTS), English version
HTTP Strict Transport Security (HSTS), English versionMichal Špaček
2.8K views27 slides

Viewers also liked(20)

Mobile Api and Caching by New Relic
Mobile Api and CachingMobile Api and Caching
Mobile Api and Caching
New Relic4.5K views
[Wroclaw #2] Web Application Security Headers by OWASP
[Wroclaw #2] Web Application Security Headers[Wroclaw #2] Web Application Security Headers
[Wroclaw #2] Web Application Security Headers
OWASP1K views
Secure HTTP Headers c0c0n 2011 Akash Mahajan by Akash Mahajan
Secure HTTP Headers c0c0n 2011 Akash MahajanSecure HTTP Headers c0c0n 2011 Akash Mahajan
Secure HTTP Headers c0c0n 2011 Akash Mahajan
Akash Mahajan1.6K views
HTTP Strict Transport Security (HSTS), English version by Michal Špaček
HTTP Strict Transport Security (HSTS), English versionHTTP Strict Transport Security (HSTS), English version
HTTP Strict Transport Security (HSTS), English version
Michal Špaček2.8K views
List of useful security related http headers by 한익 주
List of useful security related http headersList of useful security related http headers
List of useful security related http headers
한익 주1.3K views
How to secure your web applications with NGINX by Wallarm
How to secure your web applications with NGINXHow to secure your web applications with NGINX
How to secure your web applications with NGINX
Wallarm31.4K views
ONLINE BANKING by deepa
ONLINE   BANKINGONLINE   BANKING
ONLINE BANKING
deepa3.4K views
Online banking by Preet Raj
Online bankingOnline banking
Online banking
Preet Raj12.5K views
Security In Internet Banking by Chiheb Chebbi
Security In Internet BankingSecurity In Internet Banking
Security In Internet Banking
Chiheb Chebbi6.2K views
Online banking ppt by Vishnu V S
Online banking pptOnline banking ppt
Online banking ppt
Vishnu V S58.2K views
Study of Online Banking Security Mechanism in India: Take ICICI Bank as an Ex... by IOSR Journals
Study of Online Banking Security Mechanism in India: Take ICICI Bank as an Ex...Study of Online Banking Security Mechanism in India: Take ICICI Bank as an Ex...
Study of Online Banking Security Mechanism in India: Take ICICI Bank as an Ex...
IOSR Journals741 views
Internet banking - College Project by Sheril Daniel
Internet banking - College ProjectInternet banking - College Project
Internet banking - College Project
Sheril Daniel142.6K views
Web Security - Cookies, Domains and CORS by Perfectial, LLC
Web Security - Cookies, Domains and CORSWeb Security - Cookies, Domains and CORS
Web Security - Cookies, Domains and CORS
Perfectial, LLC3.4K views

Similar to Securing your web application through HTTP headers

Krzysztof kotowicz. something wicked this way comes by
Krzysztof kotowicz. something wicked this way comesKrzysztof kotowicz. something wicked this way comes
Krzysztof kotowicz. something wicked this way comesYury Chemerkin
1.3K views52 slides
HTML5 - The Promise & The Peril by
HTML5 - The Promise & The PerilHTML5 - The Promise & The Peril
HTML5 - The Promise & The PerilSecurity Innovation
106 views33 slides
Browser Hacking For Fun and Profit | Null Bangalore Meetup 2019 | Divyanshu S... by
Browser Hacking For Fun and Profit | Null Bangalore Meetup 2019 | Divyanshu S...Browser Hacking For Fun and Profit | Null Bangalore Meetup 2019 | Divyanshu S...
Browser Hacking For Fun and Profit | Null Bangalore Meetup 2019 | Divyanshu S...Divyanshu
796 views21 slides
Devouring Security Insufficient data validation risks Cross Site Scripting by
Devouring Security Insufficient data validation risks Cross Site ScriptingDevouring Security Insufficient data validation risks Cross Site Scripting
Devouring Security Insufficient data validation risks Cross Site Scriptinggmaran23
3.4K views51 slides
Do you lose sleep at night? by
Do you lose sleep at night?Do you lose sleep at night?
Do you lose sleep at night?Nathan Van Gheem
1.4K views72 slides
Rails and Content Security Policies by
Rails and Content Security PoliciesRails and Content Security Policies
Rails and Content Security PoliciesMatias Korhonen
1.6K views44 slides

Similar to Securing your web application through HTTP headers(20)

Krzysztof kotowicz. something wicked this way comes by Yury Chemerkin
Krzysztof kotowicz. something wicked this way comesKrzysztof kotowicz. something wicked this way comes
Krzysztof kotowicz. something wicked this way comes
Yury Chemerkin1.3K views
Browser Hacking For Fun and Profit | Null Bangalore Meetup 2019 | Divyanshu S... by Divyanshu
Browser Hacking For Fun and Profit | Null Bangalore Meetup 2019 | Divyanshu S...Browser Hacking For Fun and Profit | Null Bangalore Meetup 2019 | Divyanshu S...
Browser Hacking For Fun and Profit | Null Bangalore Meetup 2019 | Divyanshu S...
Divyanshu 796 views
Devouring Security Insufficient data validation risks Cross Site Scripting by gmaran23
Devouring Security Insufficient data validation risks Cross Site ScriptingDevouring Security Insufficient data validation risks Cross Site Scripting
Devouring Security Insufficient data validation risks Cross Site Scripting
gmaran233.4K views
Rails and Content Security Policies by Matias Korhonen
Rails and Content Security PoliciesRails and Content Security Policies
Rails and Content Security Policies
Matias Korhonen1.6K views
Rich Web App Security - Keeping your application safe by Jeremiah Grossman
Rich Web App Security - Keeping your application safeRich Web App Security - Keeping your application safe
Rich Web App Security - Keeping your application safe
Jeremiah Grossman8.1K views
Browser Security 101 by Stormpath
Browser Security 101 Browser Security 101
Browser Security 101
Stormpath2.1K views
Rails security: above and beyond the defaults by Matias Korhonen
Rails security: above and beyond the defaultsRails security: above and beyond the defaults
Rails security: above and beyond the defaults
Matias Korhonen438 views
Tsc summit #2 - HTTP Header Security by Mikal Villa
Tsc summit #2  - HTTP Header SecurityTsc summit #2  - HTTP Header Security
Tsc summit #2 - HTTP Header Security
Mikal Villa938 views
Why Traditional Web Security Technologies no Longer Suffice to Keep You Safe by Philippe De Ryck
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
Philippe De Ryck355 views
Html5 Application Security by chuckbt
Html5 Application SecurityHtml5 Application Security
Html5 Application Security
chuckbt2.2K views
Hacking HTML5 offensive course (Zeronights edition) by Krzysztof Kotowicz
Hacking HTML5 offensive course (Zeronights edition)Hacking HTML5 offensive course (Zeronights edition)
Hacking HTML5 offensive course (Zeronights edition)
Krzysztof Kotowicz4.2K views
www.webre24h.com - Ajax security by webre24h
www.webre24h.com - Ajax securitywww.webre24h.com - Ajax security
www.webre24h.com - Ajax security
webre24h189 views
QA: Базовое тестирование защищенности веб-приложений в рамках QA by CodeFest
QA: Базовое тестирование защищенности веб-приложений в рамках QAQA: Базовое тестирование защищенности веб-приложений в рамках QA
QA: Базовое тестирование защищенности веб-приложений в рамках QA
CodeFest1.4K views

Recently uploaded

Special_edition_innovator_2023.pdf by
Special_edition_innovator_2023.pdfSpecial_edition_innovator_2023.pdf
Special_edition_innovator_2023.pdfWillDavies22
16 views6 slides
.conf Go 2023 - Data analysis as a routine by
.conf Go 2023 - Data analysis as a routine.conf Go 2023 - Data analysis as a routine
.conf Go 2023 - Data analysis as a routineSplunk
93 views12 slides
AMAZON PRODUCT RESEARCH.pdf by
AMAZON PRODUCT RESEARCH.pdfAMAZON PRODUCT RESEARCH.pdf
AMAZON PRODUCT RESEARCH.pdfJerikkLaureta
15 views13 slides
20231123_Camunda Meetup Vienna.pdf by
20231123_Camunda Meetup Vienna.pdf20231123_Camunda Meetup Vienna.pdf
20231123_Camunda Meetup Vienna.pdfPhactum Softwareentwicklung GmbH
28 views73 slides
Business Analyst Series 2023 - Week 3 Session 5 by
Business Analyst Series 2023 -  Week 3 Session 5Business Analyst Series 2023 -  Week 3 Session 5
Business Analyst Series 2023 - Week 3 Session 5DianaGray10
209 views20 slides
TouchLog: Finger Micro Gesture Recognition Using Photo-Reflective Sensors by
TouchLog: Finger Micro Gesture Recognition  Using Photo-Reflective SensorsTouchLog: Finger Micro Gesture Recognition  Using Photo-Reflective Sensors
TouchLog: Finger Micro Gesture Recognition Using Photo-Reflective Sensorssugiuralab
15 views15 slides

Recently uploaded(20)

Special_edition_innovator_2023.pdf by WillDavies22
Special_edition_innovator_2023.pdfSpecial_edition_innovator_2023.pdf
Special_edition_innovator_2023.pdf
WillDavies2216 views
.conf Go 2023 - Data analysis as a routine by Splunk
.conf Go 2023 - Data analysis as a routine.conf Go 2023 - Data analysis as a routine
.conf Go 2023 - Data analysis as a routine
Splunk93 views
AMAZON PRODUCT RESEARCH.pdf by JerikkLaureta
AMAZON PRODUCT RESEARCH.pdfAMAZON PRODUCT RESEARCH.pdf
AMAZON PRODUCT RESEARCH.pdf
JerikkLaureta15 views
Business Analyst Series 2023 - Week 3 Session 5 by DianaGray10
Business Analyst Series 2023 -  Week 3 Session 5Business Analyst Series 2023 -  Week 3 Session 5
Business Analyst Series 2023 - Week 3 Session 5
DianaGray10209 views
TouchLog: Finger Micro Gesture Recognition Using Photo-Reflective Sensors by sugiuralab
TouchLog: Finger Micro Gesture Recognition  Using Photo-Reflective SensorsTouchLog: Finger Micro Gesture Recognition  Using Photo-Reflective Sensors
TouchLog: Finger Micro Gesture Recognition Using Photo-Reflective Sensors
sugiuralab15 views
Black and White Modern Science Presentation.pptx by maryamkhalid2916
Black and White Modern Science Presentation.pptxBlack and White Modern Science Presentation.pptx
Black and White Modern Science Presentation.pptx
maryamkhalid291614 views
.conf Go 2023 - How KPN drives Customer Satisfaction on IPTV by Splunk
.conf Go 2023 - How KPN drives Customer Satisfaction on IPTV.conf Go 2023 - How KPN drives Customer Satisfaction on IPTV
.conf Go 2023 - How KPN drives Customer Satisfaction on IPTV
Splunk88 views
Combining Orchestration and Choreography for a Clean Architecture by ThomasHeinrichs1
Combining Orchestration and Choreography for a Clean ArchitectureCombining Orchestration and Choreography for a Clean Architecture
Combining Orchestration and Choreography for a Clean Architecture
ThomasHeinrichs169 views
The Importance of Cybersecurity for Digital Transformation by NUS-ISS
The Importance of Cybersecurity for Digital TransformationThe Importance of Cybersecurity for Digital Transformation
The Importance of Cybersecurity for Digital Transformation
NUS-ISS27 views
handbook for web 3 adoption.pdf by Liveplex
handbook for web 3 adoption.pdfhandbook for web 3 adoption.pdf
handbook for web 3 adoption.pdf
Liveplex19 views
RADIUS-Omnichannel Interaction System by RADIUS
RADIUS-Omnichannel Interaction SystemRADIUS-Omnichannel Interaction System
RADIUS-Omnichannel Interaction System
RADIUS15 views
Future of Learning - Khoong Chan Meng by NUS-ISS
Future of Learning - Khoong Chan MengFuture of Learning - Khoong Chan Meng
Future of Learning - Khoong Chan Meng
NUS-ISS33 views
Upskilling the Evolving Workforce with Digital Fluency for Tomorrow's Challen... by NUS-ISS
Upskilling the Evolving Workforce with Digital Fluency for Tomorrow's Challen...Upskilling the Evolving Workforce with Digital Fluency for Tomorrow's Challen...
Upskilling the Evolving Workforce with Digital Fluency for Tomorrow's Challen...
NUS-ISS28 views
DALI Basics Course 2023 by Ivory Egg
DALI Basics Course  2023DALI Basics Course  2023
DALI Basics Course 2023
Ivory Egg14 views
The details of description: Techniques, tips, and tangents on alternative tex... by BookNet Canada
The details of description: Techniques, tips, and tangents on alternative tex...The details of description: Techniques, tips, and tangents on alternative tex...
The details of description: Techniques, tips, and tangents on alternative tex...
BookNet Canada121 views
PharoJS - Zürich Smalltalk Group Meetup November 2023 by Noury Bouraqadi
PharoJS - Zürich Smalltalk Group Meetup November 2023PharoJS - Zürich Smalltalk Group Meetup November 2023
PharoJS - Zürich Smalltalk Group Meetup November 2023
Noury Bouraqadi120 views

Securing your web application through HTTP headers

  • 1. SECURING YOUR WEB APPLICATION THROUGH HTTP HEADERS Booster — 14. March 2013 André N. Klingsheim (@klingsen) AppSec AS 1
  • 2. OUTLINE • HTTP headers • Attacks and security headers • Cross site scripting (XSS) — Content Security Policy • Clickjacking — X-Frame-options • SSL stripping++ — HTTP Strict Transport Security • Session hijacking — Cookie security settings • MIME type attacks — X-Download-Options, X-Content-Type-options 2
  • 3. DEMO 3
  • 4. HYGIENE: VERSION HEADERS • Web servers and web application frameworks tend to include version headers in the HTTP responses • There really is no reason to leak this information to an attacker • Get rid of them and save the bandwith! • Demo 4
  • 5. Cross site scripting (XSS) CONTENT SECURITY POLICY 5
  • 6. CROSS SITE SCRIPTING (XSS) • Reflected • User controlled data from the request is included in the response • Persistent • Attacker is able to store the attack server side, the stored attack is later included in response(s) • DOM based • Does not involve the server, happens on the client side - XSS (Cross Site Scripting) Prevention Cheat Sheet - OWASP Top 10 for JavaScript – A2: Cross Site Scripting – XSS 6
  • 7. DEMO 7
  • 8. CONTENT SECURITY POLICY (CSP) • Lets you specify a policy for where content in your webpages can be loaded from • Lets you put restrictions on script execution • Headers • Content-Security-Policy – Chrome 25 • X-Content-Security-Policy – Firefox 4+ • X-WebKit-Csp – WebKit browsers (Chrome/Safari) • W3C Candidate recommendation • Will end up being a proper standard! 8
  • 9. CSP DIRECTIVES • default-src — Specifies the default for other sources • script-src • style-src • object-src — plugins • img-src • media-src — video/audio • frame-src • font-src • connect-src • report-uri — Specifies where CSP violations can be reported 9
  • 10. CSP SOURCES (FOR THE DIRECTIVES) • 'none' — No content of this type is allowed (All directives) • 'self' — Content of this type can only be loaded from the same origin (no content from other sites) (All directives) • 'unsafe-inline' — Allows unsafe inline content. • Supported by style-src (inline css) and script-src (inline script) • 'unsafe-eval' — Allows script functions considered unsafe (such as eval()) • Supported by script-src • And you can specify custom sources: • * — Allow content from anywhere • https: — Scheme only, load only content served over https • *.nwebsec.com — Wildcard host, allow content from any nwebsec.com sub-domain. • www.nwebsec.com:81 — You can specify a port number • https://www.nwebsec.com — You can of specify an absolute URI for a host (path has no effect though) 10
  • 11. AND THEN IT ALL COMES TOGETHER • Content-Security-Policy: default-src 'self'; script-src 'self' scripts.nwebsec.codeplex.com • This policy sets a default source of 'self' for all directives. • script-src defines its own sources, replacing the default (hence the inclusion of 'self') • In effect, scripts, stylesheets, images, flash animations, Java applets etc can only be loaded from the same origin as the page • Scripts can also be loaded from scripts.nwebsec.codeplex.com • This policy denies inline scripts and CSS! 11
  • 12. THE "SPECIAL" SOURCES • 'unsafe-inline' can allow inline scripts (script-src) and styles (style-src) • 'unsafe-eval' allows certain JavaScript functions considered high risk (eval()) • Use these special sources with care 12
  • 13. CSP REPORTING • You can specify a "report-uri" in the CSP header • Must be a relative URI • Will post violation reports as JSON back to the web application • Content-Security-Policy-Report-Only • Will not block scripts or resources violating the policy • Will report them to the web application 13
  • 14. XSS SUMMARIZED • Make sure you validate your inputs • Make sure you encode everything you output • Input to the web application • Data from backend systems • EVERYTHING! • Use CSP as an extra level of defense, it's not the cure! 14
  • 16. CLICKJACKING • A malicious site loads the vulnerable site in an iframe • The iframe is invisible, and positioned in front of something the user is likely to click on • The user clicks on what appears to be an element on the malicious site • The user really clicks in the iframe, triggering some operation on the vulnerable site 16
  • 17. CLICKJACKING DEMO Vulnerable site Evil site Delete something! Click me! 17
  • 18. FRAMESNIFFING • You can specify an URL with an anchor when loading an iFrame • Browsers would scroll to the anchor tag, or the html element with the relevant id attribute • This scrolling can be detected with JavaScript • Note: Vulnerability has been fixed in latest versions of browsers 18
  • 19. X-FRAME-OPTIONS • X-Frame-Options: Deny | SameOrigin • Instructs the browser to not display the page in a frame • When the page isn’t displayed, there’s nothing to click on! • Browser support: Opera 10.5, Chrome 4.1, IE 8, Firefox 3.6.9, Safari 4 • Remember: The request is still sent to — and prosessed by — the web server! 19
  • 20. X-FRAME-OPTIONS SEQUENCE DIAGRAM Attacker Target 20
  • 22. HTTPS STRIPPING EXPLAINED • "Secure" websites use SSL/TLS to preserve the confidentiality and integrity of the communication with a browser • For usability, "secure" websites are still accessible through insecure channels (HTTP on port 80) • They’ll redirect the user to HTTPS • User enters www.onlinebank.com — and is redirected to https://www.onlinebank.com • The very first request is insecure, and open to attack! • SSL stripping is a middleperson attack • Attacker keeps the victim on HTTP, but passes requests on over HTTPS to the target website • Practical attack demoed at Black Hat in 2009 (sslstrip) http://www.thoughtcrime.org/software/sslstrip/ 22
  • 23. HOW "SECURE BROWSING" USUALLY WORKS www.onlinebank.com (unprotected) Redirect: https://www.onlinebank.com (unprotected) https://www.onlinebank.com (protected) Online bank 23
  • 24. HTTPS STRIPPING www.onlinebank.com (unprotected) https://www.onlinebank.com (protected) Response (unprotected) Response (protected) http://www.onlinebank.com (unprotected) https://www.onlinebank.com (protected) Attacker Online bank Response (unprotected) Response (protected) 24
  • 25. DEMO 25
  • 26. HTTP STRICT TRANSPORT SECURITY • Strict-Transport-Security: max-age=31536000; includeSubDomains • Max-age specifies for how many seconds the policy should be in effect • includeSubDomains — optional • Instructs the browser to only communicate to that hostname over SSL/TLS • Fails hard on certificate errors • The user does not have the option to click through certificate warnings • Browser support: Chrome 4+, Firefox 4+, Opera 12 26
  • 28. SESSION HIJACKING EXPLAINED • Means getting access to a user's privileged session -> steal session tokens • On the web, session tokens mean cookies • Protect the cookies! • Cookies can be marked with the "httpOnly" flag -> makes them inaccessible to JS, they won't be included in requests from applets. • Cookies can be marked with the "secure" flag -> instructs the browser to only send them with HTTPS requests 28
  • 29. DEMO 29
  • 31. IE MIME SNIFFING • HTTP responses include a header stating what type of content is included • E.g. Content-Type: text/html; charset=utf-8 • To compensate for misconfigured servers and bad programming, IE introduced MIME sniffing back in the days (IE4) • Some undesires side effects when IE guesses wrong • They introduced the "X-Content-Type-Options: nosniff " header in IE9 to disable the behaviour • Always serve your content with the correct content type, and the "X-Content-Type-Options" header • Demo! 31
  • 33. ADDING HEADERS IS EASY • Benefits • Usually a single line of code in any "webpage" • Can often be added through config • Prevents well known attacks • Cost • Low • CSP can be expensive, might require rewrite of existing applications 33
  • 34. SOME REFERENCES • Blog: Security through HTTP response headers • http://www.dotnetnoob.com/2012/09/security-through-http-response-headers.html • The NWebsec security library for ASP.NET • http://nwebsec.codeplex.com/ • The NWebsec demo site • http://www.nwebsec.com/ • The application used for demo here • https://github.com/klings/Booster2013 34