Skip to content

feat: trust proxy client addresses safely - #48

Merged
HoungDev merged 1 commit into
mainfrom
agent/add-trusted-proxy-client-ip
Aug 11, 2026
Merged

feat: trust proxy client addresses safely#48
HoungDev merged 1 commit into
mainfrom
agent/add-trusted-proxy-client-ip

Conversation

@HoungDev

Copy link
Copy Markdown
Owner

Summary

  • make forwarded-header trust fail closed with an explicit IP/CIDR allowlist
  • canonicalize the ASGI client address shared by rate limiting and request logs
  • harden the documented Nginx boundary against client-supplied X-Forwarded-For
  • add spoofing, proxy-chain, malformed-address, configuration, and integration tests

Security model

Uvicorn remains the single owner of forwarded-header parsing. It accepts forwarded headers only when the direct socket peer matches FORWARDED_ALLOW_IPS; the application then consumes the canonical ASGI client address without parsing the headers a second time. Wildcard, malformed, non-canonical, and empty allowlist entries are rejected.

Validation

  • ruff format --check .
  • ruff check .
  • 46 focused tests passed locally
  • full PostgreSQL/Redis suite delegated to GitHub Actions because those services are unavailable locally

@HoungDev
HoungDev marked this pull request as ready for review August 11, 2026 14:17
@HoungDev
HoungDev merged commit a16fdd4 into main Aug 11, 2026
1 check passed
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