require "open-uri"
patches Kernel.open and calls different code for different arguments, which can lead to remote code execution or reading any file on the server!open(params[:url])
is code execution for url = |ls
Everything that begins with | considered as a system call.open(params[:url]) if params[:url] =~ /^http://
not better for url = |touch n;\nhttp://url.com
( broken regulars can lead to RCE, use \ A \ z ).open(URI(params[:url]))
reads any file on the server. url = / etc / passwd is a valid URL but open-uri calls the original Kernel.open as the argument does not begin with http: //open(params[:url]) if URI(params[:url]).scheme == 'http'
. It looks better already, but if you manage to create the http folder: the attacker can read any file using http:/../../../../../etc/passwd
(hi, CarrierWave!). Of course, it is unlikely that such a folder will be created, but it is a good demonstration of why parsing a URL is difficult and what a bad idea was to extend the system method open instead of creating a separate openURI (url).Source: https://habr.com/ru/post/251823/
All Articles