x-forwarded-for doesn't work

Open
#3,561 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
python
Domain
networking

Research direction

Start by tracing _apply_xheaders and how trusted_downstream reaches it, then inspect netutil.is_valid_ip for bracketed IPv6 addresses. Reproduce the reported X-Forwarded-For behavior and add focused coverage for the affected cases; done means forwarded client addresses are handled correctly without losing the trusted downstream configuration.

Written by the indexing model from the issue text.

Description

My logs show either the forwarder or 127.0.0.1.

This is version 6.5.2, with jupyterhub.

I put debug statements in _apply_xheaders

  1. trusted_downstream isn't being passed through to that point. i.e. it's empty or undefined.
  2. netutil.is_valid_ip rejects [2620:0:d60:ac1a::10]

There's always ambiguity in the specs whether IP addresses should have [] around them. Fortigate uses it: AWs documtation says they do https://docs.aws.amazon.com/elasticloadbalancing/latest/application/x-forwarded-headers.html. Wikipedia says some implementations use [] and some don't: https://en.wikipedia.org/wiki/X-Forwarded-For

Here's what I got from a Fortigate acting as a load balancer:

X-Forwarded-For: [2620:0:d60:ac1a::10]

Dominant language
Python
Stars
22.2k
Forks
5.6k
Avg merge
3h 42m
Merged PRs (30d)
16

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from tornadoweb/tornado

All issues in tornadoweb/tornado

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.