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
Cookie Theft and Session Hijacking
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
shawn0102
August 16, 2014
Programming
2
130
Cookie Theft and Session Hijacking
shawn0102
August 16, 2014
Tweet
Share
More Decks by shawn0102
See All by shawn0102
Cookie Theft and Session Hijacking
shawn0102
0
940
Generators in ES6
shawn0102
2
140
Other Decks in Programming
See All in Programming
OCaml 5でモダンな並列プログラミングを Enjoyしよう!
haochenx
0
140
AI Schema Enrichment for your Oracle AI Database
thatjeffsmith
0
290
Best-Practices-for-Cortex-Analyst-and-AI-Agent
ryotaroikeda
1
110
20260127_試行錯誤の結晶を1冊に。著者が解説 先輩データサイエンティストからの指南書 / author's_commentary_ds_instructions_guide
nash_efp
1
970
並行開発のためのコードレビュー
miyukiw
0
180
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
580
OSSとなったswift-buildで Xcodeのビルドを差し替えられるため 自分でXcodeを直せる時代になっている ダイアモンド問題編
yimajo
3
620
コマンドとリード間の連携に対する脅威分析フレームワーク
pandayumi
1
450
AIによる高速開発をどう制御するか? ガードレール設置で開発速度と品質を両立させたチームの事例
tonkotsuboy_com
7
2.3k
MUSUBIXとは
nahisaho
0
130
CSC307 Lecture 04
javiergs
PRO
0
660
Data-Centric Kaggle
isax1015
2
780
Featured
See All Featured
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
10
1.1k
Context Engineering - Making Every Token Count
addyosmani
9
660
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
2.7k
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.6k
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
1
440
Highjacked: Video Game Concept Design
rkendrick25
PRO
1
290
Exploring the relationship between traditional SERPs and Gen AI search
raygrieselhuber
PRO
2
3.6k
Art, The Web, and Tiny UX
lynnandtonic
304
21k
Measuring & Analyzing Core Web Vitals
bluesmoon
9
750
GraphQLとの向き合い方2022年版
quramy
50
14k
The Mindset for Success: Future Career Progression
greggifford
PRO
0
240
Transcript
Cookie Theft & Session Hijacking 邵帅 twitter@shawn0102 weibo@shaoshuai0102 http://shaoshuai.me
None
cookie有关的术语 • session cookie • persistent cookie/tracking cookie • secure
cookie • httpOnly cookie • third-party cookie • supercookie • zombie cookie/evercookie
httponly cookie 被声明为httponly的cookie只有在 执⾏行http/https请求时会带上,在js中⽆无 法获取到 Set-Cookie: JSESSIONID=xx88bss008; Domain=.foo.com; Path=/; HttpOnly
secure cookie 被声明为secure的cookie只有在使 ⽤用https时会加密传输,不会在http请求 中传输 Set-Cookie: JSESSIONID=xx88bss008; Domain=.foo.com; Path=/; Secure
cookie的⽤用途 • session管理! • 个性化 • user tracking
session cookie被窃取 的危害演⽰示
“怎么偷⾛走session cookie?”
利⽤用xss漏洞获取cookie
我把session cookie设置为httpOnly,xss漏洞就 ⽆无法拿到session cookie了吧?
如果是php,如果开放了phpinfo权限,攻击就可 ⾏行了:xss发起异步请求,分析response拿到 httpOnly的cookie
设置httpOnly,关闭phpinfo,还有办法吗
XST!
XST • XST = Cross Site Tracing = XSS +
http trace • http trace是让我们的web服务器将客户端的所有请求信 息返回给客户端的⽅方法。其中包含了httpOnly的 cookie。 • 最佳实践是关闭服务器的trace功能。 • 但是当使⽤用代理的时候,代理可以被配置成⽀支持trace, 从⽽而⼜又可以进⾏行xst攻击了,所以代理要慎⽤用! • 还好现代浏览器禁⽤用了异步发送trace请求的功能。
设置httpOnly,关闭phpinfo,关闭trace⽀支持,⽤用 户使⽤用的是现代浏览器,还有办法偷⾛走session吗
以上⽅方式只防⽌止通过浏览器拿到 session cookie,但是可以通过拿 到实际的⺴⽹网络请求,所有cookie都 ⽆无法隐藏!
⽅方式⼀一⺴⽹网络监听(network eavsdropping) • 只要是未使⽤用https加密的⺴⽹网站都可以抓包 分析,其中包含session cookie • 未保护的wifi,对同⼀一⺴⽹网络下的请求进⾏行 监听 •
⼯工具firesheep http://codebutler.com/ firesheep/
⽅方式⼆二 DNS缓存投毒 • 把要攻击的域名的⼀一个⼦子域映射到攻击者 的server,然后想办法让被攻击者访问这 个server,请求中会带过来所有cookie (包括httpOnly)
⽅方式三 中间⼈人攻击 • 搭建免费wifi,把DHCP服务器指定为攻击 者ip,在攻击者机器上可以收到所有请 求,不仅可以获取session cookie,还可 以进⾏行脚本注⼊入 • 未使⽤用https才可以
⽅方式四 代理服务器/VPN等 • 翻墙⽤用免费VPN?⼩小⼼心你的session cookie
使⽤用https协议,是不是中间⼈人就⽆无法攻击了
如果同时⽀支持http和https,那么 还是可以使⽤用⺴⽹网络监听http请求获 取session cookie
只⽀支持https,不⽀支持http
如果输⼊入example.com发起请 求,会有⼀一次301重定向,这次请 求是http的,也会带上cookie!
把 session cookie设置成secure,只允 许在https上加密传输
其他cookie(⾮非secure)在这次301 请求中还是可以拿到,就看有没 有有⽤用信息了
设置header Strict-Transport- Security,直接省略这个http请求! http://www.wooyun.org/bugs/wooyun-2010-0498 36b625b1c47b40b270c6a390a0fb9525
现实 • ⼀一个https的⺴⽹网站,有某些⼦子域名使⽤用http提供服 务,通常为了统⼀一session,会不设置session cookie为secure,可以通过中间⼈人攻击劫持 session。
如果偷取cookie失败,⽆无 法session劫持,攻击者 如何再发起攻击?
劫持session的⺫⽬目的是拿到登录态,从⽽而获得服务器授权做很多 请求,例如账户变更。如果劫持不到session,也能够做授权请 求不是也达到攻击的⺫⽬目的了? ! ⽆无需拿到session cookie,跨站发起请求就可以了,这就是 CSRF! ! server通过把⽤用户凭证存储在cookie以维持session,http/https 协议每次访问都会⾃自动传输cookie,协议上的缺陷是导致可进⾏行
CSRF攻击的根本原因! ! 防御⽅方式:使⽤用anti-forgery token ! CSRF
“⼤大部分攻击都是提权⾏行为,最基本的提权通过偷 取⽤用户名密码,不成功转⽽而窃取session,窃取不 成转⽽而跨站攻击,实在不⾏行重放也可以造成危害” 总结
谢谢