setuid가 걸린 프로그램을 실행할 때 보안 속성이 있나요?

na94ojt의 이미지

혼자서 시스템 해킹 연습을 하는데 권한이 안따지더라구요.
그래서 테스트용으로 아래의 프로그램을 만들고

#include <stdio.h>
 
int main()
{
system("/bin/sh");
return 0;
}

setuid를 걸고 실행을 시켯는데 쉘만 실행되고 권한은 전혀 따지지 않더라구요.
os는 CentOS 7.0 쓰고 있구요. 커널 버전은 3.0.0입니다.
뭔가 따로 보안 속성이 디폴트로 걸려있나요?
(권한은 4755로 줬습니다.)

bushi의 이미지

debian 혹은 그 아류(ubuntu 라던가)에서 시험하면 다른 결과가 나올지도요.

system(3)

       Do  not  use  system()  from a program with set-user-ID or set-group-ID
       privileges, because strange values for some environment variables might
       be  used  to subvert system integrity.  Use the exec(3) family of func-
       tions instead, but not execlp(3) or execvp(3).  system() will  not,  in
       fact,  work  properly  from  programs  with set-user-ID or set-group-ID
       privileges on systems on which /bin/sh is bash version 2, since bash  2
       drops  privileges  on startup.  (Debian uses a modified bash which does
       not do this when invoked as sh.)