Project

General

Profile

Feature #859

open-uri doesn't allow redirection to https

Added by Roman Shterenzon almost 8 years ago. Updated 18 days ago.

Status:
Closed
Priority:
Normal
Assignee:
[ruby-core:20485]

Description

=begin
Only ftp and http are checked in regex in OpenURI.redirectable? method.
Please see the attached patch.
=end

open-uri.rb.patch View (547 Bytes) Roman Shterenzon, 12/12/2008 03:16 AM


Subtasks

Feature #3719: open-uri should allow redirects from http to httpsAssignedAkira Tanaka
Bug #5950: open-uri: https redirect fix AssignedAkira Tanaka

Associated revisions

Revision 56085
Added by Akira Tanaka 18 days ago

lib/open-uri.rb: Allow http to https redirection.

  • lib/open-uri.rb: Allow http to https redirection. Note that https to http is still forbidden. [Feature #859] by Roman Shterenzon.

History

#1 Updated by Shyouhei Urabe over 7 years ago

  • Assignee set to Akira Tanaka

=begin

=end

#2 Updated by Akira Tanaka over 7 years ago

  • ruby -v set to -

=begin

=end

#3 Updated by Roman Shterenzon over 7 years ago

=begin
Originally reported on:
ruby 1.8.7 (2008-08-11 patchlevel 72) [i686-linux]
=end

#4 Updated by Roman Shterenzon over 7 years ago

=begin
I quote from :

But first of all the HTTP --> HTTPS redirection should be still considered ok.

Regarding the other way, well, the Referer should be set to the URL that redirected us. I believe this is not currently implemented. As for cookies, AFAIK there's no direct support for cookies in Net::HTTP nor open-uri, so if the programmer wants to use cookies, she has to set it manually via a "Cookie" header. And since no support for cookies as per RFC2109 is in place, no security measures are implemented. So for example one URL can redirect to other (also HTTP) URL, which is in another domain, and the cookie (actually header) will be sent anyway. So the fact that the "secure" attribute of cookie is unsupported diminishes in light of this. Therefor I think that redirecting from HTTPS to HTTP should be considered ok too.
=end

#5 Updated by Nobuyoshi Nakada about 7 years ago

=begin
Hi,

At Tue, 3 Feb 2009 17:53:36 +0900,
Roman Shterenzon wrote in :

I quote from :

But first of all the HTTP --> HTTPS redirection should be still considered ok.

Then your previous patch is wrong.

Index: lib/open-uri.rb
===================================================================
--- lib/open-uri.rb (revision 24735)
+++ lib/open-uri.rb (working copy)
@@ -241,5 +241,5 @@ module OpenURI
# However this is ad hoc. It should be extensible/configurable.
uri1.scheme.downcase == uri2.scheme.downcase ||
- (/\A(?:http|ftp)\z/i =~ uri1.scheme && /\A(?:http|ftp)\z/i =~ uri2.scheme)
+ (/\A(?:http|ftp)\z/i =~ uri1.scheme && /\A(?:https?|ftp)\z/i =~ uri2.scheme)
end

--
Nobu Nakada

=end

#6 Updated by Shyouhei Urabe about 7 years ago

  • Status changed from Open to Closed

=begin

=end

#7 [ruby-core:36302] Updated by Xavier Shay over 5 years ago

Why was this closed? This bug is still present in trunk. A patch was reverted in r21381, but it was not the patch that Nobuyoshi has proposed, and there was no indication as to why it was reverted (my guess is because it allowed https -> http redirection).

#8 [ruby-core:36303] Updated by Yui NARUSE over 5 years ago

  • Priority changed from 3 to Normal
  • Status changed from Closed to Assigned

#9 [ruby-core:37444] Updated by Hiroshi Nakamura about 5 years ago

  • Target version set to 1.9.3

Tanaka-san, please handle this.

#10 [ruby-core:38584] Updated by Hiroshi Nakamura about 5 years ago

Akr, I think we agreed that http -> https redirection is OK. If you don't like ad-hoc change for 1.9.3, I can do that uglish thing instead of you. :) Do you mind if I'd do that?

#11 [ruby-core:38652] Updated by Akira Tanaka about 5 years ago

  • Target version changed from 1.9.3 to 2.0.0

I'd like generic solution. Especially because open-uri doesn't provide a way to specify headers for each request for redirection.

#13 Updated by Yusuke Endoh almost 4 years ago

  • Tracker changed from Bug to Feature

#14 [ruby-core:50711] Updated by Yusuke Endoh almost 4 years ago

  • Target version changed from 2.0.0 to next minor

#16 [ruby-core:77086] Updated by Carsten Bormann 28 days ago

A typical example of the consequences of this 7-year old bug is https://github.com/cabo/kramdown-rfc2629/issues/27

Please wake up and fix this. Now.

#17 Updated by Akira Tanaka 18 days ago

  • Status changed from Assigned to Closed

Applied in changeset r56085.


lib/open-uri.rb: Allow http to https redirection.

  • lib/open-uri.rb: Allow http to https redirection. Note that https to http is still forbidden. [Feature #859] by Roman Shterenzon.

Also available in: Atom PDF