Header sanitization removes sensitive response-header values before findings are persisted. It preserves header names and non-sensitive metadata, retaining evidence of what a server returned without placing reusable secrets in logs or report artifacts. section 4.3.3
Sanitize at the boundary between live collection and durable storage:
- Inspect each header key case-insensitively. section 4.3.3
- Replace values for Set-Cookie-prefixed headers, Authorization, and X-API-Key with [redacted]. section 4.3.3
- Keep all other values and every original header name for operational context. section 4.3.3
Listing 4.9 Header sanitization
def sanitize_headers(headers: Dict[str, str]) -> Dict[str, str]:
"""Remove obviously sensitive header values before persisting."""
redacted = {}
for k, v in headers.items():
lk = k.lower()
if lk.startswith("set-cookie") or lk in {"authorization", "x-api-key"}:
redacted[k] = "[redacted]"
else:
redacted[k] = v
return redacted
A small dictionary transformation applies explicit key-based redaction before output is saved. section 4.3.3
Treat raw headers as useful live-scan observations but unsafe durable artifacts: cookies, authorization tokens, and API keys can become liabilities once written to disk. section 4.3.3
