📄 secur
字号:
.de h'sp 2.tl '''UNIX Security - %''sp 3...de f'bp...wh -6 f.br.wh 0 h.de pg.sp .5.ti 5n...de bd.sp.in 8n.nf...de ed.sp.in 0.fi...sp 2.ce.ft B.ps 12On the Security of UNIX.sp.ft I.ceDennis M. Ritchie.sp.ft R.ceBell Laboratories, Murray Hill, N. J..sp 2.ps 10.pgRecently there has been much interest in the securityaspects of operating systems and software.At issue is the abilityto prevent undesireddisclosure of information, destruction of information,and harm to the functioning of the system.This paper discusses the degree of security which can be providedunder the UNIX system and offers a number of hintson how to improve security..pgThe first fact to face is that UNIX was not developed withsecurity, in any realistic sense, in mind;this fact alone guarantees a vast number of holes.(Actually the same statement can be made with respectto most systems.)The area of security in which UNIXis theoretically weakest isin protecting against crashing or at least cripplingthe operation of the system.The problem here is not mainly in uncriticalacceptance of bad parameters to system calls_there may be bugs in this area, but none are known_but rather in the lack of any checks for excessiveconsumption of resources.Most notably, there is no limit on the amount of diskstorage used, either in total space allocated or inthe number of files or directories.Here is a particularly ghastly shell sequence guaranteedto stop the system:.bd: loopmkdir xchdir xgoto loop.edEither a panic will occur because all the i-nodeson the device are used up or all the disk blocks willbe consumed, thus preventing anyone from writing fileson the device..pgProcesses are another resource on which the only limitis total exhaustion.For example, the sequence.bdcommand&command&command&.li. . ..edif continued long enough will use up all the slots in thesystem's process table and preventanyone from executing any commands.Alternatively, if the commands use much core,swap space may run out, causing a panic.Incidently, because of the implementation of process termination,the above sequence is effective in stopping the systemno matter how short a time it takes each command toterminate.(The process-table slot is not freed until the terminatedprocess is waited for;if no commands without ``&'' are executed,the Shell never executes a ``wait.'').pgIt should be evident that unbounded consumption of diskspace, files, swap space, and processes can easily occuraccidentally in malfunctioning programsas well as at command level.In fact UNIX is essentially defenseless against this kind ofabuse,nor is there any easy fix.The best that can be said is that it is generallyfairlyeasy to detect what has happened when disasterstrikes,to identify the user responsible,and take appropriate action.In practice,we have found that difficultiesin this area are rather rare,but we have not been faced with malicious users,and enjoy a fairly generous supply ofresources which have served to cushion us againstaccidental overconsumption..pgThe picture is considerably brighterin the area of protection of informationfrom unauthorized perusal and destruction.Here the degree of security seems (almost)adequate theoretically, and the problems liemore in the necessity for care in the actual use ofthe system..pgEach UNIX file has associated with iteleven bits of protection informationtogether with a user identification number and a user-groupidentification number(UID and GID).Nine of the protection bitsare used to specify independentlypermission to read, to write, and to execute the fileto the user himself, to members of the user'sgroup, and to all other users.Each process generatedby or for a user has associated withit an effective UID and a real UID, and an effective and real GID.When an attempt is madeto access the file for reading, writing, or execution,the user process's effective UID is comparedagainst the file's UID; if a match is obtained,access is granted provided the read, write, or executebit respectively for the user himself ispresent.If the UID for the file and for the process fail to match,but the GID's do match, the group bits are used; if the GID'sdo not match, the bits for other users are tested.The last two bits of each file's protection information,called the set-UID and set-GID bits,are used only when thefile is executed as a program.If, in this case, the set-UID bit is on for the file,the effective UID for the process is changed to the UIDassociated with the file; the change persistsuntil the process terminates or until the UIDchanged again by another execution of a set-UID file.Similarly the effective group ID of a process is changedto the GID associated with a filewhen that file is executed and has the set-GID bit set.The real UID and GID of a process do not changewhen any file is executed,but only as the result of a privileged systemcall..pgThe basic notion of the set-UID and set-GIDbits is that one may write a program which is executableby others and which maintains files accessible to others onlyby that program.The classical example is the game-playing program whichmaintains records of the scores of its players.The program itself has to read and write the score file,butno one but the game's sponsor can be allowedunrestricted access to the file lest they manipulatethe game to their own advantage.The solution is toturn on the set-UID bit of thegameprogram.When, and only when, it is invokedby players of the game, it may update the score fileordinary programs executed by others cannotaccess the score..pgThere are a number of special cases involvedin determining access permissions.Since executing a directory as a program is a meaninglessoperation, the execute-permissionbit, for directories, is taken instead to meanpermission to search the directory for a given fileduring the scanning of a path name;thus if a directory has execute permission but no readpermission for a given user, he may access fileswith known names in the directory,but may not read (list) the entire contents of thedirectory.Write permission on a directory is interpreted tomean that the user may create and deletefiles in that directory;it is impossiblefor any user to write directly into any directory..pgAnother, and from the point of view of security, muchmore serious special case is that there is a ``super user''who is able to read any file and write any non-directory.The super-user is also able to change the protectionmode and the owner UID and GID of any fileand to invoke privileged system calls.It must be recognized that the mere notion ofa super-user is a theoretical, and usuallypractical, blemish on any protection scheme..pgThe first necessity for a secure systemis of course arranging that all files and directorieshave the proper protection modes.Unfortunately, UNIX software is exceedinglypermissive in this regard;essentially all commands create filesreadable and writable by everyone.This means that more or lesscontinuous attention must bepaid to adjusting modes properly.If one wants to keep one's files completely secret,it is possible to remove all permissions from the directory in which they live,which is easy and effective;but if it is desiredto give general read permission whilepreventing writing, things are more complicated.The main problem is that write permission in a directorymeans precisely that; it has nothing to do withwrite permission for a file in that directory.Thus a writeable file in a read-only directory may be changed,or even truncated,though not removed.This fact is perfectly logical, though in this case unfortunate.A case can be made for requiring write permission forthe directory of a file as well as for the file itselfbefore allowing writing.(This possibility is more complicated than it seemsat first;the system has to allow users to change theirown directories while forbiddingthem to change the user-directory directory.).pgA situation converse to the above-discusseddifficulty is also present_ it is possible todelete a file if one has write permission for its directoryindependently of any permissions for the file.This problem is related more to self-protectionthan protection from others.It is largely mitigated by the fact thatthe two major commands which delete named files(mv and rm)ask confirmation before deleting unwritable files..pgIt follows from this discussionthat to maintain both data privacy anddata integrity,it is necessary, and largely sufficient,to make one's directory inaccessible to others.The lack of sufficiency could followfrom the existence of set-UID programscreated by the userand the possibility of totalbreach of system securityin one of the ways discussed below(or one of the ways not discussed below)..pgNeedless to say, the system administratorsmust be at least as careful as their mostdemanding user to place the correctprotection mode on the files under theircontrol.In particular,it is necessary that special files be protectedfrom writing, and probably reading, by ordinaryusers whenthey store sensitive files belonging to otherusers.It is easy to write programs that examine and changefiles by accessing the deviceon which the files live..pgOn the issue of password security,UNIX is probably better than most systems.Passwords are stored in an encrypted formwhich, in the absence of serious attentionfrom specialists in the field,appears reasonably secure,provided its limitations are understood.Since both the encryption algorithm and the encrypted passwordsare available,exhaustive enumeration of potential passwordsis feasible up to a point.As a practical test of the possibilities in this area,67 encrypted passwords were collected from 10 UNIX installations.These were tested against all five-letter combinations,all combinations of letters and digits of length four or less,and all words in Webster's Second unabridged dictionary;60 of the 67 passwords were found.The whole process took about 12 hours of machine time.This experience suggests that passwords should beat least six characters long and randomly chosen from an alphabetwhich includes digits and special characters..pgOf course there also existfeasible non-cryptanalyticways of finding out passwords.For example: write a program which types out ``login:\|''on the typewriter and copies whatever is typedto a file of your own.Then invoke the command and go away until the victim arrives.(It is this kind of possibility that makes it evident thatUNIX was not designed to be secure.).pgThe set-UID (set-GID)notion must be used carefully if any security is to be maintained.The first thing to keep in mind is thata writable set-UID file can have another program copied onto it.For example, if the super-user.ul(su)command is writable,anyone can copy the shellonto it and get a password-free versionof.ulsu.A more subtle problemcan come fromset-UID programs which are not sufficientlycareful of what is fed into them.In some systems, for example,the.ulmailcommand is set-UID and owned by the super-user.The notion is that one should be able to sendmail to anyone even if they want to protecttheir directories from writing.The trouble is that.ulmailis rather dumb:anyone can mail someone else's private file to himself.Much more serious,is the following scenario:make a file with a line like one in the password filewhich allows one to log in as the super-user.Then make a link named ``.mail'' to the password filein some writeabledirectory on the same device as the password file (say /tmp).Finally mail the bogus login line to /tmp/.mail;You can then login as the super-user,clean up the incriminating evidence,and have your will..pgThe fact that users can mount their own disks and tapesas file systemscan be another way of gaining super-user status.Once a disk pack is mounted, the system believeswhat is on it.Thus one can take a blank disk pack,put on it anything desired,and mount it.There are obvious and unfortunate consequences.For example:a mounted disk with garbage on it will crash thesystem;one of the files on the mounted disk can easily bea password-free version of.ulsu;other files can be unprotected entries for special files.The only easy fix for this problem is toforbid the use of.ulmountto unprivileged users.A partial solution, not so restrictive,would be to have the.ulmountcommand examine the special file for bad data,set-UID programs owned by others, and accessiblespecial files,and balk at unprivileged invokers.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -