Skip to content

feat(edge): header sanitization, underscore smuggling defense, and upstream error interception - #10

Merged
ATLURI0001 merged 1 commit into
mainfrom
feat/header-sanitization-and-upstream-hardening
Nov 19, 2026
Merged

ATLURI0001 merged 1 commit into
mainfrom
feat/header-sanitization-and-upstream-hardening

Conversation

@ATLURI0001

Copy link
Copy Markdown
Owner

Edge Header Sanitization & Smuggling Defense Contracts

When reverse proxy gateways negotiate ingress traffic to internal container pools, ambiguous HTTP header specifications permit subtle request smuggling and header injection vectors:

  1. Header Name Smuggling via Underscores: Many backend application servers (WSGI/ASGI, Go, Node.js) automatically normalize underscores into dashes (e.g., X_FORWARDED_FOR becomes X-Forwarded-For or HTTP_X_FORWARDED_FOR), allowing malicious clients to spoof internal proxy headers.
  2. Upstream Server Fingerprinting: Default upstream proxying forwards backend runtime signatures (Server: Python/3.11 aiohttp/3.8.5 or X-Powered-By), leaking internal framework topologies to outside scanners.
  3. Downstream Host & Port Ambiguity: Multi-hop proxy clusters lose downstream client port and hostname context unless explicitly bound.
  4. Error Stack Trace Leakage: Upstream application crashes or unhandled 5xx exceptions can bypass edge gateways and expose stack traces directly to end users unless errors are intercepted.
Directive / Contract Target Layer Hardening Action Security Invariant
underscores_in_headers off; Ingress HTTP (nginx.conf) Disallows underscores in header keys Mitigates CGI/WSGI header collision & smuggling attacks
ignore_invalid_headers on; Ingress HTTP (nginx.conf) Drops malformed header tokens Enforces strict RFC 7230 header name syntax
proxy_hide_header Server; Upstream Proxy (proxy.conf) Strips upstream server disclosure Conceals backend engine versions from reconnaissance
proxy_hide_header X-Powered-By; Upstream Proxy (proxy.conf) Strips framework metadata Suppresses application identity fingerprinting
proxy_set_header X-Forwarded-Host; Upstream Proxy (proxy.conf) Forwards authenticated $host Prevents virtual host header confusion
proxy_set_header X-Forwarded-Port; Upstream Proxy (proxy.conf) Passes client $server_port Informs downstream of TLS edge termination context
proxy_intercept_errors on; Upstream Proxy (proxy.conf) Traps upstream 4xx/5xx responses Replaces raw debug traces with edge error templates

Verification Matrix

  • Test suite: python -m unittest tests/test_project.py
    • test_header_sanitization_and_smuggling_defense: Validates underscores_in_headers, ignore_invalid_headers, header stripping (Server, X-Powered-By), host/port forwarding, and error interception.
  • Full test suite: 19/19 tests passing in 0.009s.

@ATLURI0001
ATLURI0001 merged commit 33ce1a1 into main Nov 19, 2026
1 check failed
@ATLURI0001
ATLURI0001 deleted the feat/header-sanitization-and-upstream-hardening branch November 19, 2026 05:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant