关于 SELinux 的 least-privilege 的影响范围

2016-05-12 09:17:26 +08:00
 Explorare

最近踩了 SELinux 这个坑,sshd 在更换了自定义端口后启动失败,最后用 semanage 添加了端口才解决。然而我发现托管在 supervisor 下的 ssserver 使用了一个没有定义在 SELinux 中的端口,然后 ssserver 的进程属性如下

unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 9681 ? S 0:05 /usr/bin/python /bin/ssserver -c /etc/ssserver.json

三个属性都是 unconfined 状态,按理来说应该没有权限绑定端口才对啊。 SELinux 的状态为 enforcing

2326 次点击
所在节点    CentOS
15 条回复
jhaohai
2016-05-12 09:24:05 +08:00
为啥不禁用了
Explorare
2016-05-12 09:28:38 +08:00
@jhaohai 因为我认同 SELinux 的理念,做好权限管理很重要,最大的问题在人,懒得翻 manpage 直接关掉 FirewallD 和 SELinux 就骗自己解决问题,迟早药丸。
whatot
2016-05-12 09:30:08 +08:00
全是 unconfined 就不关 selinux 的事情了
jhaohai
2016-05-12 09:32:23 +08:00
@Explorare 生产的服务器都看不到几个开 selinux 的,很多软件在安装手册上都建议关闭 selinux 。而且现在都是集中控制访问了,没人会在 host 上折腾 selinux 和 firewall
Explorare
2016-05-12 09:32:24 +08:00
@whatot 也就是说 **SELinux** 是不管理 `unconfined` 的进程么?而只会限制配置了属性的进程?那不就违背了 least-privilege 的理念么?说好的默认最小权限呢 ( ´_ゝ`)
Explorare
2016-05-12 09:33:12 +08:00
@jhaohai 了解,多谢。
Explorare
2016-05-12 09:37:21 +08:00
>>>Unconfined processes run in unconfined domains, for example, init programs run in the unconfined initrc_t domain, unconfined kernel processes run in the kernel_t domain, and unconfined Linux users run in the unconfined_t domain. For unconfined processes, SELinux policy rules are applied, but policy rules exist that allow processes running in unconfined domains almost all access. Processes running in unconfined domains fall back to using DAC rules exclusively. If an unconfined process is compromised, SELinux does not prevent an attacker from gaining access to system resources and data, but of course, DAC rules are still used. SELinux is a security enhancement on top of DAC rules – it does not replace them.

--[4.2. Unconfined Processes]( https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Security-Enhanced_Linux/sect-Security-Enhanced_Linux-Targeted_Policy-Unconfined_Processes.html)

RTFM 是解决问题的最佳方法,给自己一嘴巴 ⊂彡☆))∀`)

多谢各位帮助,问题已解决
Explorare
2016-05-12 09:39:23 +08:00
所以说如果实在怕 `ssserver` 被爆破,也许给这个进程配置属性后限制访问比较好?
whatot
2016-05-12 09:39:32 +08:00
关闭 selinux 以及类似的机制就是欺骗自己。如果 ftp 、 http 这种服务出现漏洞,还有几天前发生的 imagemagic 的漏洞,你怎么限制访问也没用, docker 都能被穿破,除非你去用虚拟机。
Explorare
2016-05-12 09:40:41 +08:00
@whatot 那么 SELinux 能在一定程度上避免这种漏洞造成过大损失?
whatot
2016-05-12 09:42:30 +08:00
@Explorare SELinux 的意图就是这个
Explorare
2016-05-12 09:45:00 +08:00
@whatot 把不安全进程托管在 **Docker** 或者 **supervisor** 中也无法避免进程读取超出范围的文件或者获取过高的权限?
whatot
2016-05-12 09:48:11 +08:00
@Explorare 严重漏洞可以导致穿透 docker 类似的防护,但不一定能穿透 selinux ,但这也是一种保险。
Explorare
2016-05-12 09:51:03 +08:00
@whatot 那么 **Supervisor** 呢?
whatot
2016-05-12 09:59:05 +08:00
@Explorare 没试过这个,我用得比较少

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/278078

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX