Linux 2.6.32 Centos 6.4 setuid() 실패/보안 변경?

Linux 2.6.32 Centos 6.4 setuid() 실패/보안 변경?

최근 CentOS 6.4로 업데이트한 후 두 시스템에 기능이나 selinux처럼 작동하는 setuid() 제한이 있지만 둘 다 비활성화되어 있습니다. 예를 들어 다음은 실패합니다.

[root@host statd]# perl -e 'use POSIX; POSIX::setuid(99);system("id")'
[root@host statd]# echo $?
0

다음과 같은 결과를 반환해야 하는 경우:

host:~# perl -e 'use POSIX; POSIX::setuid(99);system("id")'
uid=99(nobody) gid=0(root) groups=99(nobody),0(root) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023

Perl 호출을 추적하면 setuid() 호출이 성공하지만 system() 하위 항목은 selinux 또는 유사한 프로그램에 의해 종료된 것처럼 즉시 종료됩니다. 그러나 semodule -DB 이후에도 /var/log/audit/audit.log에는 로그 항목이 없습니다.

setuid32(99)                            = 0
getuid32()                              = 99
geteuid32()                             = 99
pipe([3, 4])                            = 0
clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0xb7705728) = 10073
close(4)                                = 0
rt_sigaction(SIGINT, {SIG_IGN, [], 0}, {SIG_DFL, [], 0}, 8) = 0
rt_sigaction(SIGQUIT, {SIG_IGN, [], 0}, {SIG_DFL, [], 0}, 8) = 0
waitpid(10073, [{WIFEXITED(s) && WEXITSTATUS(s) == 255}], 0) = 10073
--- SIGCHLD (Child exited) @ 0 (0) ---
rt_sigaction(SIGINT, {SIG_DFL, [], 0}, NULL, 8) = 0
rt_sigaction(SIGQUIT, {SIG_DFL, [], 0}, NULL, 8) = 0
read(3, "\r\0\0\0", 4)                  = 4
close(3)                                = 0
exit_group(0)    

이 문제는 nfs.statd가 "로컬 netconfig 데이터베이스에 액세스하지 못했습니다: Netconfig 데이터베이스를 찾을 수 없습니다."라는 메시지와 함께 실패했기 때문에 처음 재부팅한 후에 분명해졌습니다. 그리고 "RPC: 서버 로컬 호스트에는 더 강력한 인증이 필요합니다." 때문에 rpc.rquotasd가 실패했습니다.

nfs.statd 문제는 루트(chown root:root /var/lib/nfs/statd)로 실행하여 해결할 수 있습니다. 머신의 모든 것을 루트로 실행하는 것은 좋은 해결 방법이 아닌 것 같습니다. ;)

다른 계정으로 su를 시도해도 작동하지 않습니다.

[root@host ~]# su - jboss
su: warning: cannot change directory to /opt/jboss: Permission denied
su: /bin/bash: Permission denied
[root@host ~]# su jboss
su: /bin/bash: Permission denied

기본 시스템 정보는 다음과 같습니다.

[root@host statd]# getenforce
Permissive
[root@host statd]# uname -a
Linux host.example.com 2.6.32-358.14.1.el6.i686 #1 SMP Tue Jul 16 21:12:30 UTC 2013 i686 i686 i386 GNU/Linux
[root@host statd]# cat /etc/redhat-release
CentOS release 6.4 (Final)
[root@host statd]# getcap /usr/bin/perl
/usr/bin/perl =

selinux나 Linux 기능이 아닌 것 같은데 이 문제의 원인은 무엇입니까?

답변1

업그레이드 프로세스에서 /의 권한이 다음과 같이 변경되었습니다.

[root@host ~]# ls -alZ /
drw-r--r--. 42374 5031 system_u:object_r:root_t:s0      .
drw-r--r--. 42374 5031 system_u:object_r:root_t:s0      ..

어느 것으로 수정 되었습니까?

chown root:root / && chmod 755 /

오류 공간을 줄이는 데 큰 도움이 되는 것은 대신 실행되는 것이었습니다.

strace perl -e 'use POSIX; POSIX::setuid(99);exec("id")'

모든 $PATH 디렉토리를 시도할 때 EACCES를 사용할 때마다 Perl의 execve() 호출이 실패하는 것을 보여줍니다.

관련 정보