Hacker101 ~The Web In Depth Cookie, Same-Origin Policy
今回は、HackerOneにあるHacker101を使って、どのような脆弱性があるか学びます。
今更ですが。。。
- Introduction
- The Web In Depth <-今日はこれ
- XSS and Authorization
- SQL Injection and Friends
- Session Fixation
- Clickjacking
- File Inclusion Bugs
- File Upload Bugs
- Null Termination Bugs
- Unchecked Redirects
- Password Storage
- Crypto series
- Threat Modeling
- Writing Good Reports
- Burp Suite series
- Secure Architecture Review
- Server-Side Request Forgery
- Source Code Review
- XML External Entities
- Cookie Tampering Techniques
- Mobile App Hacking series
- Native Code Crash Course
Webサーバとの情報のやり取りに使う、Key-Value
ドメインごとに保存している、読み書きにルールがある
・セットする場合
ドメインおよびpathに値をセットしない
→書き込みを行ったサイトのドメインおよびpathがセットされる
ドメインおよびpathに値をセット
→セットしたドメインおよびpathがセットされる
・読みだす場合
基本、同一ドメインおよびサブドメイン、pathがセットした値より深い場合は読み出せる
例)ドメイン:test.exp.com PATH:/test がセットされている場合
test.exp.com/test というページからは読み込める
test.exp.com/test/under というページからは読み込める
test.exp.com/ というページからは読み込めない
site.test.exp.com/test というページからは読み込める
test.exp.com/ というページからは読み込めない
text2.exp.com/test というページからは読めない
☆test.exp.com/test_siteというページから読み込めてしまう!!!
※Cookieは文字列前方一致でしか見ていないらしい!!!
参考:http://www.imymode.com/exp/cookie.html
◇Same-Origin Policy?
Same-Origin Policyを満たす
→Cross-Siteとみなされない
Same-Originである条件
・同一ポート
・同一ドメイン名
サブドメインとかもNG
例)http://test.site.com/test に対してSame-Originかどうか
・http://test.site.com/test/file -> Yes
・http://test.site.com/file -> Yes
・https://test.site.com/test -> No
・http://test2.site.com/test -> No
参考:https://developer.mozilla.org/ja/docs/Web/Security/Same-origin_policy
以下、メモ
************************************************************************
HTTPリクエストについて
Host, Accept, Cookie, Referer, Authorization
test.exam.com test2.exam.com <-読めない
test.exam.com lll.test.exam.cm <- 読める
Cookieのセキュリティ
Secure, HTTPOnly
HTML 解釈するブラウザの種類によっては簡単にXSSなどできてしまう可能性あり
古いブラウザだと、</script>で閉じなくてもPageの終わりで自動的に閉じる
Content Sniffinfg
Content-TypeによらずタグがあればHTMLとして解釈してしまう
・Encodinf Sniffing
+ADw-script+AD4-alert(1);+ADw-/script+AD4-
Same-Origin Policy
Origin Matching
-HTTPS or HTTP
-Port
-Domain nameの完全一致
CORS
Cross-Site Requesdt Forgery
Mitigation
use CSRF token
not good dynamic CSRF-proof forms
*********************************************************
以上