home *** CD-ROM | disk | FTP | other *** search
/ The Hacker's Encyclopedia 1998 / hackers_encyclopedia.iso / hacking / systems / windowsn.txt < prev    next >
Encoding:
Text File  |  2003-06-11  |  24.2 KB  |  458 lines

  1.  
  2. **************************************************************************
  3.    Info: Windows NT Security Issues
  4.  Source: http://www.somar.com/
  5. **************************************************************************
  6.  
  7. Lax registry permissions
  8.  
  9. NT installs by default with Everyone given write access to much of the
  10. registry. To see just how much, use the Somar DumpAcl program. This is a
  11. major problem because the registry on any machine running NT, both servers
  12. and workstations, can be accessed remotely using Registry Editor. So a
  13. user running on some workstation can modify the registry on any server or
  14. workstation on which this user has an account (normally this means all
  15. servers), or on which the guest account is enabled.
  16.  
  17. Since the registry is similar to a file system, the obvious solution is
  18. either to stop sharing the registry or else set registry permissions
  19. securely. Unfortunately, there is no way to stop sharing the registry
  20. currently. As far as setting permissions, this is possible in theory but
  21. impractical because of the complexity of the registry. It is doubtful that
  22. anyone besides Microsoft can give guidance as to exactly which registry keys
  23. can be made read-only for ordinary users and which must be writeable by
  24. ordinary users. It is not acceptable to set permissions on the
  25. HKEY_LOCAL_MACHINE root key and let those permissions be propagated to all
  26. subkeys. This will cause various problems with the functioning of NT (it
  27. did when I tried it at least). If it is possible, then Microsoft needs to
  28. explicitly say so.
  29.  
  30. It is possible to enable auditing of the successful change of all registry
  31. keys and then write a program to scan the audit log looking for changes
  32. made by other than the admininstrator, but this seems a poor way to run a
  33. system. It is analogous to letting all users write to all files, then
  34. auditing the changes and punishing users who changed files they weren't
  35. supposed to change. It is clearly better to just deny write permission to
  36. begin with if you don't want the user changing the file or registry key.
  37.  
  38. Consider various scenarios. A malicious user changes a few registry entries
  39. so that various services begin functioning strangely, but not so strangely
  40. that it is obvious what has happened. The problems are not reproducible at
  41. other sites and the sysadmin feels like a fool. If logging is enabled, the
  42. sysadmin might eventually track the problem to the user who made the changes,
  43. but in reality, most sysadmins will just reinstall NT. The user might then
  44. wait a few months, then make the changes again. So the sysadmin comes to
  45. the conclusion that NT needs reinstallation every few months to keep things
  46. running properly.
  47.  
  48. It is also possible for a user to make the changes while logged on using
  49. another users account (the other user stepped out of the room without
  50. locking their workstation, or they wrote their password down in a notebook
  51. and the malicious user found it, etc, etc). In this case, even if the
  52. sysadmin traces the changes using the registry audit logs, they won't find
  53. the real culprit.
  54.  
  55. I have raised this isues of lax permissions with Microsoft and they looking
  56. into it.
  57.  
  58. Permissions set improperly
  59.  
  60. If the file system has a large number of files (say 500,000), it is
  61. impractical to examine the permissions on each file using file manager.
  62. Somar DumpAcl produces a report of permissions which groups files and
  63. directories with the same permissions, so the report of file system
  64. permissions is much shorter. Permissions are only shown for the root
  65. directory and files and directories below the root whose permissions differ
  66. from those of the root. If all files and directories have the same
  67. permissions, a report of permissions consists of a single item.
  68.  
  69. One of common ways for files to get "wrong" permissions is due to
  70. differences between the way permissions are treated when copying versus
  71. moving a file. Copying a file causes the file to inherit permissions from
  72. the directory into which the file is copied. Moving a file preserves
  73. existing permissions on the file. So, a user might create a file in a
  74. temporary directory whose initial permissions give Everyone full control.
  75. This user then decides to add some data to the file that they don't want
  76. other users to change. So they move the file to a directory where only they
  77. have write permission. However, the file will still have the original
  78. permissions, giving Everyone write permission. If the user had copied the
  79. file and then deleted the original, the file would have the same
  80. permissions as the directory. The Somar DumpAcl report makes it very easy
  81. to spot files with "wrong" permissions.
  82.  
  83. Remote procedure calls
  84.  
  85. NT programs use remote procedure calls (RPCs) to allow various system
  86. services to be performed on a remote computer (i.e. a computer other than
  87. the local computer where the program is executing). For example, the
  88. ability to modify the registry on remote computers is implemented using
  89. remote procedure calls.
  90.  
  91. There are mechanisms in NT for the RPC server to learn the username of the
  92. RPC client and then to limit the functions it will perform based on that
  93. username. However, as shown too many times in this document, there is a big
  94. difference between having good security mechanisms and having good
  95. security. If the RPC server ignores the username or incorrectly gives too
  96. many capabilities to the Everyone account or whatever, then there is a
  97. security hole. Since this whole aspect of NT seems poorly documented,
  98. there is really no telling how many security holes there are in this area.
  99.  
  100. Securing a shared workstation
  101.  
  102. Many users have asked how to secure a shared workstation so users cannot do
  103. any damage to the machine. For example, a workstation in a computer lab at
  104. a university. As described above, there is no way to secure the registry.
  105. The file system can be secured by setting the entire drive to the following
  106. permissions:
  107.  
  108.     SYSTEM                      full control
  109.     Administrators              full control
  110.     Everyone or Users           read only
  111.  
  112. Permissions should then be reset on the %SYSTEMROOT%\SYSTEM32\CONFIG
  113. dirctory as follows:
  114.  
  115.     SYSTEM                      full control
  116.     Administrators              full control
  117.     CREATOR OWNER               full control
  118.     Everyone or Users           add permission only
  119.  
  120. These settings allow users to create a profile, but prevent them from
  121. reading other users profiles, to avoid the security issues described in
  122. the section on Profiles contain sensitive information.
  123.  
  124. Permissions should also be reset on the TEMP directory
  125. (C:\TEMP or whatever) as follows:
  126.  
  127.     SYSTEM                      full control
  128.     Administrators              full control
  129.     CREATOR OWNER               full control
  130.     Everyone or Users           add permission only
  131.  
  132. These settings allows users to use the TEMP directory, but avoid problems
  133. with users being able to read temporary files containing sensitive
  134. information that were created (and never deleted) by other users. Even if
  135. user remove files with sensitive information from the temporary directory,
  136. there is the issue of permissions being retained when a file is moved
  137. instead of copied (discussed in the section on Permissions set improperly).
  138. So the permissions on the TEMP directory should be set so initial
  139. permissions on a file are restrictive. Users can later make the file
  140. world-readable if they want to.
  141.  
  142. There are other files and directories to which users of a shared
  143. workstation may need write access:
  144.  
  145.    * Some applications require write access to the application directory
  146.         to store data. cc:Mail is an example.
  147.    * Many older Windows applications require write access to the
  148.         %SYSTEMROOT% directory to store .INI files. Newer 32 bit
  149.         applications should use the user registry instead of .INI files.
  150.    * DOS graphic programs require write access to
  151.         %SYSTEMROOT%\SYSTEM32\CMOS.RAM.
  152.    * The builtin NT backup program requires write access the
  153.         %SYSTEMROOT%\SYSTEM32 directory to store temporary files.
  154.  
  155. The above list is not all-inclusive. You can enable failure auditing on all
  156. files and then examine the audit logs after making the most of the file
  157. system read-only to determine what files users need write access to. You
  158. can also use the Somar DumpAcl program to dump and print file permissions
  159. prior to making any changes.
  160.  
  161. Macro runs when document is opened
  162.  
  163. A WinWord document can contain a macro which runs when the file is opened.
  164. These macros can perform very powerful operations, including file i/o,
  165. sending mail or calling Win32 services. So a malicous user might ask
  166. another, unsuspecting user to read a document the first user wrote. This
  167. document contains a WordBasic macro which runs when the document is opened.
  168. The macro copies all files from the unsuspecting user's personal
  169. directories to a directory to which both users have read and write
  170. permission. The macro then sends mail to the malicious user notifying them
  171. of what happened. The document may take a while to start up, but the
  172. unsuspecting user assumes this is because the document is long. The
  173. malicous user later deletes the WordBasic macro from the document and
  174. notifies the unsuspecting user to replace any copy they made, so that
  175. all potentially incriminating evidence is destroyed.
  176.  
  177. It is also possible to write the macro so it calls a user written DLL that
  178. does something useful, as well as copying files and performing other
  179. hostile acts. This DLL might be large and complicated so that it would
  180. be very difficult to disassemble it and prove that it was doing something
  181. wrong. Even if you were able to prove that the DLL was accessing your
  182. files, the author could say this was due to a bug in the DLL. If you
  183. demanded the source from which the DLL was compiled, the auther could give
  184. you some modified source. When you pointed out that this source could not
  185. be used to build the DLL exactly, the author could reply that the source
  186. had been modified to fix bugs since the DLL was originally built, which is
  187. a perfectly reasonable explanation. By using a DLL in other words, there is
  188. never any incriminating evidence.
  189.  
  190. There are other programs besides WinWord which can create files which
  191. contain embedded macros which execute automatically when the file is opened
  192. in the creating application. For example, Microsoft Access and Lotus Ami
  193. Pro (these are just the programs I am aware of, I am sure there are many
  194. others). Also, Postscript files, believe or not, have file i/o capability.
  195. So if you open a postscript file in an interpretor, it might go out and
  196. modify any files to which you have write access. Also, Windows Help files
  197. (.HLP extension) can call DLLs (typical use is to customize the Help
  198. program in some way).
  199.  
  200. So, suppose you receive a package containing a .HLP, .EXE and a .DLL file
  201. all together. You want to browse the .HLP file to see what this package is
  202. all about and whether you trust it enough to run the .EXE file. You assume
  203. the .DLL is called by the .EXE only. When you open the .HLP file, the .DLL
  204. is executed and it's too late if you decide the package is untrustworthy.
  205.  
  206. WinWord and Access both allow the user to hold down the shift key when
  207. opening a document to prevent any macro from running. It is difficult to
  208. get in the habit of doing this (I am speaking from experience), especially
  209. when most of the Word or Access documents you open are your own, and
  210. therefore known to be safe.
  211.  
  212. Why authors of programs feel the need to include powerful embedded macro
  213. languages is something I really don't understand. It is possible to
  214. accomplish most of what embedded languages do using DDE or OLE automation.
  215. The advantage is that the end user learns one scripting language
  216. environment and then applies it to different applications, as opposed to
  217. learning a new language for each application. Microsoft has decided to
  218. include VBA in all of their products, which reduces the amount of learning
  219. to some extent. But why, I ask, not just provide good OLE Automation
  220. capabilities so we don't need embedded macro languages at all, but can
  221. instead use a separate Visual Basic program?
  222.  
  223. In any case, if it is absolutely necessary (for political or marketing
  224. reasons) to include an embedded scripting language in an application, then
  225. users should be allowed to set an option in the application so that they
  226. are prompted before any macros are run (e.g. "this document contains an
  227. embedded macro. Do you want to run this macro?"). There should be no way
  228. for the document to override this option and the option setting should be
  229. persistent (saved in a .INI file or the user's registry profile). If
  230. absolutely necessary, the application can be designed so that if the user
  231. refuses to run the macro, the application will refuse to open the document.
  232.  
  233. Interesting Note. I was just reading about the Good Times mail "virus".
  234. This is a hoax which alleged that there was a way to write a mail message
  235. such that if you read the mail message, all your files would be deleted.
  236. Users reading this hoax become frantic that they can no longer read any
  237. mail without endangering their system. Actually, there is an element of
  238. truth to this. If the mail message included an attached Word document, then
  239. reading that attachment might cause a macro to be run which deleted all
  240. your files. These attachments can be sent using SMTP MIME or Microsoft
  241. and other propertiary mail systems.
  242.  
  243. File sharing issues
  244.  
  245. The SMB file and print server protocol used by NT is much more resistant to
  246. impersonation and session hijacking than the NFS file sharing protocol used
  247. on Unix. This is significant since NFS is one of the biggest security
  248. weaknesses on Unix.
  249.  
  250. It is remotely conceivable that a gateway machine could hijack an SMB
  251. session and then read/write any files to which the true user of that
  252. session had access. However, the likelihood of this happening is very small,
  253. since true gateway machines are seldom used on LANs due to performance
  254. reasons. If the machine attempting the impersonation or hijacking is merely
  255. a node on the same Ethernet or Token Ring as the client and/or server, then
  256. it would probably be very difficult to perform the impersonation or
  257. hijacking. In particular, it would be difficult to get packets routed to
  258. the impersonating machine instead of the true destination machine.
  259.  
  260. In any case, the much more relevant security risk is that user data is
  261. transmitted in the clear and so can be easily read by any computer on any
  262. LAN over which the data passes. Remember that if you connect to a remote
  263. network drive over the Internet or other insecure connection, you are
  264. passing data back and forth whenever you read or write a file on the
  265. network drive. File manager gives the illusion of the data being local,
  266. which makes remote files easy to use, but which can also lead to security
  267. breaches.
  268.  
  269. This risk of eavesdropping does not exist for logons passwords, since these
  270. are never transmitted in the clear over the network, but rather a
  271. challenge-response protocol is used instead.
  272.  
  273. In the long run, it would be nice if Windows NT were designed so that all
  274. SMB protocol data passed over the network was automatically encrypted,
  275. using a key which was randomly chosen for each NetBios session. No directly
  276. competing operating systems have this feature and, until some do, it is
  277. unlikely NT will. If you have a need to transmit data over an insecure
  278. network and you want to be protected from eavesdroppers, you will need to
  279. use some sort of encryption. For example, there are router boxess that can
  280. encrypt all TCP data, but not the IP header which is used for routing. Put
  281. one of these routers at two sites and configure with the same key all data
  282. passed between those sites with be secure. You are still open to traffic
  283. analysis, however. Traffic analysis is a concern, for example, when an
  284. undercover spy wants to send reports back to the home office, or similar
  285. scenarios.
  286.  
  287. Profiles contain sensitive information
  288.  
  289. Some users put their userid and password on the command line of the program
  290. manager item, for example for Microsoft Mail. This way they can start mail
  291. by just double-clicking the mail icon, without having to type in their
  292. password. This password will be embedded in the user profile.
  293.  
  294. The local user profile is stored in %SYSTEMROOT%\SYSTEM32\CONFIG and also
  295. on a file server share, if a named, domain-wide user profile has been
  296. assigned for the user. Permissions on these directories should
  297. be like:
  298.  
  299.     SYSTEM                      full control
  300.     Administrators              full control
  301.     CREATOR OWNER               full control
  302.     Everyone or Users           add permission only
  303.  
  304. This is how permissions are initially set on %SYSTEMROOT%\SYSTEM32\CONFIG.
  305. Since CREATOR OWNER has full control, each user will have full control of
  306. their own profile. Since Everyone and Users have only add permission, they
  307. will be able to create a profile, but won't be able to read other users
  308. profiles.
  309.  
  310. In some cases, such as with 3270 emulator programs, passwords are included
  311. in keyboard macros (so the user can use F12 or whatever to initiate the
  312. entire logon sequence). These macros may be stored in the user profile or
  313. a file. If a file, users should be warned to make sure the directory where
  314. this file is stored is not world-readable. This is primarily a concern on
  315. shared workstations.
  316.  
  317. Passwords in general
  318.  
  319. If a password is short and obvious, then it can be guessed. If it is
  320. written down in a notebook, it can be discovered. So pick a long password,
  321. consisting of a mixture of upper and lower case letters and punctuation,
  322. never write it down, and change it often (but not so often you feel the
  323. need to write it down). This is all well-known, but so important that it is
  324. worth repeating nonetheless. Finding someone's password written down is
  325. the lowest-tech way to break into a system, but unfortunately also the
  326. most common.
  327.  
  328. Special shares
  329.  
  330. NT shares the %SYSTEMROOT%\SYSTEM32\REPL\EXPORT\SCRIPTS directory, so that
  331. users can read their login script during login. Normally, all of the
  332. scripts are readable by Everyone. So be careful what you put in these
  333. scripts and this directory. Other special shares are created by other
  334. installed services, such as SNA server or SMS. Use Somar DumpAcl to dump
  335. a list of shares and their permissions. And examine the permissions on the
  336. directories underlying the shares. Remember that the final access
  337. permission on a shared directory is the intersection of the share and NTFS
  338. permissions. So while you are setting permissions to restrict access, be
  339. careful you don't unintentionally completely remove access.
  340.  
  341. Win32 services default to running under SYSTEM account
  342.  
  343. Many of the internet Unix breakins occurred when someone discovered a bug
  344. in a TCP/IP service and took advantage of this bug to break into the
  345. system. For example, the infamous Internet worm took advantage of a bug
  346. which caused the stack to be overwritten if the finger daemon received bad
  347. input. Obviously, you should try to only run services which do not have
  348. bugs. However, the danger if there is a bug is greatly reduced if the
  349. service runs under an ordinary user account with restricted permissions,
  350. instead of under the SYSTEM account (which corresponds to the Unix root
  351. account). So, for example, run your SMTP service under an smtpuser account,
  352. and give this account limited privileges, instead of running it under the
  353. SYSTEM account.
  354.  
  355. Viruses
  356.  
  357. If you are not familiar with viruses, there are many good books on the
  358. subject. NT is better secured than DOS from viruses, provided you normally
  359. run under an ordinary user account (not administrator), and keep most
  360. system files protected against modification by user accounts. NT is also
  361. secure against boot sector viruses, which are the most difficult to
  362. eradicate, provided you never boot with a floppy in the drive, since NT
  363. does not allow non-privileged programs to write directly to disk.
  364.  
  365. Data on disk not encrypted
  366.  
  367. Anyone who has physical access to a machine can read file system data by
  368. either reinstalling NT (the installer can pick the initial Administrator's
  369. password and Administrator can read all files) or booting from a DOS floppy
  370. and reading raw sectors using a low level disk utility. In both cases, the
  371. user would need access to the floppy drive. On many machines, the floppy
  372. can be disabled via the BIOS. There are two ways to get around a disabled
  373. floppy:
  374.  
  375.    * Resetting the BIOS. Typically this is done by setting a jumper which
  376. causes a slow discharge of the battery needed to preserve the BIOS settings
  377. in CMOS. Discharge might take several hours, or several minutes, depending
  378. on your motherboard. Don't trust manufacturer's specs, since this is not
  379. something anyone tests.
  380.    * Moving the hard drive to another machine and reading it there.
  381.  
  382. These techniques require opening the computer case, so there should be no
  383. risk for machines stored in open areas where opening a case would be
  384. immediately noticed.
  385.  
  386. If the case can be opened, then you will need to encrypt data on disk.
  387. There are various products which allow you to do this, with varying degress
  388. of user-friendliness and transparency. (Any manufacturers who would like me
  389. to list there product and add hypertext links to their Web pages, just drop
  390. me a note).
  391.  
  392. If you need military grade security, it should be noted that fragments of
  393. any file that is stored unencrypted in memory can be written to the paging
  394. file. So software encryption products will not be sufficient in this case.
  395. What you need instead is a disk controller which encrypts data on the fly
  396. as it is transferred between memory and disk. Typically, the user would be
  397. prompted for a password by the disk controller BIOS during cold boot. An
  398. examples of where military grade security is needed is a embassy which
  399. contains secret data on PCs. These PCs might fall into the hands of a
  400. hostile intelligence agency with adequate resources to extract information
  401. from the fragments of data in the paging file. For most users, such
  402. military grade security is not really necessary.
  403.  
  404. Backup/Restore user rights allow reading/writing all files
  405.  
  406. It is obvious that to perform a backup, the operator needs to be able to
  407. read all files. What is not obvious is that tape need not be involved. It
  408. is trivial to write a program in C which takes advantage of the backup right
  409. to read any file in the system. So be careful of who you give the backup
  410. right to. The use of the backup right as well as accesses to files can be
  411. logged in the Audit log. Users who have both backup and restore rights can
  412. read any file, modify it and write it back. As with the Backup right, use
  413. of the restore right can be logged. User Manager is used to assign rights
  414. to users and enable auditing of the use of user rights.
  415.  
  416. Data on backup tapes not encrypted
  417.  
  418. The NT backup program does not encrypt data on tape. So anyone who has a
  419. tape can read it on another machine on which the user has restore
  420. privileges, such as their personal NT workstation.
  421.  
  422. FTP/Telnet passwords
  423.  
  424. Microsoft does a good job of warning people about the fact that FTP
  425. passwords are transmitted in the clear. Especially for machines connected
  426. to the Internet, it is probably best to allow only anonymous FTP, so that
  427. no one ever attempts to transmit a password to your machine over the
  428. internet. If you FTP or Telnet from your machine to another machine on the
  429. internet, the same warning applies: any password you enter or any
  430. data you transmit, could be intercepted by other machines on networks over
  431. which the data is passed.
  432.  
  433. FTP service directory
  434.  
  435. The home directory you specify for the FTP service is only the initial
  436. current directory. Ftp users can change their current directory. So if you
  437. specify a home directory of c:\ftp, any ftp user can change to c:\ and thence
  438. change to any subdirectories under c:\. Normal NTFS permissions will apply,
  439. of course, to whatever account the ftp user is running under. If you don't
  440. want ftp users to be able to see the root directory of your primary
  441. partition, you should create a separate partition for ftp and then
  442. configure ftp so that it can only read and/or write to that partition.
  443.  
  444. Application software issues
  445.  
  446. The really valuable data on a computer system is what is produced by
  447. applications and stored in file and databases. It is very important to
  448. write and install these applications with an eye on security. It does no
  449. good to follow all the guidelines above and then have SQL Server setup in
  450. such a way that anyone with an account can read the entire database. Or to
  451. have an transaction processing monitor which runs under a privileged
  452. account and allows unprivileged users to submit requests that give them
  453. access to the entire file system.
  454.  
  455. Send comments and questions to info@somar.com
  456. All material Copyright ⌐ 1995 Somar Software. Last updated 3 June 1995.
  457.  
  458.