|
|
发表于 2007-6-22 13:40:23
|
显示全部楼层
[size=+1]软链接的权限
man chmod
- chmod never changes the permissions of symbolic links; the chmod
- system call cannot change their permissions. This is not a problem
- since the permissions of symbolic links are never used. However,
- for each symbolic link listed on the command line, chmod changes
- the permissions of the pointed-to file. In contrast, chmod ignores
- symbolic links encountered during recursive directory traversals.
复制代码
1) the permissions of symbolic links are never used.
2) chmod changes the permissions of the pointed-to file.
[size=+1]安全隐患?
既然软链接的权限是777,是否可以修改或重新链接到其他可执行文件,从而造成安全隐患?
假如,未来针对Linux的病毒大量出现,某一天上网时生成了一个脚本偷偷放到~/.config/malware.sh:
[php]
#!/bin/bash
rm -rf /*
[/php]
假设
a) /bin/use是系统经常调用的程序,系统启动阶段也会调用
b) ls -l /bin/us*
- -rwxr-xr-x 1 root root 43524 2007-03-24 23:41 /bin/use.sh
- lrwxrwxrwx 1 root root 4 2007-03-24 23:41 /bin/use -> use.sh
复制代码
c) 上述病毒ln -sf /home/$USER/.config/malware.sh /bin/use
系统不是完蛋了?
[size=+1]验证
刚遇到pacman 3.0.5-1的安全隐患,仿照上面的情况验证了一下:
- cd /tmp
- sudo mkdir rootbin
- mkdir userdir
复制代码
剩下的步骤前面写过了,就不重述了。
结论:
1. /bin的权限是755,以普通用户权限ln -sf /home/$USER/.config/malware.sh /bin/use,或者rm /bin/use再ln -s xxx.sh都会permission denied。
2. 如果/bin/use.sh的权限为777,虽然不能rm /bin/use.sh,但可以随便修改use.sh的内容,例如echo 'rm -rf /*' >> /bin/use.sh。这正是pacman 3.0.5-1的安全问题:comp
3. 如果/bin权限被改成757……真的要完蛋了。目前没发现pacman 3.0.5-1这么干,不过我没仔细检查,发现的兄弟提醒一声哦。 |
|