SlideShare a Scribd company logo
1 of 32
Download to read offline
Cookie Security
Myths and Misconceptions
David Johansson - AppSec USA 2017
About Me
• David Johansson (@securitybits)
– Security consultant with 10 years in AppSec
– Helping clients design and build secure software
– Develop and deliver security training
– Based in London, working for Synopsys
Cookie Security
• Why talk about Cookie Security?
Cookie security is somewhat broken…
Image src: https://commons.wikimedia.org/wiki/File:Choco_chip_cookie_half.png (Author: Bob Smith, modifications made by Chzz)
Agenda
• Cookie Basics
• The ‘Secure’ Attribute
• The ‘HttpOnly’ Attribute
• The ‘Path’ Attribute
• The ‘Domain’ Attribute
• Cookie Lifetime
• Modern Cookie Protections
• Summary
COOKIE BASICS
Background
History of HTTP Cookies
Cookies are based on an old recipe:
• 1994 –Netscape draft
• 1997 – RFC 2109
• 2000 – RFC 2965
• 2002 – HttpOnly
• 2011 – RFC 6265
• 2017 – RFC 6265bis (draft)
“Classic Film” (https://www.flickr.com/photos/29069717@N02/)
HTTP Cookies
• Cookies are sent in HTTP headers
• Attributes influence how cookies are managed by the client
(e.g., browser)
Server response
HTTP/1.1 200 OK
…
Set-Cookie:
id=2bf353246gf3; Secure;
HttpOnly
Set-Cookie: lang=en;
Expires=Wed, 09 Jun 2021
10:18:14 GMT
Subsequent client request
GET /index.html HTTP/1.1
…
Cookie: id=2bf353246gf3;
lang=en
THE ‘SECURE’ ATTRIBUTE
Keeping Cookies Secure from Network-level Attackers
The ‘Secure’ Attribute
“Cookies marked with the ‘Secure’ attribute are only sent over
encrypted HTTPS connections and are therefore safe from man-
in-the-middle attacks.”
–True or false?
The ‘Secure’ Attribute
• The ‘Secure’ attribute only protects the confidentiality of a
cookie against MiTM attackers – there is no integrity
protection!
– Mallory can’t read ‘secure’ cookies
– Mallory can still write/change ‘secure’ cookies
Image source: https://commons.wikimedia.org/wiki/File:Man_in_the_middle_attack.svg (Author: Miraceti, No changes made, Creative Commons Attribution-Share Alike 3.0 Unported)
DEMO
Bypassing the ‘Double-submit Cookie Pattern’ CSRF Defense
THE ‘HTTPONLY’ ATTRIBUTE
Keeping JavaScript’s Hands Away from the Cookie Jar
The ‘HttpOnly’ Attribute
“Cookies marked with the ‘HttpOnly’ attribute
are not accessible from JavaScript and therefore
unaffected by cross-site scripting (XSS) attacks.”
–True or false?
The ‘HttpOnly’ Attribute
Picture by Greg Putrich (flickr.com)
• Only confidentiality protected in
practice
• HttpOnly-cookies can be replaced by
overflowing the cookie jar from
JavaScript
Image src: https://www.flickr.com/photos/migrashgrutot/6905482601/in/photolist-bwdpoR (Author: Greg Putrich, No Modifications, https://creativecommons.org/licenses/by-nc-nd/2.0/)
DEMO
Overwriting a Cookie Marked as ‘HttpOnly’ from JavaScript
THE ‘PATH’ ATTRIBUTE
Isolating Cookies to Specific Paths
The ‘Path’ Attribute
“The ‘Path’ attribute limits the scope of a cookie to a specific
path on the server and can therefore be used to prevent
unauthorized access to it from other applications on the same
host.”
–True or false?
The ‘Path’ Attribute
• Cookie Scope vs. Same-origin Policy
Host/domainPath
Port &
Protocol
Cookie Scope Same-origin Policy
The ‘Path’ Attribute
example
.com
/App1
https
(443)
Isolated in terms
of cookie scope
Not isolated in
terms of SOP!
/App2
• Two different applications on shared host:
– https://example.com/App1/
– https://example.com/App2/
THE ‘DOMAIN’ ATTRIBUTE
Only Send Cookie to Intended Host(s)
The ‘Domain’ Attribute
“The ‘Domain’ attribute should be set to the origin host to limit
the scope to that particular server. For example if the application
resides on server app.mysite.com, then it should be set to
domain=app.mysite.com”
–True or false?
The ‘Domain’ Attribute
• When domain set, cookies will be sent to that domain
and all its subdomains
• The risk with subdomains is lower than when scoped to
parent domain, but still relevant
• Remove domain attribute to limit cookie to origin host
only
– Important note: IE will always send to subdomains regardless
COOKIE LIFETIME
Limiting Exposure of Cookies
Cookie Lifetime
“A session cookie, also known as an in-memory
cookie or transient cookie, exists only in temporary memory
while the user navigates the website.” (Wikipedia)
–True or false?
Cookie Lifetime
• It’s up to the browser to decide when the session ends
• ‘Non-persistent’ session cookies may actually be persisted to
survive browser restart
https://developer.mozilla.org/en-US/docs/Web/API/document/cookie
MODERN COOKIE PROTECTIONS
RFC6265bis: Making Improvements to the Cookie Recipe
Strict Secure Cookies
• Makes ‘secure’ cookies a little more secure by adding integrity
protection
• Prevents plain-text HTTP responses from setting or overwriting
‘secure’ cookies
• Attackers still have a window of opportunity to “pre-empt”
secure cookies with their own
Cookie Prefixes
• Problem:
– Server only sees cookie name and value in HTTP request, no
information about its attributes
– Impossible for server to know if a cookie it receives was set securely
• Solution:
– ‘Smuggle’ information to server in cookie name
– "__Secure-" prefix
– "__Host-" prefix
The ‘SameSite’ Attribute
• Problem:
– Cookies are sent with all requests to a server, regardless of request
origin
– Attackers can abuse this by initiating authenticated cross-origin
requests, e.g., CSRF, XSSI, etc.
• Solution:
– New cookie attribute SameSite=[Strict|Lax]
– Prevents cookies from being attached to cross-origin requests
SUMMARY
Summary
• Key Takeaways:
– Cookies are still largely based on a draft from 1994
– The security model has many weaknesses
– Don’t build your application on false assumptions about cookie
security
– Application and framework developers should take advantage of new
improvements to cookie security
– Beware that not all browsers are using the same cookie recipe (yet)
The ‘Ultimate’ Cookie
• Is there an ‘ultimate’ cookie configuration?
• This is probably the most secure configuration we have for
now:
Set-Cookie: __Host-SessionID=3h93…;
Path=/;Secure;HttpOnly;SameSite=Strict

More Related Content

What's hot

Html5 security
Html5 securityHtml5 security
Html5 securityKrishna T
 
Drupal point of vue
Drupal point of vueDrupal point of vue
Drupal point of vueDavid Ličen
 
Azure 103 Certification Course
Azure 103 Certification CourseAzure 103 Certification Course
Azure 103 Certification CoursewiTTyMinds1
 
Accessible web applications
Accessible web applicationsAccessible web applications
Accessible web applicationsWojtek Zając
 
Nuxt.JS Introdruction
Nuxt.JS IntrodructionNuxt.JS Introdruction
Nuxt.JS IntrodructionDavid Ličen
 
Bsidesnova- Pentesting Methodology - Making bits less complicated
Bsidesnova- Pentesting Methodology - Making bits less complicatedBsidesnova- Pentesting Methodology - Making bits less complicated
Bsidesnova- Pentesting Methodology - Making bits less complicatedOctavio Paguaga
 
Micro Web Service - Slim and JWT
Micro Web Service - Slim and JWTMicro Web Service - Slim and JWT
Micro Web Service - Slim and JWTTuyen Vuong
 
Amp by Google: The Present And Future Of Quick Content Delivery
Amp by Google: The Present And Future Of Quick Content DeliveryAmp by Google: The Present And Future Of Quick Content Delivery
Amp by Google: The Present And Future Of Quick Content DeliveryRaunak Hajela
 
Responsive websites. Toolbox
Responsive websites. ToolboxResponsive websites. Toolbox
Responsive websites. ToolboxWojtek Zając
 
Responsive Web Design: buzzword or revolution?
Responsive Web Design: buzzword or revolution?Responsive Web Design: buzzword or revolution?
Responsive Web Design: buzzword or revolution?Wojtek Zając
 
Module 01 - WebDriver Basics
Module 01 - WebDriver BasicsModule 01 - WebDriver Basics
Module 01 - WebDriver BasicsNPN Training
 
SEE 2009: Improving Mobile Web Developer Experience
SEE 2009: Improving Mobile Web Developer ExperienceSEE 2009: Improving Mobile Web Developer Experience
SEE 2009: Improving Mobile Web Developer ExperienceTasneem Sayeed
 
Html5: attack and defense
Html5: attack and defenseHtml5: attack and defense
Html5: attack and defenseKsenia Peguero
 
VueJS Introduction
VueJS IntroductionVueJS Introduction
VueJS IntroductionDavid Ličen
 
Javascript issues and tools in production for developers
Javascript issues and tools in production for developersJavascript issues and tools in production for developers
Javascript issues and tools in production for developersMichael Haberman
 

What's hot (20)

Real Time With Web Sockets
Real Time With Web SocketsReal Time With Web Sockets
Real Time With Web Sockets
 
Html5 security
Html5 securityHtml5 security
Html5 security
 
Drupal point of vue
Drupal point of vueDrupal point of vue
Drupal point of vue
 
Azure 103 Certification Course
Azure 103 Certification CourseAzure 103 Certification Course
Azure 103 Certification Course
 
Accessible web applications
Accessible web applicationsAccessible web applications
Accessible web applications
 
Nuxt.JS Introdruction
Nuxt.JS IntrodructionNuxt.JS Introdruction
Nuxt.JS Introdruction
 
Bsidesnova- Pentesting Methodology - Making bits less complicated
Bsidesnova- Pentesting Methodology - Making bits less complicatedBsidesnova- Pentesting Methodology - Making bits less complicated
Bsidesnova- Pentesting Methodology - Making bits less complicated
 
Micro Web Service - Slim and JWT
Micro Web Service - Slim and JWTMicro Web Service - Slim and JWT
Micro Web Service - Slim and JWT
 
Amp by Google: The Present And Future Of Quick Content Delivery
Amp by Google: The Present And Future Of Quick Content DeliveryAmp by Google: The Present And Future Of Quick Content Delivery
Amp by Google: The Present And Future Of Quick Content Delivery
 
Responsive websites. Toolbox
Responsive websites. ToolboxResponsive websites. Toolbox
Responsive websites. Toolbox
 
Responsive Web Design: buzzword or revolution?
Responsive Web Design: buzzword or revolution?Responsive Web Design: buzzword or revolution?
Responsive Web Design: buzzword or revolution?
 
Module 01 - WebDriver Basics
Module 01 - WebDriver BasicsModule 01 - WebDriver Basics
Module 01 - WebDriver Basics
 
SEE 2009: Improving Mobile Web Developer Experience
SEE 2009: Improving Mobile Web Developer ExperienceSEE 2009: Improving Mobile Web Developer Experience
SEE 2009: Improving Mobile Web Developer Experience
 
Vue JS Intro
Vue JS IntroVue JS Intro
Vue JS Intro
 
Html5 for Security Folks
Html5 for Security FolksHtml5 for Security Folks
Html5 for Security Folks
 
Html5: attack and defense
Html5: attack and defenseHtml5: attack and defense
Html5: attack and defense
 
VueJS Introduction
VueJS IntroductionVueJS Introduction
VueJS Introduction
 
Javascript issues and tools in production for developers
Javascript issues and tools in production for developersJavascript issues and tools in production for developers
Javascript issues and tools in production for developers
 
Introduction to backbone js
Introduction to backbone jsIntroduction to backbone js
Introduction to backbone js
 
Bower power
Bower powerBower power
Bower power
 

Similar to Cookie Security Myths and Misconceptions

Browser Security 101
Browser Security 101 Browser Security 101
Browser Security 101 Stormpath
 
Protecting Java EE Web Apps with Secure HTTP Headers
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
 
Building Secure User Interfaces With JWTs
Building Secure User Interfaces With JWTsBuilding Secure User Interfaces With JWTs
Building Secure User Interfaces With JWTsrobertjd
 
Cross Site Scripting - Mozilla Security Learning Center
Cross Site Scripting - Mozilla Security Learning CenterCross Site Scripting - Mozilla Security Learning Center
Cross Site Scripting - Mozilla Security Learning CenterMichael Coates
 
Chapter 13 web security
Chapter 13 web securityChapter 13 web security
Chapter 13 web securitynewbie2019
 
Scott Isaacs Presentationajaxexperience (Final)
Scott Isaacs Presentationajaxexperience (Final)Scott Isaacs Presentationajaxexperience (Final)
Scott Isaacs Presentationajaxexperience (Final)Ajax Experience 2009
 
Sea surfing in asp.net mvc
Sea surfing in asp.net mvcSea surfing in asp.net mvc
Sea surfing in asp.net mvcmagda3695
 
Building Secure User Interfaces With JWTs (JSON Web Tokens)
Building Secure User Interfaces With JWTs (JSON Web Tokens)Building Secure User Interfaces With JWTs (JSON Web Tokens)
Building Secure User Interfaces With JWTs (JSON Web Tokens)Stormpath
 
02-browser-sec-model-sop.pptx
02-browser-sec-model-sop.pptx02-browser-sec-model-sop.pptx
02-browser-sec-model-sop.pptxssuserec53e73
 
Securing your web application through HTTP headers
Securing your web application through HTTP headersSecuring your web application through HTTP headers
Securing your web application through HTTP headersAndre N. Klingsheim
 
BeEF_EUSecWest-2012_Michele-Orru
BeEF_EUSecWest-2012_Michele-OrruBeEF_EUSecWest-2012_Michele-Orru
BeEF_EUSecWest-2012_Michele-OrruMichele Orru
 
External JavaScript Widget Development Best Practices (updated) (v.1.1)
External JavaScript Widget Development Best Practices (updated) (v.1.1) External JavaScript Widget Development Best Practices (updated) (v.1.1)
External JavaScript Widget Development Best Practices (updated) (v.1.1) Volkan Özçelik
 
Towards a More Secure, Reliable, and Performant Web: Tools / Approaches to Help
Towards a More Secure, Reliable, and Performant Web: Tools / Approaches to HelpTowards a More Secure, Reliable, and Performant Web: Tools / Approaches to Help
Towards a More Secure, Reliable, and Performant Web: Tools / Approaches to HelpStephen Donner
 
Notes on SF W3Conf
Notes on SF W3ConfNotes on SF W3Conf
Notes on SF W3ConfEdy Dawson
 
JWT Authentication with AngularJS
JWT Authentication with AngularJSJWT Authentication with AngularJS
JWT Authentication with AngularJSrobertjd
 
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...
Browser Hacking For Fun and Profit | Null Bangalore Meetup 2019 | Divyanshu S...Divyanshu
 
Cookies: HTTP state management mechanism
Cookies: HTTP state management mechanismCookies: HTTP state management mechanism
Cookies: HTTP state management mechanismJivan Nepali
 
External JavaScript Widget Development Best Practices
External JavaScript Widget Development Best PracticesExternal JavaScript Widget Development Best Practices
External JavaScript Widget Development Best PracticesVolkan Özçelik
 

Similar to Cookie Security Myths and Misconceptions (20)

APEX & Cookie Monster
APEX & Cookie MonsterAPEX & Cookie Monster
APEX & Cookie Monster
 
Browser Security 101
Browser Security 101 Browser Security 101
Browser Security 101
 
Protecting Java EE Web Apps with Secure HTTP Headers
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 Headers
 
Building Secure User Interfaces With JWTs
Building Secure User Interfaces With JWTsBuilding Secure User Interfaces With JWTs
Building Secure User Interfaces With JWTs
 
Cookies
CookiesCookies
Cookies
 
Cross Site Scripting - Mozilla Security Learning Center
Cross Site Scripting - Mozilla Security Learning CenterCross Site Scripting - Mozilla Security Learning Center
Cross Site Scripting - Mozilla Security Learning Center
 
Chapter 13 web security
Chapter 13 web securityChapter 13 web security
Chapter 13 web security
 
Scott Isaacs Presentationajaxexperience (Final)
Scott Isaacs Presentationajaxexperience (Final)Scott Isaacs Presentationajaxexperience (Final)
Scott Isaacs Presentationajaxexperience (Final)
 
Sea surfing in asp.net mvc
Sea surfing in asp.net mvcSea surfing in asp.net mvc
Sea surfing in asp.net mvc
 
Building Secure User Interfaces With JWTs (JSON Web Tokens)
Building Secure User Interfaces With JWTs (JSON Web Tokens)Building Secure User Interfaces With JWTs (JSON Web Tokens)
Building Secure User Interfaces With JWTs (JSON Web Tokens)
 
02-browser-sec-model-sop.pptx
02-browser-sec-model-sop.pptx02-browser-sec-model-sop.pptx
02-browser-sec-model-sop.pptx
 
Securing your web application through HTTP headers
Securing your web application through HTTP headersSecuring your web application through HTTP headers
Securing your web application through HTTP headers
 
BeEF_EUSecWest-2012_Michele-Orru
BeEF_EUSecWest-2012_Michele-OrruBeEF_EUSecWest-2012_Michele-Orru
BeEF_EUSecWest-2012_Michele-Orru
 
External JavaScript Widget Development Best Practices (updated) (v.1.1)
External JavaScript Widget Development Best Practices (updated) (v.1.1) External JavaScript Widget Development Best Practices (updated) (v.1.1)
External JavaScript Widget Development Best Practices (updated) (v.1.1)
 
Towards a More Secure, Reliable, and Performant Web: Tools / Approaches to Help
Towards a More Secure, Reliable, and Performant Web: Tools / Approaches to HelpTowards a More Secure, Reliable, and Performant Web: Tools / Approaches to Help
Towards a More Secure, Reliable, and Performant Web: Tools / Approaches to Help
 
Notes on SF W3Conf
Notes on SF W3ConfNotes on SF W3Conf
Notes on SF W3Conf
 
JWT Authentication with AngularJS
JWT Authentication with AngularJSJWT Authentication with AngularJS
JWT Authentication with AngularJS
 
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...
Browser Hacking For Fun and Profit | Null Bangalore Meetup 2019 | Divyanshu S...
 
Cookies: HTTP state management mechanism
Cookies: HTTP state management mechanismCookies: HTTP state management mechanism
Cookies: HTTP state management mechanism
 
External JavaScript Widget Development Best Practices
External JavaScript Widget Development Best PracticesExternal JavaScript Widget Development Best Practices
External JavaScript Widget Development Best Practices
 

Recently uploaded

SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetEnjoy Anytime
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 

Recently uploaded (20)

SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 

Cookie Security Myths and Misconceptions

  • 1. Cookie Security Myths and Misconceptions David Johansson - AppSec USA 2017
  • 2. About Me • David Johansson (@securitybits) – Security consultant with 10 years in AppSec – Helping clients design and build secure software – Develop and deliver security training – Based in London, working for Synopsys
  • 3. Cookie Security • Why talk about Cookie Security? Cookie security is somewhat broken… Image src: https://commons.wikimedia.org/wiki/File:Choco_chip_cookie_half.png (Author: Bob Smith, modifications made by Chzz)
  • 4. Agenda • Cookie Basics • The ‘Secure’ Attribute • The ‘HttpOnly’ Attribute • The ‘Path’ Attribute • The ‘Domain’ Attribute • Cookie Lifetime • Modern Cookie Protections • Summary
  • 6. History of HTTP Cookies Cookies are based on an old recipe: • 1994 –Netscape draft • 1997 – RFC 2109 • 2000 – RFC 2965 • 2002 – HttpOnly • 2011 – RFC 6265 • 2017 – RFC 6265bis (draft) “Classic Film” (https://www.flickr.com/photos/29069717@N02/)
  • 7. HTTP Cookies • Cookies are sent in HTTP headers • Attributes influence how cookies are managed by the client (e.g., browser) Server response HTTP/1.1 200 OK … Set-Cookie: id=2bf353246gf3; Secure; HttpOnly Set-Cookie: lang=en; Expires=Wed, 09 Jun 2021 10:18:14 GMT Subsequent client request GET /index.html HTTP/1.1 … Cookie: id=2bf353246gf3; lang=en
  • 8. THE ‘SECURE’ ATTRIBUTE Keeping Cookies Secure from Network-level Attackers
  • 9. The ‘Secure’ Attribute “Cookies marked with the ‘Secure’ attribute are only sent over encrypted HTTPS connections and are therefore safe from man- in-the-middle attacks.” –True or false?
  • 10. The ‘Secure’ Attribute • The ‘Secure’ attribute only protects the confidentiality of a cookie against MiTM attackers – there is no integrity protection! – Mallory can’t read ‘secure’ cookies – Mallory can still write/change ‘secure’ cookies Image source: https://commons.wikimedia.org/wiki/File:Man_in_the_middle_attack.svg (Author: Miraceti, No changes made, Creative Commons Attribution-Share Alike 3.0 Unported)
  • 11. DEMO Bypassing the ‘Double-submit Cookie Pattern’ CSRF Defense
  • 12. THE ‘HTTPONLY’ ATTRIBUTE Keeping JavaScript’s Hands Away from the Cookie Jar
  • 13. The ‘HttpOnly’ Attribute “Cookies marked with the ‘HttpOnly’ attribute are not accessible from JavaScript and therefore unaffected by cross-site scripting (XSS) attacks.” –True or false?
  • 14. The ‘HttpOnly’ Attribute Picture by Greg Putrich (flickr.com) • Only confidentiality protected in practice • HttpOnly-cookies can be replaced by overflowing the cookie jar from JavaScript Image src: https://www.flickr.com/photos/migrashgrutot/6905482601/in/photolist-bwdpoR (Author: Greg Putrich, No Modifications, https://creativecommons.org/licenses/by-nc-nd/2.0/)
  • 15. DEMO Overwriting a Cookie Marked as ‘HttpOnly’ from JavaScript
  • 16. THE ‘PATH’ ATTRIBUTE Isolating Cookies to Specific Paths
  • 17. The ‘Path’ Attribute “The ‘Path’ attribute limits the scope of a cookie to a specific path on the server and can therefore be used to prevent unauthorized access to it from other applications on the same host.” –True or false?
  • 18. The ‘Path’ Attribute • Cookie Scope vs. Same-origin Policy Host/domainPath Port & Protocol Cookie Scope Same-origin Policy
  • 19. The ‘Path’ Attribute example .com /App1 https (443) Isolated in terms of cookie scope Not isolated in terms of SOP! /App2 • Two different applications on shared host: – https://example.com/App1/ – https://example.com/App2/
  • 20. THE ‘DOMAIN’ ATTRIBUTE Only Send Cookie to Intended Host(s)
  • 21. The ‘Domain’ Attribute “The ‘Domain’ attribute should be set to the origin host to limit the scope to that particular server. For example if the application resides on server app.mysite.com, then it should be set to domain=app.mysite.com” –True or false?
  • 22. The ‘Domain’ Attribute • When domain set, cookies will be sent to that domain and all its subdomains • The risk with subdomains is lower than when scoped to parent domain, but still relevant • Remove domain attribute to limit cookie to origin host only – Important note: IE will always send to subdomains regardless
  • 24. Cookie Lifetime “A session cookie, also known as an in-memory cookie or transient cookie, exists only in temporary memory while the user navigates the website.” (Wikipedia) –True or false?
  • 25. Cookie Lifetime • It’s up to the browser to decide when the session ends • ‘Non-persistent’ session cookies may actually be persisted to survive browser restart https://developer.mozilla.org/en-US/docs/Web/API/document/cookie
  • 26. MODERN COOKIE PROTECTIONS RFC6265bis: Making Improvements to the Cookie Recipe
  • 27. Strict Secure Cookies • Makes ‘secure’ cookies a little more secure by adding integrity protection • Prevents plain-text HTTP responses from setting or overwriting ‘secure’ cookies • Attackers still have a window of opportunity to “pre-empt” secure cookies with their own
  • 28. Cookie Prefixes • Problem: – Server only sees cookie name and value in HTTP request, no information about its attributes – Impossible for server to know if a cookie it receives was set securely • Solution: – ‘Smuggle’ information to server in cookie name – "__Secure-" prefix – "__Host-" prefix
  • 29. The ‘SameSite’ Attribute • Problem: – Cookies are sent with all requests to a server, regardless of request origin – Attackers can abuse this by initiating authenticated cross-origin requests, e.g., CSRF, XSSI, etc. • Solution: – New cookie attribute SameSite=[Strict|Lax] – Prevents cookies from being attached to cross-origin requests
  • 31. Summary • Key Takeaways: – Cookies are still largely based on a draft from 1994 – The security model has many weaknesses – Don’t build your application on false assumptions about cookie security – Application and framework developers should take advantage of new improvements to cookie security – Beware that not all browsers are using the same cookie recipe (yet)
  • 32. The ‘Ultimate’ Cookie • Is there an ‘ultimate’ cookie configuration? • This is probably the most secure configuration we have for now: Set-Cookie: __Host-SessionID=3h93…; Path=/;Secure;HttpOnly;SameSite=Strict