ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:111040] [Ruby master Bug#19157] URI bad component validation can be tricked
@ 2022-11-28 23:46 straight-shoota
  0 siblings, 0 replies; only message in thread
From: straight-shoota @ 2022-11-28 23:46 UTC (permalink / raw)
  To: ruby-core

Issue #19157 has been reported by straight-shoota (Johannes Müller).



----------------------------------------

Bug #19157: URI bad component validation can be tricked

https://bugs.ruby-lang.org/issues/19157



* Author: straight-shoota (Johannes Müller)

* Status: Open

* Priority: Normal

* ruby -v: 3.1.3

* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN

----------------------------------------

`URI::HTTP` checks the validity of the URI components. For example, the path of a URI with authority component must be either empty or start with a slash.



This validation applies on the `.build` constructor as well as on the `path` setter.

But it can be tricked when setting an empty authority component and scheme before setting a relative path, and then setting the authority and scheme again.

This produces an invalid and incorrect URI.



``` ruby

require "uri"



uri = URI::HTTP.build({})

uri.scheme = nil

uri.path = "resource"

uri.host = "example.com" # this should raise URI::InvalidComponentError

uri.scheme = "http"

uri.to_s # => "http://example.comresource"

```









-- 

https://bugs.ruby-lang.org/

 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-11-28 23:46 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-28 23:46 [ruby-core:111040] [Ruby master Bug#19157] URI bad component validation can be tricked straight-shoota

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).