Opened 10 years ago

Last modified 10 years ago

#3845 defect new

bug in prePathURL breaks proxies (8.2.0)

Reported by: jamesyonan Owned by: jamesyonan
Priority: normal Milestone:
Component: web Keywords:
Cc: Jean-Paul Calderone Branch:
Author:

Description

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:<port> 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 (1)

prepath.2.patch (2.2 KB) - added by jamesyonan 10 years ago.
This patch fixes the issue.

Download all attachments as: .zip

Change History (6)

comment:1 Changed 10 years ago by Jean-Paul Calderone

Reporter: changed from Jean-Paul Calderone to jamesyonan

This is a re-posting of a bug someone else tried to file, but was unable to due to inadequacies of trac.

Changed 10 years ago by jamesyonan

Attachment: prepath.2.patch added

This patch fixes the issue.

comment:2 Changed 10 years ago by jamesyonan

Re: This is a re-posting of a bug someone else tried to file, but was unable to due to inadequacies of trac.

That was probably me. I've been getting a lot of "Database Locked" error messages from trac on this site.

James

comment:3 Changed 10 years ago by Jean-Paul Calderone

Hi jamesyonan,

Thanks for the patch! Can you also include a unit test which demonstrates the misbehavior and that the patch you've attached so far fixes it? I'm not sure I really understand the scenario/behavior you're describing.

comment:4 Changed 10 years ago by Jean-Paul Calderone

Cc: Jean-Paul Calderone added
Owner: changed from jknight to jamesyonan

comment:5 Changed 10 years ago by Jean-Paul Calderone

#3857 was a duplicate of this.

Note: See TracTickets for help on using tickets.