twisted / twisted/twisted

bug in prePathURL breaks proxies (8.2.0)

Open
#3,845 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug new priority-normal web
Dominant language
Python
Stars
6k
Forks
1.2k
Avg merge
2d 10h
Merged PRs (30d)
10

Description

jamesyonan's avatar jamesyonan reported
Trac ID trac#3845
Type defect
Created 2009-05-20 13:44:29Z

Work around a bug in twisted 8.2.0 prePathURL function
that breaks HTTP proxies by not properly respecting
port numbers in Host: foo.bar.com: style
headers. As a result of the incorrect behavior,
HTTP redirections fail if an HTTP proxy or IP-stack-level
port forward rule remaps the port number of the request
so that the port number in the Host header is different
from the port number of the receiving transport.

For example, suppose I have a port forward rule
on my server (foo.bar.com) to redirect port 8443
on my public interface to 127.0.0.1:5000 where a
twisted web server is listening. Now I connect with
a web browser to http://foo.bar.com:8443/ and get this
wrong redirect:

Location: https://foo.bar.com:5000/__session_key__3ba5281f1d7598ef02b0e314ef28f6e5/

Of course, the bug is that twisted should have used
port 8443 from the HTTP request instead of port 5000
from the transport to build the redirect. This bug
will break any port-remapping proxy or forward rule.

Attachments:

  • prepath.2.patch (2259 bytes) - added by jamesyonan on 2009-05-20 19:18:14Z - This patch fixes the issue.
Searchable metadata
trac-id__3845 3845
type__defect defect
reporter__jamesyonan jamesyonan
priority__normal normal
milestone__ 
branch__ 
branch_author__ 
status__new new
resolution__None None
component__web web
keywords__ 
time__1242827069000000 1242827069000000
changetime__1244769568000000 1244769568000000
version__None None
owner__jamesyonan jamesyonan
cc__exarkun

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.

Research direction

Start by locating the prePathURL entry point in Twisted's web HTTP handling and reproduce the port-remapping case described in the issue, where the Host header port differs from the receiving transport. Compare the generated redirect with the request's original port; done means the redirect preserves that requested port and the relevant HTTP tests pass.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend, networking
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.