Skip to content

Su not working in container with udica generated policy #69

@jpf91

Description

@jpf91

Describe the bug
When a container is run in a udica generated policy, su command does not work.

To Reproduce
Steps to reproduce the behavior:

  1. Install this rule generated by udica:
(block container-sabnzbd
   (blockinherit container)
   (blockinherit net_container)
   (blockinherit restricted_net_container)
   (allow process process ( capability ( audit_write chown dac_override fowner fsetid kill mknod net_bind_service net_raw setfcap setgid setpcap setuid sys_chroot ))) 

   (allow process unreserved_port_t ( tcp_socket (  name_bind ))) 
   (allow process container_file_t ( dir ( add_name create getattr ioctl lock open read remove_name rmdir search setattr write ))) 
   (allow process container_file_t ( file ( append create getattr ioctl lock map open read rename setattr unlink write ))) 
   (allow process container_file_t ( sock_file ( append getattr open read write ))) 
   (allow process container_file_t ( dir ( add_name create getattr ioctl lock open read remove_name rmdir search setattr write ))) 
   (allow process container_file_t ( file ( append create getattr ioctl lock map open read rename setattr unlink write ))) 
   (allow process container_file_t ( sock_file ( append getattr open read write ))) 
   (allow process public_content_rw_t ( dir ( add_name create getattr ioctl lock open read remove_name rmdir search setattr write ))) 
   (allow process public_content_rw_t ( file ( append create getattr ioctl lock map open read rename setattr unlink write ))) 
   (allow process public_content_rw_t ( sock_file ( append getattr open read write ))) 
)
  1. podman run --security-opt label=type:container-sabnzbd.process -it debian:buster /bin/sh
  2. su => su: System error

Expected behavior
Su should work as expected, like when not specifying -security-opt label=type:container-sabnzbd.process .

Solution

Udica seems to need the (allow process process ( netlink_audit_socket ( nlmsg_read nlmsg_relay nlmsg_tty_audit ))) rule of container-selinux. Adding this rule fixes the problem, I'm not sure though whether it's possible to auto-detect when it is required.

Metadata

Metadata

Assignees

No one assigned

    Labels

    known bugBug is known or not possible to fix in udica componentquestionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions