Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Distill: Death to Cookies
Search
Konstantin Haase
August 09, 2013
Technology
7
1.2k
Distill: Death to Cookies
Konstantin Haase
August 09, 2013
Tweet
Share
More Decks by Konstantin Haase
See All by Konstantin Haase
RubyConf Philippines 2017: Magenta is a Lie
rkh
0
190
How We Replaced Salary Negotiations with a Sinatra App
rkh
17
4.2k
HTTP (RubyMonsters Edition)
rkh
5
1.1k
GCRC 2015: Abstract Thoughts on Abstract Things
rkh
1
360
Frozen Rails: Magenta - The Art Of Abstraction
rkh
3
300
RedDotRubyConf 2014: Magenta is a Lie - and other tales of abstraction
rkh
0
920
Ancient City Ruby: Hack me, if you can!
rkh
2
420
Boston I/O: Continuous Integration
rkh
3
310
Steel City Ruby: Architecting Chaos
rkh
4
910
Other Decks in Technology
See All in Technology
vLLM meetup Tokyo
jpishikawa
1
200
新規プロダクト開発、AIでどう変わった? #デザインエンジニアMeetup
bengo4com
0
440
研究開発部メンバーの働き⽅ / Sansan R&D Profile
sansan33
PRO
3
17k
All About Sansan – for New Global Engineers
sansan33
PRO
1
1.2k
Workflows から Agents へ ~ 生成 AI アプリの成長過程とアプローチ~
belongadmin
2
140
「どこにある?」の解決。生成AI(RAG)で効率化するガバメントクラウド運用
toru_kubota
2
340
OpenTelemetry Collector internals
ymotongpoo
5
530
Devin(Deep) Wiki/Searchの活用で変わる開発の世界観/devin-wiki-search-impact
tomoki10
0
290
白金鉱業Meetup_Vol.19_PoCはデモで語れ!顧客の本音とインサイトを引き出すソリューション構築
brainpadpr
2
270
Roo CodeとClaude Code比較してみた
pharma_x_tech
2
310
Text-to-SQLの評価データセットを作って最新LLMモデルの性能評価をしてみた
gotalab555
3
770
バクラクのモノレポにおける AI Coding のための環境整備と {Roo,Claude} Code活用事例 / AI Coding in Bakuraku's Monorepo: Environment Setup & Case Studies with {Roo, Claude} Code
upamune
9
5.9k
Featured
See All Featured
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
30
2.1k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
53k
StorybookのUI Testing Handbookを読んだ
zakiyama
30
5.8k
The Cost Of JavaScript in 2023
addyosmani
50
8.3k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
180
53k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.5k
Making Projects Easy
brettharned
116
6.2k
Docker and Python
trallard
44
3.4k
GitHub's CSS Performance
jonrohan
1031
460k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
667
120k
Unsuck your backbone
ammeep
671
58k
Measuring & Analyzing Core Web Vitals
bluesmoon
7
480
Transcript
Death to Cookies Konstantin Haase @konstantinhaase
story time
None
None
None
once upon a time
None
None
Recipetastic™
None
None
Bob Alice
Bob Alice
Bob Alice Eve
Bob Alice Mallet
problem solved
None
POST /login HTTP/1.1 Host: www.recipetast.ic Content-Length: 44
[email protected]
& password=st0p%20Motion
HTTP/1.1 200 OK Content-Type: text/html Set-Cookie: user=bob <html> ...
GET / HTTP/1.1 Host: www.recipetast.ic Cookie: user=bob
Guessing
None
None
None
HTTP/1.1 200 OK Content-Type: text/html Set-Cookie: user=bob Set-Cookie: pwd=... <html>
...
GET / HTTP/1.1 Host: www.recipetast.ic Cookie: user=bob,pwd=...
GET / HTTP/1.1 Host: www.recipetast.ic Cookie: user=bob,pwd=... Basic Auth, just
with cookies
HTTP/1.1 200 OK Content-Type: text/html Set-Cookie: user=bob Set-Cookie: token=... <html>
...
None
XSS Cross Site Scripting
None
can read cookie and send it somewhere
None
HTTP/1.1 200 OK Content-Type: text/html Set-Cookie: user=bob; HttpOnly <html> ...
None
can read (and write) recipes
None
sanitize all user input
Content Security Policy
None
CSRF Cross Site Request Forgery
Is this awesome, y/n?
None
GET /create?… HTTP/1.1 Host: www.recipetast.ic Cookie: user=alice
GET /create?… HTTP/1.1 Host: www.recipetast.ic Cookie: user=alice Deadly cookies!
None
GET, HEAD, OPTIONS, TRACE PUT, DELETE, LINK, UNLINK POST, PATCH
1 2 PUT / 2 PUT / 2 Repeatable! :)
State change! :( Deterministic! :) https://speakerdeck.com/rkh/we-dont-know-http
GET, HEAD, OPTIONS, TRACE PUT, DELETE, LINK, UNLINK POST, PATCH
None
None
None
POST /create HTTP/1.1 Host: www.recipetast.ic Cookie: user=alice ...
POST /create HTTP/1.1 Host: www.recipetast.ic Cookie: user=alice ... Deadly cookies!
None
POST /create HTTP/1.1 Host: www.recipetast.ic Referer: http://awesome- website.com/ Cookie: user=alice
POST /create HTTP/1.1 Host: www.recipetast.ic Referer: http://awesome- website.com/ Cookie: user=alice
[sic]
None
None
Referer is not set for FTP or HTTPS referrers
Referer can be spoofed by outdated flash plugin
None
POST /create HTTP/1.1 Host: www.recipetast.ic Origin: http://awesome- website.com Cookie: user=alice
None
None
Not supported by older browsers
Origin can probably be spoofed by outdated flash plugin
None
HTTP/1.1 200 OK Content-Type: text/html Set-Cookie: csrf_token=XXX
None
None
Cheating Same Origin
HTTP/1.1 200 OK Content-Type: application/json
An attacker could just load it, right?
AJAX can only load from the same origin (or CORS)
None
seems harmless
In JavaScript, you can override the array constructor.
https://github.com/rkh/json-csrf
None
Never serve JSON that has an array at top level
(or don’t use cookies)
None
VBScript did not fully implement Same Origin
None
Block Internet Explorer before IE9
Block Internet Explorer before IE9
require CSRF token for all AJAX requests
None
Are we doing good so far?
None
Can we trust a cookie?
DNS cache poisoning
Can we trust the browser?
Can we trust browser plugins?
None
None
Signed Cookies
Encrypted Cookies
None
Eaves- dropping
encrypting cookies does not help
None
None
None
attacker cannot parse cookie from stream
None
Or can they?
BEAST Browser Exploit Against SSL/ TLS
decrypts TLS 1.0 streams via injected JavaScript
None
fixed in TLS 1.1
force recent browser
don’t allow TLS 1.0
None
CRIME Compression Ratio Info-leak Made Easy
SSL has built-in compression
GET /?user=alice HTTP/1.1 Host: www.recipetast.ic Cookie: user=bob GET /?user=bob HTTP/1.1
Host: www.recipetast.ic Cookie: user=bob better compression
None
update your browser
turn off SSL compression
append random number of bytes to response
None
BREACH Browser Reconnaissance and Exfiltration via Adaptive Compression of Hypertext
like CRIME, but for the response
attack the CSRF token, not the cookie
inject something in the response http://www.recipetast.ic/search?q=XXX
None
mask CSRF tokens differently in every response (Rails PR pending)
don’t use CSRF tokens
None
Do you think about all this when you build an
app?
Next attack vector around the corner?
None
Alternatives
IP address
Session ID in URL
None
Custom Authorization header
None
Store value in Local Storage
Needs JavaScript :(
Works well with PJAX/ Turbo Links like setups
None
New Browser Concepts?
None
@konstantinhaase
[email protected]
rkh.im