FastCGI: 30 Years Old and Still the Better Protocol for Reverse Proxies

· security web · Source ↗

TLDR

  • FastCGI, a 30-year-old wire protocol, avoids HTTP reverse-proxy security pitfalls like desync attacks and header injection by design.

Key Takeaways

  • HTTP/1.1 desync (request smuggling) is a structural flaw: no explicit message framing means proxy and backend can disagree on boundaries, enabling attacks like the recent Discord media-proxy vulnerability.
  • FastCGI prefixes all client headers with HTTP_, making it structurally impossible for attackers to inject a header mistaken for trusted proxy data like REMOTE_ADDR or X-Real-IP.
  • Migration is minimal in Go: swap http.Serve for fcgi.Serve using net/http/fcgi; nginx, Caddy, Apache, and HAProxy all support FastCGI backends with one-line config changes.
  • HTTP/2 fixes desync but not header trust separation, and nginx only gained HTTP/2 backend support in late 2025; Apache’s is still experimental.
  • FastCGI has no WebSocket support and benchmarks show some throughput regression, attributed to less-optimized code paths rather than protocol overhead.

Hacker News Comment Review

  • No substantive HN discussion yet.

Original | Discuss on HN