twarne / xebia-france

Automatically exported from code.google.com/p/xebia-france
0 stars 0 forks source link

Multiple X-Forwarded-For headers not handled #20

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Error is the same as https://issues.apache.org/bugzilla/show_bug.cgi?id=50453.

When a request comes in with multiple X-Forwarded-For headers the RemoteIP 
valve should be examining all of them in reverse order.

As defined by the standard:
"Multiple message-header fields with the same field-name MAY be present in a 
message if and only if the entire field-value for that header field is defined 
as a comma-separated list [i.e., #(values)]. It MUST be possible to combine the 
multiple header fields into one "field-name: field-value" pair, without 
changing the semantics of the message, by appending each subsequent field-value 
to the first, each separated by a comma. The order in which header fields with 
the same field-name are received is therefore significant to the interpretation 
of the combined field value, and thus a proxy MUST NOT change the order of 
these field values when a message is forwarded."

thus:
(a)
X-Forwarded-For: 192.168.0.3
X-Forwarded-For: 222.234.0.4

Is semantically equivalent to:
(b)
X-Forwarded-For: 192.168.0.3, 222.234.0.4

However (a) is not handled by the RemoteIP valve as it only ever looks at the 
first header.

For reference, this was raised on the HAproxy mailing list:
http://www.formilux.org/archives/haproxy/1012/4122.html
and tomcat user's mailing list:
http://mail-archives.apache.org/mod_mbox/tomcat-users/201012.mbox/%3C4D022C57.10
70005@apache.org%3E

Tomcat users suggested raising a bug. Hence this.

Original issue reported on code.google.com by pmolchan...@gmail.com on 20 Mar 2013 at 7:45