Dan*_*eny 14 shell security find
从find
手册页:
Run Code Online (Sandbox Code Playgroud)-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.
这是什么意思?为什么从起始目录运行它会出现竞争条件?这些安全风险如何?
Dan*_*eny 13
在这里找到详细信息:
该
-exec
操作导致另一个程序运行。它将当时正在考虑的文件的名称传递给程序。被调用的程序通常会对该文件执行一些操作。再一次,这里存在可以利用的竞争条件。我们将作为一个具体的例子命令Run Code Online (Sandbox Code Playgroud)find /tmp -path /tmp/umsp/passwd -exec /bin/rm
在这个简单的例子中,我们只识别一个要删除的文件并调用
/bin/rm
它来删除它。存在问题是因为在 find 决定它需要处理-exec
操作的点与/bin/rm
命令实际发出 unlink() 系统调用以从文件系统中删除文件的点之间存在时间间隔 。在这段时间内,攻击者可以重命名/tmp/umsp
目录,将其替换为指向/etc
. 无法/bin/rm
确定它正在处理 find 所考虑的同一个文件。一旦符号链接到位,攻击者就说服了 find 导致删除/etc/passwd
文件,这不是实际调用的命令预期的效果。
不确定有人有多大可能利用它;但我想这就是答案!