Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Problem: open-uri blocking redirection from http to https

Reply
Thread Tools

Problem: open-uri blocking redirection from http to https

 
 
Xavier Del Castillo
Guest
Posts: n/a
 
      02-18-2011
Hello,

I was working on a small script to verify the presence of an element
through a list of URL, some of these URLs have a redirections from http to
https, when the script crawled into them I got the following error:

/usr/lib/ruby/1.9.1/open-uri.rb:216:in `open_loop': redirection forbidden:
http://beta.carsdirect.com/auto-loans/finance-app ->
https://beta.carsdirect.com/auto-loans/finance-app (RuntimeError)

I understand that this is intentional, as per the comments on open-uri.rb

# This test is intended to forbid a redirection from http://... to
# file:///etc/passwd.
# https to http redirect is also forbidden intentionally.
# It avoids sending secure cookie or referer by non-secure HTTP
protocol.
# (RFC 2109 4.3.1, RFC 2965 3.3, RFC 2616 15.1.3)
# However this is ad hoc. It should be extensible/configurable.

This mentions that "https to http" redirects are forbidden intentionally,
but redirections from "http to https" are also blocked.

Is there a way to override this security check? currently I had to change the
following line in the library to allow "http to https" re-directions:

(/\A(?:http|ftp)\z/i =~ uri1.scheme && /\A(?:http|ftp)\z/i =~ uri2.scheme)

to

(/\A(?:http|ftp|https)\z/i =~ uri1.scheme && /\A(?:http|ftp|https)\z/i =~
uri2.scheme)

Thanks,
Xavi

 
Reply With Quote
 
 
 
 
Tanaka Akira
Guest
Posts: n/a
 
      02-28-2011
2011/2/18 Xavier Del Castillo <>:

> # However this is ad hoc. It should be extensible/configurable.
>
> This mentions that "https to http" redirects are forbidden intentionally,
> but redirections from "http to https" are also blocked.
>
> Is there a way to override this security check? currently I had to change
> the
> following line in the library to allow "http to https" re-directions:
>
> (/\A(?:http|ftp)\z/i =~ uri1.scheme && /\A(?:http|ftp)\z/i =~ uri2.scheme)


Currently it is not configurable (as the comment says) except monkey patching.

Maybe open-uri should have some hooks.
--
Tanaka Akira

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
server side redirect https => https NOT working Axel ASP General 8 04-27-2009 02:02 AM
https authentication & storing https page in string Naveen Dhanuka Ruby 1 09-19-2007 02:05 PM
open-uri and HTTPS, or net/https with a redirect jotto Ruby 4 10-02-2006 07:26 AM
poert redirection https to http Robert Cisco 11 03-16-2006 05:28 PM
Network blocking https traffic - Cisco 1721 problem? Paulo Cantanhede Cisco 1 09-08-2005 02:52 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57