From: Shugo Maeda Date: 2005-07-29T10:08:34+09:00 Subject: [ruby-dev:26641] Re: $SAFE=1 の open-uri で redirect 時にエラー 前田です。 Tanaka Akira wrote: >>perlsecをざっと眺めただけなのですが、Perlではライブラリがどのように >>振る舞うべきだとされているのかが、わかりませんでした。 >>今回の議論の流れから、Perlではライブラリはuntaintに類する処理 >>(Perlでは正規表現によって部分文字列を取り出すようですね)を >>行わないと仮定して考えてみました。 > > > その仮定は不適切だと思います。perlsec の > > Perl presumes that if you reference a substring using $1, > $2, etc., that you knew what you were doing when you wrote the pattern. > That means using a bit of thought--don't just blindly untaint anything, > or you defeat the entire mechanism. It's better to verify that the > variable has only good characters (for certain values of "good") rather > than checking whether it has any bad characters. That's because it's > far too easy to miss bad characters that you never thought of. > > というあたりの記述から考えると、untaint は行われることが想定されていま > す。正規表現マッチと抱き合わせになっているのは、untaint が必要な時には > なるべく正規表現で validation させるように仕向ける仕掛けなのでしょう。 Perlではuntaintに類する操作をしない、という話をしたつもりはありません。 あくまでも*ライブラリが*どういう条件でuntaintするべきかという指針を 見い出せなかったという話です。 ライブラリでuntaintするということは、`You may not use data derived from outside your program to affect something else outside your program'という原則に反するということですが、その判断はどういう 指針にもとづいて行われるのでしょうか。 > その手間には untaint すべきかどうかを判断する手間が含まれるわけですが、 > 判断するには安全性の定義が必要です。 ではPerlではどういう基準で判断されるのでしょう。 -- 前田 修吾