home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / unix / programm / 5217 < prev    next >
Encoding:
Text File  |  1992-11-09  |  1.9 KB  |  55 lines

  1. Xref: sparky comp.unix.programmer:5217 comp.mail.mh:1268
  2. Newsgroups: comp.unix.programmer,comp.mail.mh
  3. Path: sparky!uunet!pipex!warwick!coventry!champion
  4. From: champion@cch.coventry.ac.uk (Alun)
  5. Subject: Re: setuid programs and calls...
  6. Message-ID: <BxG21C.n38@cck.coventry.ac.uk>
  7. Sender: news@cck.coventry.ac.uk (news user)
  8. Nntp-Posting-Host: cc_sysh
  9. Organization: Coventry University, Coventry, UK.
  10. References: <1992Nov5.220832.3217@spectrum.xerox.com> <1992Nov9.031112.21835@spectrum.xerox.com>
  11. Date: Mon, 9 Nov 1992 10:19:59 GMT
  12. Lines: 41
  13.  
  14. In article <1992Nov9.031112.21835@spectrum.xerox.com> leisner.henr801c@xerox.com writes:
  15. ~Well, I think what I'm doing now works...
  16. ~
  17. ~    #include <stdio.h>
  18. ~
  19. ~    main()
  20. ~    {
  21. ~        int i;
  22. ~
  23. ~        if(0 != setruid(220)) {
  24. ~            perror("Can't set real uid");
  25. ~            exit(2);
  26. ~        }
  27. ~
  28. ~        /* this runs setuid on the destination mailfile account UID */
  29. ~        i = system("inc +zombi -file /net/zombi/files5/spool/mail/leisner -truncate");
  30. ~        system("id");
  31. ~        exit(i);
  32. ~    }
  33. ~
  34. ~I found I have to be setuid to root and change the real ID -- just changing
  35. ~the effective UID will let me read the remote mail file, but not truncate it.
  36.  
  37. I didn't see the beginning of this thread so I don't know exactly what
  38. you are trying to do.
  39. But doesn't system(arg) runs "sh -c arg" and therefore has some of the security
  40. problems of a setuid shell script. You have not specified the full path to
  41. "inc" so someone could write their own version of "inc" and as long as the
  42. environment variable $PATH was configured properly it would run their version
  43. of "inc" and not the intended on - same with "id". 
  44. Even if you did specify the full path it would still be susceptible to attacks
  45. with $IFS.
  46.  
  47. If security is not a problem ignore this article. :-}
  48.  
  49.  
  50.     -Alun
  51.     
  52. -- 
  53. A.Champion                |  That's an interesting point, in the sense of
  54. (champion@uk.ac.cov.cck)  |    being very not interesting at all. - The Liar
  55.