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.1k
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
180
How We Replaced Salary Negotiations with a Sinatra App
rkh
17
4.1k
HTTP (RubyMonsters Edition)
rkh
5
1k
GCRC 2015: Abstract Thoughts on Abstract Things
rkh
1
340
Frozen Rails: Magenta - The Art Of Abstraction
rkh
3
280
RedDotRubyConf 2014: Magenta is a Lie - and other tales of abstraction
rkh
0
810
Ancient City Ruby: Hack me, if you can!
rkh
2
390
Boston I/O: Continuous Integration
rkh
3
300
Steel City Ruby: Architecting Chaos
rkh
4
880
Other Decks in Technology
See All in Technology
マルチプロダクト開発の現場でAWS Security Hubを1年以上運用して得た教訓
muziyoshiz
3
2.3k
新機能VPCリソースエンドポイント機能検証から得られた考察
duelist2020jp
0
220
2024年にチャレンジしたことを振り返るぞ
mitchan
0
140
生成AIのガバナンスの全体像と現実解
fnifni
1
190
KubeCon NA 2024 Recap: How to Move from Ingress to Gateway API with Minimal Hassle
ysakotch
0
200
終了の危機にあった15年続くWebサービスを全力で存続させる - phpcon2024
yositosi
11
9.9k
re:Invent をおうちで楽しんでみた ~CloudWatch のオブザーバビリティ機能がスゴい!/ Enjoyed AWS re:Invent from Home and CloudWatch Observability Feature is Amazing!
yuj1osm
0
120
多領域インシデントマネジメントへの挑戦:ハードウェアとソフトウェアの融合が生む課題/Challenge to multidisciplinary incident management: Issues created by the fusion of hardware and software
bitkey
PRO
2
110
watsonx.ai Dojo #5 ファインチューニングとInstructLAB
oniak3ibm
PRO
0
160
スタートアップで取り組んでいるAzureとMicrosoft 365のセキュリティ対策/How to Improve Azure and Microsoft 365 Security at Startup
yuj1osm
0
220
Wvlet: A New Flow-Style Query Language For Functional Data Modeling and Interactive Data Analysis - Trino Summit 2024
xerial
1
120
kargoの魅力について伝える
magisystem0408
0
210
Featured
See All Featured
The Pragmatic Product Professional
lauravandoore
32
6.3k
Fashionably flexible responsive web design (full day workshop)
malarkey
405
66k
The Language of Interfaces
destraynor
154
24k
How STYLIGHT went responsive
nonsquared
95
5.2k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
191
16k
GraphQLの誤解/rethinking-graphql
sonatard
67
10k
Git: the NoSQL Database
bkeepers
PRO
427
64k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
95
17k
Bootstrapping a Software Product
garrettdimon
PRO
305
110k
For a Future-Friendly Web
brad_frost
175
9.4k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
17
2.3k
Making the Leap to Tech Lead
cromwellryan
133
9k
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