owned this note changed 5 years ago
Linked with GitHub

CDN 網站攻擊 - 這次換駭客當鬼來抓你了 - Mico

此議程探討不同於傳統網頁功能缺陷攻擊的駭客手法。 近年來因網站 CDN/WAF 技術以及網路負載平衡、反向代理等前後端點類型的伺服器架構盛行,被世人遺忘的攻擊手法再次被提起。 網站管理員用了這些節點技術,卻可能因為多了這些端點,反而多了更多新的駭客攻擊方法? 新手乍到 CDN 就像在玩鬼抓人,駭客就像鬼一樣,用了一些手法,找到你,接著攻擊你,你.. 真的躲好了嗎? 一起來看看這些奇妙的攻擊手法吧

先備知識

會從基礎講,有網路(http)基本概念及略懂資安攻擊名詞佳

tags: SITCON 2020 共筆 SITCON 2020 2020 共筆 R0

歡迎大家來到SITCON 2020 ヽ(✿゚▽゚)ノ
共筆入口:https://hackmd.io/@SITCON/2020
手機版請點選上方 按鈕展開議程列表。

請從這裡開始

outline

Speaker: Mico

1. Architecture

一蘭拉麵

  • 本來:要飛到日本才能吃的到
  • 開分店在世界各地,顧客就可以用最低的時間成本和物理距離吃到,CDN同理

伺服器服務模式

單一節點網站服務模式(常見)

  • 通常為單一伺服器
  • 離線快取不友善
  • 端點防禦成本高
  • 靜態流量浪費

節點式網站服務模式

  • 各地的近端伺服器
  • 離線快取機制
  • 端點防禦成本較低
  • 靜態快取重用
    content deliver network

CDN Domain Resolve

使用者不會知道網站的真實 ip

一般直連

#像極了愛情

透過CDN快取 可以更快取得資料

2. threats and mitigations

Disclosure of Origin IPs

bypass cdn and waf
dos, attack directly to host

how to

域名的 a 紀錄

dig query name server

multi ping
異地 domain 的解析IP不同

網址/cdn-cgi/trace
是否使用CDN

cdn-cgi trace

製造parse error
%
%後面一般接上兩個十六進位的字元
單一一個%造成

request for comments(RFC)
IETF

RFC 規範了一個標準

不遵循 RFC 開發的例子,粽子沒有規定烹飪方式

中部粽(?
南部粽
(3D油飯?

子/域名探測
wordlist scanner

virustotal

x509v3
subject altermative name

  • crt.sh
    查詢憑證申請紀錄中有無目標 domain

  • associated domain
    buildwith

  • cloudflair
    查找所有很像的憑證網站

    Image Not Showing Possible Reasons
    • The image file may be corrupted
    • The server hosting the image is unavailable
    • The image path is incorrect
    • The image format is not supported
    Learn More →
    可能是真實域名

  • domain fronting
    透過修改 Host header 讓 cdn 將封包導向與連線 domain 不同的主機

  • 直接打 ip 訪問(不帶 host header
    infected pc
    tructed website attackers web server
    c c server

  • osint

  • whois 資料庫
    作者名稱、社交網頁等 GET一些可能有用內容

  • theharvester build by python

  • content search

    • shodan
    • yandex
      不會出現同個網域的結果藉以找到旁站
  • integration tools

    • sublist3r on github
    • dnsdumpster

功能探測

利用公開網站提供的預覽功能(該網站的IP連接)
其他思路
xss -> 打客服

上傳 webshell

crimeflare
濫用早期 cloudflare 的檢舉功能

撈 phpinfo.php or web config

cf-connnecting-ip

CDN Domain resolve

永遠是 CDN IP 要怎麼知道真實 IP

Cloudflare Header: CF-Connecting-IP

防禦措施

web cache deception and poisoning

cached and confused web cache deception in the wild
caching 101

cache key

靜態資源副本

cache control headers

  1. Vary
  2. Cache-Control
    • public 總之會快取
    • private 中間伺服器不快取
    • no-cache 僅在有變動時快取
    • no-store 完全不快取
      max-age 存留秒數(較被受用)
      expires 過期時間

cach extension

預設快取項目
html php aspx
js css

custom route

web cache deception attack in paypal settings page

  1. 不存在的 css 資源網址(malicious.css)被受害者打開
    • 但 'malicious.css' 被 paypal 當作參數解析,因此不會 404
  2. 得到頁面(被快取)
  3. 攻擊者打開同個路徑,得到快取的內容

web chache poisoning
web cache poisoning - DOM
first cache time

  1. unity3d.com
    X-Host 參數可以指定 js 來源

防禦措施
只快取指定資料夾

cache poisoned denial of service (CPDoS)

attack method
heep header oversize
usually maxmium 8192 bytes

http meta character
400 不該被快取
Get Post Delete

Http Method Override

rfc 7231
Method:
GET HEAD POST
Status Code:
200 203 204 206
300 301
404 405 410 414
501

404 也會被快取

CDN 平台

流量計價 連線計價

攻擊流量 > 預算
經濟式服務阻斷攻擊

CDN 流量放大

網站源地址相同 -> 容易被擋
CDN 來源三角映射
// 太多CDN節點會不提供服務
相同節點網站阻斷服務

防禦措施

  • 選擇具有威信 採良性存取行為計價的 CDN 服務
  • 異常頁面加入 Cache-Control: no-store
  • 遵循 RFC 開發,可快取狀態碼白名單
  • 簽訂 SLA

http desymc requests smuggling(協議走私attack)

這個攻擊

http response splitting
http desymc attacks
lasted release:
blackhat usa 2019 8
defcon 27 2019 8

HTTP 1.0+ keep alive & pipeline

multiple connections
persistent connection(持久連線)->非常省時間
no pipelining
pipelining

駭客可以謊報自己的封包長度,用以穿插別人的封包

不會檢查嗎?
攻擊圍繞在這兩個方式
Content-Length (整體傳輸、較舊)
Transfer-Encoding

RFC2616
一起傳會怎麼樣
會忽略比較舊的那一個

Transfer-Encoding
0
\r\n
End;

Front-end->Back-end

CLTE
TECL
傳兩個 Content-Length 會怎樣
RFC2616 沒有意料到有這個操作

http desymc smuggling and web cache poisoning paypal bugbounty $38,900 usd

http desymc smuggling slack bugbounty
paypal bugbounty $6,900 usd

防禦措施

選擇會正規劃 header 的 CDN 服務
前後端不使用TCP重用
使用HTTP/2
嚴格遵守 RFC

結論

歷史唯一給我們的教訓,就是我們無法從歷史中獲得任何教訓

要精準的評估資訊安全的風險不容易,必須持續關注最新議題才能意識最新的資安攻擊

thank you

Q&A

Select a repo