V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Explorare
V2EX  ›  CentOS

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

  •  
  •   Explorare · 2016-05-12 09:17:26 +08:00 · 2309 次点击
    这是一个创建于 2878 天前的主题,其中的信息可能已经有所发展或是发生改变。

    最近踩了 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

    15 条回复    2016-05-12 09:59:05 +08:00
    jhaohai
        1
    jhaohai  
       2016-05-12 09:24:05 +08:00 via iPhone
    为啥不禁用了
    Explorare
        2
    Explorare  
    OP
       2016-05-12 09:28:38 +08:00
    @jhaohai 因为我认同 SELinux 的理念,做好权限管理很重要,最大的问题在人,懒得翻 manpage 直接关掉 FirewallD 和 SELinux 就骗自己解决问题,迟早药丸。
    whatot
        3
    whatot  
       2016-05-12 09:30:08 +08:00 via Android
    全是 unconfined 就不关 selinux 的事情了
    jhaohai
        4
    jhaohai  
       2016-05-12 09:32:23 +08:00 via iPhone
    @Explorare 生产的服务器都看不到几个开 selinux 的,很多软件在安装手册上都建议关闭 selinux 。而且现在都是集中控制访问了,没人会在 host 上折腾 selinux 和 firewall
    Explorare
        5
    Explorare  
    OP
       2016-05-12 09:32:24 +08:00
    @whatot 也就是说 **SELinux** 是不管理 `unconfined` 的进程么?而只会限制配置了属性的进程?那不就违背了 least-privilege 的理念么?说好的默认最小权限呢 ( ´_ゝ`)
    Explorare
        6
    Explorare  
    OP
       2016-05-12 09:33:12 +08:00
    @jhaohai 了解,多谢。
    Explorare
        7
    Explorare  
    OP
       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
        8
    Explorare  
    OP
       2016-05-12 09:39:23 +08:00
    所以说如果实在怕 `ssserver` 被爆破,也许给这个进程配置属性后限制访问比较好?
    whatot
        9
    whatot  
       2016-05-12 09:39:32 +08:00 via Android   ❤️ 1
    关闭 selinux 以及类似的机制就是欺骗自己。如果 ftp 、 http 这种服务出现漏洞,还有几天前发生的 imagemagic 的漏洞,你怎么限制访问也没用, docker 都能被穿破,除非你去用虚拟机。
    Explorare
        10
    Explorare  
    OP
       2016-05-12 09:40:41 +08:00
    @whatot 那么 SELinux 能在一定程度上避免这种漏洞造成过大损失?
    whatot
        11
    whatot  
       2016-05-12 09:42:30 +08:00 via Android
    @Explorare SELinux 的意图就是这个
    Explorare
        12
    Explorare  
    OP
       2016-05-12 09:45:00 +08:00
    @whatot 把不安全进程托管在 **Docker** 或者 **supervisor** 中也无法避免进程读取超出范围的文件或者获取过高的权限?
    whatot
        13
    whatot  
       2016-05-12 09:48:11 +08:00
    @Explorare 严重漏洞可以导致穿透 docker 类似的防护,但不一定能穿透 selinux ,但这也是一种保险。
    Explorare
        14
    Explorare  
    OP
       2016-05-12 09:51:03 +08:00
    @whatot 那么 **Supervisor** 呢?
    whatot
        15
    whatot  
       2016-05-12 09:59:05 +08:00
    @Explorare 没试过这个,我用得比较少
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3548 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 04:51 · PVG 12:51 · LAX 21:51 · JFK 00:51
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.