home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / unix / programm / 5668 < prev    next >
Encoding:
Text File  |  1992-12-13  |  4.1 KB  |  101 lines

  1. Path: sparky!uunet!dtix!darwin.sura.net!gatech!rpi!batcomputer!cornell!uw-beaver!uw-coco!mdisea!mdivax1!van-bc!rwsys!root
  2. From: root@rwsys.wimsey.bc.ca (Superuser)
  3. Newsgroups: comp.unix.programmer
  4. Subject: Re: Revisited: How to isolate a user... setuid()..?
  5. Message-ID: <92121119736@rwsys.wimsey.bc.ca>
  6. Date: 13 Dec 92 06:15:46 GMT
  7. References: <1992Dec9.235237.26097@mcs.anl.gov>
  8. Organization: RWSYS Exporter BBS system
  9. Lines: 90
  10.  
  11. cbaker@woody.dep.anl.gov (Christopher Baker) writes:
  12. > I posted this a while back and got very little response.
  13. > I am re-posting this in hope that someone can help.
  14. > All help would be greatly appreciated!
  15. > I run a BBS which runs under SCO Xenix.  The BBS software
  16. > is accessed by loging into the Unix box through a single
  17. > login with no password.  The BBS host actually takes care
  18. > of each individuals login and password.  The host and all
  19. > of its associated files and directories are owned by BBS
  20. > and have a group of BBS.  So to unix, all the users of the
  21. > BBS have the same login (bbs) and group id (bbs).
  22. > The host software actually replaces the shell.  The host
  23. > actually allows for external programs to be run.  I have
  24. > tested, and they work fine, programs like telnet and vi
  25. > from the host.
  26. > This is the problem, programs like VI, Kermit, and telnet
  27. > allow for shell escapes. Since every user has the same unix 
  28. > level access, this is a gaping security hole, espcially
  29. > when all of the bulletin board files are owned 
  30. > by user BBS.  So with a single swoop, all of the bbs files
  31. > can be elimated.
  32. > How could I create a black hole (isolated directory),
  33. > use setuid(), or some other solution from a script or
  34. > a small compiled program?
  35. > I immagined either some way of temp. setting the user id to some
  36. > bogas id, moving to a directory and then changing permissions,
  37. > or somehow changing the permissions on a temp. moved to file system.
  38. > I am not a programmer and the documentation on setuid()
  39. > and the like are very poor.  Can anyone give me some explicit ways
  40. > of fixing this?
  41. > Thank You in Advance,
  42. > Christopher Baker
  43. > PS - Direct mail responses are welcome!
  44. > Re: How to isolate a user...setuid()?
  45. If your BBS program reads the enviornment from .profile, you can set the
  46. SHELL enviornmental variable to the path of your BBS executable. Many
  47. applications use this enviornment to determine what shell to offer
  48. when the user presses the keys to invoke a shell. Then when the user
  49. does a shell escape, it will be the BBS that comes up.
  50.  
  51. Not all programs use the enviornment in order to determine the path of
  52. the shell program. Often it is hardcoded into the application. In such
  53. a case, if you do not wish to tinker with the source code for the application
  54. ( or cannot ), perhaps you can set the path enviornment for the BBS to
  55. first try some off the wall directory that offers a setuid program
  56. by the name of sh or csh or whatever. This program will call the
  57. real sh after it re-sets the uid to something you would prefer. 
  58.  
  59. --- cut here ----
  60. /* fakesh.c
  61.  * compile with:
  62.  * cc fakesh.c -o sh
  63.  * The executable will be named sh. Stick it in 
  64.  * directory /fakebin or some other non-used directory
  65.  * make this program run setuid to some account name that
  66.  * can't damage your files. Then point the first subdirectory
  67.  * in your BBS's PATH= enviornmental variable to this
  68.  * subdirectory.
  69.  */
  70. main()
  71. {
  72.     /* call the real shell */
  73. system( "/bin/sh" );
  74. }
  75. --- cut here ----
  76.  
  77. Even this will not catch the shell escapes on all applications. This is
  78. the biggest problem with security on *nix BBS's. It is the leaky applications.
  79. Best solution is get into the source code for the applications and fix 
  80. versions of them for your BBS.
  81. Randy Wright
  82. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  83. root@rwsys.wimsey.bc.ca (Randy Wright)      | Exporter BBS     2400 bps
  84.                 or                          | (604) 581-0518     8N1
  85.     Randy_Wright@Mindlink.bc.ca             | uucp         ogin: uguest
  86.                                             | interactive login: guest
  87. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  88.