[#25936] [Bug:1.9] [rubygems] $LOAD_PATH includes bin directory — Nobuyoshi Nakada <nobu@...>

Hi,

10 messages 2009/10/05

[#25943] Disabling tainting — Tony Arcieri <tony@...>

Would it make sense to have a flag passed to the interpreter on startup that

16 messages 2009/10/05

[#26028] [Bug #2189] Math.atanh(1) & Math.atanh(-1) should not raise an error — Marc-Andre Lafortune <redmine@...>

Bug #2189: Math.atanh(1) & Math.atanh(-1) should not raise an error

14 messages 2009/10/10

[#26222] [Bug #2250] IO::for_fd() objects' finalization dangerously closes underlying fds — Mike Pomraning <redmine@...>

Bug #2250: IO::for_fd() objects' finalization dangerously closes underlying fds

11 messages 2009/10/22

[#26244] [Bug #2258] Kernel#require inside rb_require() inside rb_protect() inside SysV context fails — Suraj Kurapati <redmine@...>

Bug #2258: Kernel#require inside rb_require() inside rb_protect() inside SysV context fails

24 messages 2009/10/22

[#26361] [Feature #2294] [PATCH] ruby_bind_stack() to embed Ruby in coroutine — Suraj Kurapati <redmine@...>

Feature #2294: [PATCH] ruby_bind_stack() to embed Ruby in coroutine

42 messages 2009/10/27

[#26371] [Bug #2295] segmentation faults — tomer doron <redmine@...>

Bug #2295: segmentation faults

16 messages 2009/10/27

[ruby-core:26223] [Bug #2251] URI.parse accepts strings with invalid characters

From: Sam Quigley <redmine@...>
Date: 2009-10-22 03:49:49 UTC
List: ruby-core #26223
Bug #2251: URI.parse accepts strings with invalid characters
http://redmine.ruby-lang.org/issues/show/2251

Author: Sam Quigley
Status: Open, Priority: Normal
Category: lib
ruby -v: ruby 1.9.1p243 (2009-07-16 revision 24175) [i386-darwin10.0.0] 

The regexes used in URI::Parser's initialize_regexp use ^ and $ rather than \A and \Z:

   399       # for URI::split
   400       ret[:ABS_URI] = Regexp.new('^' + pattern[:X_ABS_URI] + '$', Regexp::EXTENDED)
   401       ret[:REL_URI] = Regexp.new('^' + pattern[:X_REL_URI] + '$', Regexp::EXTENDED)

The result is that URI.parse matches on any URI separated by newlines, rather than on its argument as a whole:

   irb(main):001:0> require 'uri'
   => true
   irb(main):002:0> URI.parse("blah\nhttp://www.foo.com/\nblahblah")
   => #<URI::HTTP:0x000001010aac78 URL:http://www.foo.com/>

I think programmers would expect URI.parse to only successfully parse strings that *are* URIs, rather than any string that *contains* a URI surrounded by a particular kind of whitespace.  This issue has apparently caused at least one security vulnerability in the real world: http://schmoil.blogspot.com/2009/10/mainlining-new-lines-feel-burn.html

Replacing the ^ and $ with \A and \Z should fix the issue, and is unlikely to break any existing code.  The Rubyspec project does not seem to have any tests for this behavior.  This behavior is present in at least versions 1.8.6, 1.8.7, and 1.9.1.

-sq


----------------------------------------
http://redmine.ruby-lang.org

In This Thread

Prev Next