[#26156] ruby 1.8.3 preview1 — Yukihiro Matsumoto <matz@...>

Hi,

28 messages 2005/05/12

[#26186] ruby_setenv dumps core with mod_ruby/1.4.2 — Tietew <tietew-ml-ruby-dev@...>

Tietew です。

15 messages 2005/05/18
[#26285] Re: ruby_setenv dumps core with mod_ruby/1.4.2 — "H.Yamamoto" <ocean@...2.ccsnet.ne.jp> 2005/06/05

山本です。

[#26325] Re: ruby_setenv dumps core with mod_ruby/1.4.2 — Tietew <tietew-ml-ruby-dev@...> 2005/06/10

Tietew です。

[#26187] IO.select dumps core — Tanaka Akira <akr@...17n.org>

[ruby-talk:142505] で可能性に気がついたのですが、いま実験してみたとこ

31 messages 2005/05/18
[#26255] Re: IO.select dumps core — nobu@... 2005/05/31

なかだです。

[#26256] Re: IO.select dumps core — Tanaka Akira <akr@...17n.org> 2005/06/01

In article <200505311523.j4VFN4Y4005876@sharui.nakada.niregi.kanuma.tochigi.jp>,

[#26257] Re: IO.select dumps core — nobu@... 2005/06/01

なかだです。

[#26262] Re: IO.select dumps core — Tanaka Akira <akr@...17n.org> 2005/06/01

In article <200506010140.j511edY4012889@sharui.nakada.niregi.kanuma.tochigi.jp>,

[#26265] Re: IO.select dumps core — Takahiro Kambe <taca@...> 2005/06/02

In message <87u0khj377.fsf@m17n.org>

[#26365] Re: IO.select dumps core — とみたまさひろ <tommy@...> 2005/06/22

とみたです。

[#26366] Re: IO.select dumps core — nobu@... 2005/06/22

なかだです。

[#26369] Re: IO.select dumps core — とみたまさひろ <tommy@...> 2005/06/23

とみたです。

[#26242] many errors with soap/wsdl test on mswin32 — "U.Nakamura" <usa@...>

こんにちは、なかむら(う)です。

12 messages 2005/05/27
[#26249] Re: many errors with soap/wsdl test on mswin32 — "H.Yamamoto" <ocean@...2.ccsnet.ne.jp> 2005/05/31

山本です。

[ruby-dev:26237] Re: FileUtils.rm_rf security problem

From: Minero Aoki <aamine@...>
Date: 2005-05-26 11:33:23 UTC
List: ruby-dev #26237
青木です。

  In mail "[ruby-dev:26234] Re: FileUtils.rm_rf security problem"
  Tanaka Akira <akr@m17n.org> wrote:

>   def remove_entry_secure(path, force = false)
>     fu_try_unlink path and return   # Remove non-directory files.
>     if fu_have_symlink?
>       File.lchown Process.euid, nil, path
>     else
>       File.chown Process.euid, nil, path
>     end
> 
> unlink した後、lchown する前に sudo とかへの hard link にすりかえられ
> るとまずいんじゃないでしょうか。

lchown が suid ビットをクリアすることを仮定しています。

  /tmp % ls -ld sudo
  ---s--x--x    1 aamine   users       80608 May 26 18:08 sudo
  /tmp % sudo ruby -e 'File.lchown 0,nil,"sudo"'
  /tmp % ll sudo
  ---x--x--x    1 root     users       80608 May 26 18:08 sudo

が、いま調べてみるとあまりポータブルでないことがわかったので、
「そういうプラットフォームでは root で消すの禁止」ということにします。

  #
  # This method removes a file system entry +path+.  +path+ shall be a 
  # regular file, a directory, or something.  If +path+ is a directory, 
  # remove it recursively.  This method is required to avoid TOCTTOU 
  # (time-of-check-to-time-of-use) local security vulnerability of #rm_r.
  # #rm_r causes security hole when and only when:
  #
  #   * Parent directory is world writable (including /tmp).
  #   * Removing directory tree includes world writable directory.
  # 
  # To avoid this security hole, this method applies special preprocess.
  * If +path+ is a directory, this method chown(2) and chmod(2) all
  # removing directories.  This requires the current process is the
  # owner of the removing whole directory tree.
  # 
  # When parent directory is /tmp (permission 1777), UNIX super user
  # (root) can remove directory tree safely only on systems which 
  # lchown(2) clears S_ISUID (set-user-id) bit, such as Linux.
  # Many systems do NOT clear S_ISUID bit, this method is insecure for 
  # cleaning /tmp.  Note that, if parent directory is not world writable, 
  # this method is secure for also super user.
  #
  # WARNING: You must ensure that *ALL* parent directories are not
  # world writable.  Otherwise this method does not work.
  # Only exception is /tmp, permission 1777.
  # 
  # WARNING: Only the owner of the removing directory tree, or
  # super user (root) should invoke this method.  Otherwise this
  # method does not work.
  # 
  # WARNING: This method does not work if system have symbolic link
  # but do not have lchown(2).  This method raises NotImplementedError
  # on such system. 
  # 
  # WARNING: Currently, this method does NOT work Win32 systems.
  # 
  # For details of this security vulnerability, see Perl's case:
  # 
  #   http://www.cve.mitre.org/cgi-bin/cvename.cgi?name=CAN-2005-0448
  #   http://www.cve.mitre.org/cgi-bin/cvename.cgi?name=CAN-2004-0452
  #   
  # For fileutils.rb, this vulnerability is reported in [ruby-dev:26100].
  # 
  def remove_entry_secure(path, force = false)

ちなみに Solaris とか AIX だと root の場合はディレクトリが空で
なくても unlink で消せるみたいなので、lchown まで到達しなそうです。
これはこれでまずいので修正します。


> あと、(私も最近失敗したんでなんですが) EISDIR は Linux 固有です。

こっちも修正しました。

--
青木峰郎

In This Thread