Instalar com Codex ou Claude Copie este prompt, cole no Codex, Claude ou outro assistente e deixe que ele revise a página da skill e instale para você.
Um comando direto ignora o prompt de revisão. Verifique a origem antes de executá-lo.
Browser cache weakness testing examines whether sensitive authentication and user data can be retrieved from browser cache, history, or back button functionality. Improper cache control headers may allow sensitive pages to be cached, enabling attackers to access private information from shared or public computers.
# This requires browser testing, but we can check server behavior# 1. Login and access sensitive page
session=$(curl -s -c - "https://target.com/login" \
-X POST \
-d "username=test&password=test" | grep session | awk '{print $7}')
# 2. Access dashboard
curl -s "https://target.com/dashboard" \
-H "Cookie: session=$session" > dashboard_content.html
# 3. Logout
curl -s "https://target.com/logout" \
-H "Cookie: session=$session"# 4. Check if cached version returns with same session# (This simulates back button)
curl -s "https://target.com/dashboard" \
-H "Cookie: session=$session" \
-H "Cache-Control: max-age=0" \
-w "\nStatus: %{http_code}"# Should return 401/302 to login, not cached content
Step 3: Check Autocomplete Settings
# Check login form for autocomplete settings
curl -s "https://target.com/login" | \
grep -iE "autocomplete|password|username" | \
head -20
# Check for password fields without autocomplete="off"
curl -s "https://target.com/login" | \
grep -i "type=.password" | \
grep -v "autocomplete"# Check registration form
curl -s "https://target.com/register" | \
grep -iE "autocomplete|password"
Step 4: Test Page Caching Behavior
#!/bin/bash# Test if pages are being cached
TARGET="https://target.com"
TOKEN="your_token"# Make request and check for caching headersecho"Testing cache headers..."# Sensitive endpoints
endpoints=("/dashboard""/account""/api/me""/settings")
for endpoint in"${endpoints[@]}"; doecho"=== $endpoint ==="
response=$(curl -sI "$TARGET$endpoint" \
-H "Authorization: Bearer $TOKEN")
# Check Cache-Control
cache_control=$(echo"$response" | grep -i "cache-control")
if [ -z "$cache_control" ]; thenecho" [VULN] No Cache-Control header"elifecho"$cache_control" | grep -qi "no-store\|no-cache"; thenecho" [OK] Proper caching disabled: $cache_control"elseecho" [WARN] Cache-Control may allow caching: $cache_control"fi# Check Pragma
pragma=$(echo"$response" | grep -i "pragma")
if [ -z "$pragma" ]; thenecho" [INFO] No Pragma header (optional for HTTP/1.1)"fi# Check Expires
expires=$(echo"$response" | grep -i "expires")
ifecho"$expires" | grep -qi "0\|-1\|Thu, 01 Jan 1970"; thenecho" [OK] Expires set to past"fiecho""done
Step 5: Check ETag and Last-Modified
# Check for conditional request headers that might reveal info
curl -sI "https://target.com/dashboard" \
-H "Authorization: Bearer $TOKEN" | \
grep -iE "etag|last-modified"# If ETag contains user-specific info, it could be a privacy issue# Make same request with different user and compare ETags
Step 6: Test Credential Caching in Browser
<!-- This test is performed manually in browser --><!-- Check if browser offers to save password --><!-- 1. Open login page --><!-- 2. Enter credentials --><!-- 3. Check if browser prompts to save password --><!-- 4. Check if saved credentials appear in browser settings --><!-- Server should return: --><!-- - autocomplete="off" on login form --><!-- - autocomplete="new-password" on password reset forms --><!-- - Cache-Control: no-store -->
Step 7: Test HTTPS Page Caching
# Check if HTTPS responses include caching headers# Some browsers don't cache HTTPS by default, but explicit headers are safer
curl -sI "https://target.com/sensitive-page" \
-H "Authorization: Bearer $TOKEN" \
-o headers.txt
# Analyze headersif grep -qi "cache-control.*public\|cache-control.*max-age=[1-9]" headers.txt; thenecho"[VULN] Sensitive page may be cached"fiif ! grep -qi "cache-control" headers.txt; thenecho"[VULN] No Cache-Control header on sensitive page"fi
Tools
Header Analysis
Tool
Description
Usage
curl
HTTP client
Check headers
Browser DevTools
Network tab
Inspect cache behavior
Burp Suite
Proxy
Analyze responses
Cache Testing
Tool
Description
Browser cache viewer
Inspect cached content
Private/Incognito mode
Test clean cache behavior
Example Commands/Payloads
Cache Analysis Script
#!/usr/bin/env python3import requests
classCacheAnalyzer:
def__init__(self, base_url, token=None):
self.base_url = base_url
self.headers = {}
if token:
self.headers["Authorization"] = f"Bearer {token}"self.results = []
defanalyze_endpoint(self, endpoint):
"""Analyze caching headers for an endpoint"""try:
response = requests.get(
f"{self.base_url}{endpoint}",
headers=self.headers
)
result = {
"endpoint": endpoint,
"status": response.status_code,
"issues": []
}
headers = response.headers
# Check Cache-Control
cache_control = headers.get("Cache-Control", "")
ifnot cache_control:
result["issues"].append("Missing Cache-Control header")
else:
if"no-store"notin cache_control.lower():
result["issues"].append(f"Cache-Control may allow caching: {cache_control}")
if"private"notin cache_control.lower() and"no-store"notin cache_control.lower():
result["issues"].append("Cache-Control should include 'private' or 'no-store'")
# Check Pragma
pragma = headers.get("Pragma", "")
if"no-cache"notin pragma.lower() andnot cache_control:
result["issues"].append("Missing Pragma: no-cache (useful for HTTP/1.0)")
# Check Expires
expires = headers.get("Expires", "")
if expires and"0"notin expires and"1970"notin expires:
result["issues"].append(f"Expires header may allow caching: {expires}")
# Check for ETag with potentially sensitive data
etag = headers.get("ETag", "")
if etag andlen(etag) > 50:
result["issues"].append("Long ETag may contain sensitive information")
result["cache_control"] = cache_control
result["vulnerable"] = len(result["issues"]) > 0self.results.append(result)
return result
except Exception as e:
return {"endpoint": endpoint, "error": str(e)}
defanalyze_form(self, endpoint):
"""Analyze form for autocomplete settings"""try:
response = requests.get(
f"{self.base_url}{endpoint}",
headers=self.headers
)
issues = []
# Check for password fields without autocomplete="off"if'type="password"'in response.text or"type='password'"in response.text:
if'autocomplete="off"'notin response.text and'autocomplete="new-password"'notin response.text:
issues.append("Password field without autocomplete='off'")
# Check form-level autocompleteif'<form'in response.text:
if'autocomplete="off"'notin response.text:
issues.append("Form without autocomplete='off'")
return {
"endpoint": endpoint,
"form_issues": issues,
"vulnerable": len(issues) > 0
}
except Exception as e:
return {"endpoint": endpoint, "error": str(e)}
defgenerate_report(self):
"""Generate analysis report"""print("\n=== BROWSER CACHE SECURITY REPORT ===\n")
vulnerable = [r for r inself.results if r.get("vulnerable")]
print(f"Endpoints analyzed: {len(self.results)}")
print(f"Vulnerable endpoints: {len(vulnerable)}\n")
for result inself.results:
status = "[VULN]"if result.get("vulnerable") else"[OK]"print(f"{status}{result['endpoint']}")
if result.get("issues"):
for issue in result["issues"]:
print(f" - {issue}")
print(f" Cache-Control: {result.get('cache_control', 'Not set')}")
print()
# Usage
analyzer = CacheAnalyzer("https://target.com", "your_token")
analyzer.analyze_endpoint("/dashboard")
analyzer.analyze_endpoint("/account")
analyzer.analyze_endpoint("/api/user")
analyzer.analyze_form("/login")
analyzer.generate_report()
Remediation Guide
1. Set Proper Cache-Control Headers
from flask import Flask, make_response
@app.after_requestdefadd_cache_headers(response):
"""Add security headers to prevent caching of sensitive pages"""# For all authenticated pagesif is_authenticated_request():
response.headers['Cache-Control'] = 'no-store, no-cache, must-revalidate, max-age=0'
response.headers['Pragma'] = 'no-cache'
response.headers['Expires'] = '0'return response
# Or for specific routes@app.route('/dashboard')@login_requireddefdashboard():
response = make_response(render_template('dashboard.html'))
response.headers['Cache-Control'] = 'no-store, no-cache, must-revalidate, max-age=0'
response.headers['Pragma'] = 'no-cache'
response.headers['Expires'] = '0'return response