text
stringlengths
0
1.99k
it has been criticized as an area of system security compromise.
Permission modes
OWNER GROUP OTHERS
------------------------------------------------------------
rwx : rwx : rwx
------------------------------------------------------------
r=read w=write x=execute
-rw--w-r-x 1 bob csc532 70 Apr 23 20:10 file
drwx------ 2 sam A1 2 May 01 12:01 directory
FIGURE 1. File and directory modes: File shows Bob as the owner, with read
and write permission. Group has write permission, while Others has read and
execute permission. The directory gives a secure directory not readable,
writeable, or executable by Group and Others.
Since the file protection mechanism is so important in the Unix operating
system, it stands to reason that the proper setting of permission bits is
required for overall security. Aside from user ignorance, the most common
area of file compromise has to do with the default setting of permission bits
at file creation. In some systems the default is octal 644, meaning that only
the file owner can write and read to a file, while all others can only read
it. (3) In many "open" environments this may be acceptable. However, in
cases where sensitive data is present, the access for reading by others should
be turned off. The file utility umask does in fact satisfy this requirement.
A suggested setting, umask 027, would enable all permission for the file
owner, disable write permission to the group, and disable permissions for all
others (octal 750). By inserting this umask command in a user .profile or
.login file, the default will be overwritten by the new settings at file
creation.
The CHMOD utility can be used to modify permission settings on files and
directories. Issuing the following command,
chmod u+rwd,g+rw,g-w,u-rwx file
will provide the file with the same protection as the umask above (octal 750).
Permission bits can be relaxed with chmod at a later time, but at least
initially, the file structure can be made secure using a restrictive umask.
By responsible application of such utilities as umask and chmod, users can
enhance file system security. The Unix system, however, restricts the
security defined by the user to only owner, group and others. Thus, the owner
of the file cannot designate file access to specific users. As Kowack and
Healy have pointed out, "The granularity of control that (file security)
mechanisms is often insufficient in practice (...) it is not possible to grant
one user write protection to a directory while granting another read
permission to the same directory. (4) A useful file security file security
extension to the Unix system might be Multics style access control lists.
With access mode vulnerabilities in mind, users should pay close attention
to files and directories under their control, and correct permissions whenever
possible. Even with the design limitations in mode granularity, following a
safe approach will ensure a more secure Unix system file structure.
SUID and SGID
The set user id (suid) and set group id (sgid) identify the user and group
ownership of a file. By setting the suid or sgid permission bits of an
executable file, other users can gain access to the same resources (via the
executable file) as that of the real file's owner.
For Example:
Let Bob's program bob.x be an executable file accessible to others. When Mary
executes bob.x, Mary becomes the new program owner. If during program
execution bob.x requests access to file browse.txt, then Mary must have
previous read or write permission to browse.txt. This would allow Mary and
everyone else total access to the contents of browse.txt, even when she is not
running bob.x. By turning on the suid bit of bob.x, Mary will have the same
access permissions to browse.txt as does the program's real owner, but she
will only have access to browse.txt during the execution of bob.x. Hence, by
incorporating suid or sgid, unwelcome browsers will be prevented from
accessing files like browse.txt.
Although this feature appears to offer substantial access control to Unix
system files, it does have one critical drawback. There is always the chance
that the superuser (system administrator) may have a writable file for others
that is also set with suid. With some modification in the file's code (by a
hacker), an executable file like this would enable a user to become a
superuser. Within a short period of time this violator could completely
compromise system security and make it inaccessible, even to other superusers.
As Farrow (5) puts it, "(...) having a set-user-id copy of the shell owned by
root is better than knowing the root password".
To compensate for this security threat, writable suid files should be sought
out and eliminated by the system administrator. Reporting of such files by
normal users is also essential in correcting existing security breaches.
DIRECTORIES
Directory protection is commonly overlooked component of file security in the
Unix system. Many system administrators and users are unaware of the fact,
that "publicly writable directories provide the most opportunities for
compromising the Unix system security" (6). Administrators tend to make these
"open" for users to move around and access public files and utilities. This
can be disastrous, since files and other subdirectories within writable
directories can be moved out and replaced with different versions, even if
contained files are unreadable or unwritable to others. When this happens, an
unscrupulous user or a "password breaker" may supplant a Trojan horse of a
commonly used system utility (e.g. ls, su, mail and so on). For example,