~からfind
マニュアルページ:
-exec command ; There are unavoidable security problems surrounding use of the -exec action; you should use the -execdir option instead. -execdir command {} + Like -exec, but the specified command is run from the subdirectory containing the matched file, which is not normally the directory in which you started find. This a much more secure method for invoking commands, as it avoids race conditions during resolution of the paths to the matched files.
どういう意味ですか?スタートアップディレクトリで実行すると競合状態が発生するのはなぜですか?これらのセキュリティリスクはどうですか?
ベストアンサー1
詳細が見つかりました。ここ:
これ
-exec
により他のプログラムが実行されます。検討中のファイル名をプログラムに渡します。その後、呼び出されたプログラムは通常、ファイルに対していくつかの操作を実行します。ここでも悪用される可能性がある競争条件があります。コマンドを例に挙げましょう。find /tmp -path /tmp/umsp/passwd -exec /bin/rm
この簡単な例では、削除するファイルを識別し、
/bin/rm
削除を呼び出します。 findがジョブを処理する必要があると判断した時点と、コマンドが実際にファイルシステムからファイルを削除するためにunlink()システムコールを実行する-exec
時点との間に時間遅延があるため、問題が発生します。/bin/rm
この間、攻撃者はディレクトリ/tmp/umsp
名を/etc
。/bin/rm
シンボリックリンクが確立されると、攻撃者はfindが/etc/passwd
実際に呼び出されたコマンドの意図した効果ではなくファイルの削除を引き起こすように説得する可能性があります。
誰かがこれを悪用する可能性がどれくらいになるのかわかりませんが、答えはそこにあるようです。