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.
Cookie attributes control how browsers handle cookies, including security restrictions. Improperly configured cookie attributes can expose session tokens to theft via XSS attacks, man-in-the-middle attacks, or cross-site request forgery. This test examines whether cookies are configured with appropriate security attributes including Secure, HttpOnly, SameSite, Domain, Path, and Expires/Max-Age.
What to Check
Cookie Security Attributes
Secure flag (HTTPS only)
HttpOnly flag (no JavaScript access)
SameSite attribute (CSRF protection)
Domain scope
Path scope
Expires/Max-Age settings
Cookie prefix (**Host-, **Secure-)
Attribute Impact
Attribute
Missing Impact
Secure
Token sent over HTTP
HttpOnly
XSS can steal token
SameSite
CSRF attacks possible
Proper Domain
Subdomain attacks
Proper Path
Broader exposure
How to Test
Step 1: Capture All Cookies
#!/bin/bash# Capture and analyze all cookies
TARGET="https://target.com"# Get all Set-Cookie headersecho"=== All Set-Cookie Headers ==="
curl -sI "$TARGET" | grep -i "set-cookie"# After authenticationecho -e "\n=== Post-Auth Cookies ==="
curl -s -c - -X POST "/login" \
-d | grep -v
curl -sI | grep -i | -r line;
| | -r attr;
#!/bin/bash# Test cookie prefixes (__Host-, __Secure-)
TARGET="https://target.com"# __Host- prefix requirements:# - Must have Secure flag# - Must not have Domain attribute# - Path must be /# - Must be set from secure origin# __Secure- prefix requirements:# - Must have Secure flag# - Must be set from secure originecho"=== Testing Cookie Prefixes ==="# Check for __Host- cookies
curl -sI "$TARGET" | grep -i "set-cookie.*__Host-" && \
echo"[OK] Using __Host- prefix" || \
echo"[INFO] Not using __Host- prefix"# Check for __Secure- cookies
curl -sI "$TARGET" | grep -i "set-cookie.*__Secure-" && \
echo"[OK] Using __Secure- prefix" || \
echo"[INFO] Not using __Secure- prefix"
Step 4: Test HTTP Downgrade
#!/bin/bash# Test if cookies are sent over HTTP# This test requires both HTTP and HTTPS access
HTTP_TARGET="http://target.com"
HTTPS_TARGET="https://target.com"# Get session from HTTPS
session=$(curl -s -c - "$HTTPS_TARGET/login" -d "user=test&pass=test" | \
grep -oP "SESSIONID=\K[^;]+")
# Try to use session over HTTP
response=$(curl -s -b "SESSIONID=$session""$HTTP_TARGET/protected")
ifecho"$response" | grep -qi "authenticated\|welcome"; thenecho"[VULN] Session cookie accepted over HTTP"elseecho"[OK] Session cookie not sent/accepted over HTTP"fi
Step 5: Test XSS Cookie Theft
// Browser console test - check if session cookies are accessible// If accessible, XSS can steal themconsole.log("=== Cookies accessible via JavaScript ===")
console.log(document.cookie)
// Check for specific session cookiesconst cookies = document.cookie.split(";")
cookies.forEach((cookie) => {
const [name, value] = cookie.trim().split("=")
if (
name.toLowerCase().includes("session") ||
name.toLowerCase().includes("token") ||
name.toLowerCase().includes("auth")
) {
console.log(`[VULN] Sensitive cookie accessible: ${name}`)
}
})
// If session cookies appear, HttpOnly is missing
Step 6: Comprehensive Cookie Analyzer
#!/usr/bin/env python3import requests
from http.cookies import SimpleCookie
classCookieAnalyzer:
def__init__(self, url):
self.url = url
self.session = requests.Session()
self.findings = []
defanalyze(self):
"""Analyze all cookie attributes"""print(f"[*] Analyzing cookies from {self.url}")
response = self.session.get(self.url)
for cookie inself.session.cookies:
print(f"\n{'='*50}")
print(f"Cookie: {cookie.name}")
print(f"{'='*50}")
self._analyze_cookie(cookie, response)
returnself.findings
def_analyze_cookie(self, cookie, response):
"""Analyze individual cookie"""# Check Secure flagif cookie.secure:
print(f" [OK] Secure: True")
else:
print(f" [VULN] Secure: False")
self.findings.append({
"cookie": cookie.name,
"issue": "Missing Secure flag",
"severity": "High",
"recommendation": "Add Secure flag to cookie"
})
# Check HttpOnly (need to check raw header)
set_cookie_headers = response.headers.get('Set-Cookie', '')
if cookie.name in set_cookie_headers:
if'httponly'in set_cookie_headers.lower():
print(f" [OK] HttpOnly: True")
else:
print(f" [VULN] HttpOnly: False")
self.findings.append({
"cookie": cookie.name,
"issue": "Missing HttpOnly flag",
"severity": "High",
"recommendation": "Add HttpOnly flag to prevent XSS theft"
})
# Check SameSiteif'samesite=strict'in set_cookie_headers.lower():
print(f" [OK] SameSite: Strict")
elif'samesite=lax'in set_cookie_headers.lower():
print(f" [WARN] SameSite: Lax")
elif'samesite=none'in set_cookie_headers.lower():
print(f" [WARN] SameSite: None (cross-site allowed)")
ifnot cookie.secure:
self.findings.append({
"cookie": cookie.name,
"issue": "SameSite=None without Secure flag",
"severity": "High",
"recommendation": "SameSite=None requires Secure flag"
})
else:
print(f" [WARN] SameSite: Not set")
self.findings.append({
"cookie": cookie.name,
"issue": "Missing SameSite attribute",
"severity": "Medium",
"recommendation": "Add SameSite=Strict or Lax"
})
# Check Domainprint(f" Domain: {cookie.domain or'(not set - origin only)'}")
if cookie.domain and cookie.domain.startswith('.'):
self.findings.append({
"cookie": cookie.name,
"issue": f"Domain with leading dot ({cookie.domain})",
"severity": "Low",
"recommendation": "Review if subdomain access is needed"
})
# Check Pathprint(f" Path: {cookie.path}")
if cookie.path == '/':
print(f" [INFO] Cookie available to entire site")
# Check Expirationif cookie.expires:
import datetime
exp_date = datetime.datetime.fromtimestamp(cookie.expires)
print(f" Expires: {exp_date}")
# Check for very long expiration
days_until_expire = (exp_date - datetime.datetime.now()).days
if days_until_expire > 365:
self.findings.append({
"cookie": cookie.name,
"issue": f"Long expiration ({days_until_expire} days)",
"severity": "Low",
"recommendation": "Consider shorter cookie lifetime"
})
else:
print(f" Expires: Session (browser close)")
# Check value characteristicsprint(f" Value length: {len(cookie.value)}")
iflen(cookie.value) < 16:
print(f" [WARN] Short cookie value")
defgenerate_report(self):
"""Generate findings report"""print("\n" + "="*60)
print("COOKIE SECURITY REPORT")
print("="*60)
ifnotself.findings:
print("\nNo security issues found!")
returnprint(f"\nTotal findings: {len(self.findings)}")
# Group by severityfor severity in ['High', 'Medium', 'Low']:
issues = [f for f inself.findings if f['severity'] == severity]
if issues:
print(f"\n{severity.upper()} ({len(issues)}):")
for issue in issues:
print(f" [{issue['cookie']}] {issue['issue']}")
print(f" → {issue['recommendation']}")
# Usage
analyzer = CookieAnalyzer("https://target.com")
analyzer.analyze()
analyzer.generate_report()