Misplaced Pages

setuid

Article snapshot taken from Wikipedia with creative commons attribution-sharealike license. Give it a read and then ask your questions in the chat. We can research this topic together.

The Unix and Linux access rights flags setuid and setgid (short for set user identity and set group identity ) allow users to run an executable with the file system permissions of the executable's owner or group respectively and to change behaviour in directories. They are often used to allow users on a computer system to run programs with temporarily elevated privileges to perform a specific task. While the assumed user id or group id privileges provided are not always elevated, at a minimum they are specific.

#751248

62-480: The flags setuid and setgid are needed for tasks that require different privileges than what the user is normally granted, such as the ability to alter system files or databases to change their login password. Some of the tasks that require additional privileges may not immediately be obvious, though, such as the ping command, which must send and listen for control packets on a network interface. The setuid and setgid bits are normally represented as

124-430: A Sequence Number that is only reset at boot time. The Echo Reply is returned as: An ICMP packet transported with IPv6 looks like this. Most Linux systems use a unique Identifier for every ping process, and Sequence Number is an increasing number within that process. Windows uses a fixed Identifier , which varies between Windows versions, and a Sequence Number that is only reset at boot time. The Echo Reply

186-441: A standard deviation of 0.748 ms. In cases of no response from the target host, most implementations display either nothing or periodically print notifications about timing out. Possible ping results indicating a problem include the following: In case of error, the target host or an intermediate router sends back an ICMP error message, for example host unreachable or TTL exceeded in transit . In addition, these messages include

248-489: A binary compatibility layer . This is much simpler and faster than emulation ; for example, it allows applications intended for Linux to be run at effectively full speed. This makes BSDs not only suitable for server environments, but also for workstation ones, given the increasing availability of commercial or closed-source software for Linux only. This also allows administrators to migrate legacy commercial applications, which may have only supported commercial Unix variants, to

310-488: A bit more BSD-flavored than SysVish, but it was pretty eclectic. Eric S. Raymond summarizes the longstanding relationship between System V and BSD, stating, "The divide was roughly between longhairs and shorthairs; programmers and technical people tended to line up with Berkeley and BSD, more business-oriented types with AT&T and System V." In 1989, David A. Curry wrote about the differences between BSD and System V. He characterized System V as being often regarded as

372-404: A manner similar to setgid , in which case it forces all files and sub-directories created in a directory to be owned by that directory's owner - a simple form of inheritance. This is generally not needed on most systems derived from BSD , since by default directories are treated as if their setgid bit is always set, regardless of the actual value. As is stated in open(2) , "When a new file

434-481: A more modern operating system, retaining the functionality of such applications until they can be replaced by a better alternative. Current BSD operating system variants support many of the common IEEE , ANSI , ISO , and POSIX standards, while retaining most of the traditional BSD behavior. Like AT&T Unix , the BSD kernel is monolithic , meaning that device drivers in the kernel run in privileged mode , as part of

496-417: A read-only umask or an append only attribute. Developers design and implement programs that use this bit on executables carefully in order to avoid security vulnerabilities including buffer overruns and path injection . Successful buffer-overrun attacks on vulnerable applications allow the attacker to execute arbitrary code under the rights of the process exploited. In the event that a vulnerable process uses

558-524: A recursive mode restricted to directories, so modifying an existing directory tree must be done manually, with a command such as find /path/to/directory -type d -exec chmod g+s '{}' '\' . The setuid and setgid flags have different effects, depending on whether they are applied to a file, to a directory or binary executable or non-binary executable file. The setuid and setgid flags have an effect only on binary executable files and not on scripts (e.g., Bash, Perl, Python). When

620-466: A single request wakes up that host just enough to allow its Echo Reply service to reply instantly if that service was enabled. The host does not need to wake up all devices completely and may return to low-power mode after a short delay. Such configuration may be used to avoid a host to enter in hibernation state, with much longer wake-up delay, after some time passed in low power active mode. A packet including IP and ICMP headers must not be greater than

682-399: A statistical summary of the results, typically including the minimum, maximum, the mean round-trip times, and standard deviation of the mean. The command-line options of the ping utility and its output vary between the numerous implementations. Options may include the size of the payload, count of tests, limits for the number of network hops ( TTL ) that probes traverse, interval between

SECTION 10

#1732793536752

744-400: A visiting professor. He helped to install Version 6 Unix and started working on a Pascal implementation for the system. Graduate students Chuck Haley and Bill Joy improved Thompson's Pascal and implemented an improved text editor, ex . Other universities became interested in the software at Berkeley, and so in 1977 Joy started compiling the first Berkeley Software Distribution (1BSD), which

806-570: Is 'root' and the SUID permission is set (the '4') - so the file is executed as 'root'. The reason an executable would be run as 'root' is so that it can modify specific files that the user would not normally be allowed to, without giving the user full root access. A default use of this can be seen with the /usr/bin/passwd binary file. /usr/bin/passwd needs to modify /etc/passwd and /etc/shadow which store account information and password hashes for all users, and these can only be modified by

868-547: Is a discontinued operating system based on Research Unix , developed and distributed by the Computer Systems Research Group (CSRG) at the University of California, Berkeley . Since the original has become obsolete, the term "BSD" is commonly used for its open-source descendants, including FreeBSD , OpenBSD , NetBSD , and DragonFly BSD . BSD was initially called Berkeley Unix because it

930-420: Is configured to accept wakeup requests. If the host is already active and configured to allow replies to incoming ICMP Echo Request packets, the returned reply should include the same payload. This may be used to detect that the remote host was effectively woken up, by repeating a new request after some delay to allow the host to resume its network services. If the host was just sleeping in low power active state,

992-413: Is created it is given the group of the directory which contains it." Permissions of a file can be checked in octal form and/or alphabetic form with the command line tool stat 4701 on an executable file owned by 'root' and the group 'root' A user named 'thompson' attempts to execute the file. The executable permission for all users is set (the '1') so 'thompson' can execute the file. The file owner

1054-526: Is much more suited to a research environment, which requires a faster file system, better virtual memory handling, and a larger variety of programming languages . Berkeley's Unix was the first Unix to include libraries supporting the Internet Protocol stacks: Berkeley sockets . A Unix implementation of IP's predecessor, the ARPAnet's NCP , with FTP and Telnet clients, had been produced at

1116-402: Is returned as: The payload of the packet is generally filled with ASCII characters, as the output of the tcpdump utility shows in the last 32 bytes of the following example (after the eight-byte ICMP header starting with 0x0800 ): The payload may include a timestamp indicating the time of transmission and a sequence number, which are not found in this example. This allows ping to compute

1178-455: Is set. However, if 'thoughts' is a file, then 'wozniak' can edit it. Sticky bit has the final decision. If sticky bit and SGID had not been set, the user 'wozniak' could rename, move, or delete the file named 'thoughts' because the directory named 'blog' allows read and write by group, and wozniak belongs to the group, and the default 0002 umask allows new files to be edited by group. Sticky bit and SGID could be combined with something such as

1240-422: Is the output of running ping on Linux for sending five probes (1-second interval by default, configurable via -i option) to the target host www.example.com : The output lists each probe message and the results obtained. Finally, it lists the statistics of the entire test. In this example, the shortest round-trip time was 9.674 ms, the average was 10.968 ms, and the maximum value was 11.726 ms. The measurement had

1302-480: The chroot system call is not available to non- root users on Unix. See limitations of chroot for more details. Setting the setgid permission on a directory causes files and subdirectories created within to inherit its group ownership, rather than the primary group of the file-creating process. Created subdirectories also inherit the setgid bit. The policy is only applied during creation and, thus, only prospectively. Directories and files existing when

SECTION 20

#1732793536752

1364-498: The setgid bit is applied are unaffected, as are directories and files moved into the directory on which the bit is set. Thus is granted a capacity to work with files amongst a group of users without explicitly setting permissions, but limited by the security model expectation that existing files permissions do not implicitly change. The setuid permission set on a directory is ignored on most UNIX and Linux systems. However FreeBSD can be configured to interpret setuid in

1426-448: The setuid bit to run as root , the code will execute with root privileges, in effect giving the attacker root access to the system on which the vulnerable process is running. Of particular importance in the case of a setuid process is the environment of the process. If the environment is not properly sanitized by a privileged process, its behavior can be changed by the unprivileged process that started it. For example, GNU libc

1488-432: The setuid or setgid attributes are set on an executable file, then any users able to execute the file will automatically execute the file with the privileges of the file's owner (commonly root ) and/or the file's group, depending upon the flags set. This allows the system designer to permit trusted programs to be run which a user would otherwise not be allowed to execute. These may not always be obvious. For example,

1550-466: The C shell . Some 75 copies of 2BSD were sent out by Bill Joy. A VAX computer was installed at Berkeley in 1978, but the port of Unix to the VAX architecture, UNIX/32V , did not take advantage of the VAX's virtual memory capabilities. The kernel of 32V was largely rewritten to include Berkeley graduate student Özalp Babaoğlu 's virtual memory implementation, and a complete operating system including

1612-545: The University of Illinois in 1975, and was available at Berkeley. However, the memory scarcity on the PDP-11 forced a complicated design and performance problems. By integrating sockets with the Unix operating system's file descriptors , it became almost as easy to read and write data across a network as it was to access a disk. The AT&T laboratory eventually released their own STREAMS library, which incorporated much of

1674-484: The maximum transmission unit of the network, or risk being fragmented . To conduct a denial-of-service attack , an attacker may send ping requests as fast as possible, possibly overwhelming the victim with ICMP echo requests. This technique is called a ping flood . Ping requests to multiple addresses, ping sweeps , may be used to obtain a list of all hosts on a network. BSD The Berkeley Software Distribution or Berkeley Standard Distribution ( BSD )

1736-490: The ping command may need access to networking privileges that a normal user cannot access; therefore it may be given the setuid flag to ensure that a user who needs to ping another system can do so, even if their account does not have the required privilege for sending packets. For security purposes, the invoking user is usually prohibited by the system from altering the new process in any way, such as by using ptrace , LD_LIBRARY_PATH or sending signals to it, to exploit

1798-544: The "standard Unix." However, he described BSD as more popular among university and government computer centers, due to its advanced features and performance: Most university and government computer centers that use UNIX use Berkeley UNIX, rather than System V. There are several reasons for this, but perhaps the two most significant are that Berkeley UNIX provides networking capabilities that until recently (Release 3.0) were completely unavailable in System V, and that Berkeley UNIX

1860-499: The 9th Edition, which incorporated source code and improvements from 4.3BSD. The result was that these later versions of Research Unix were closer to BSD than they were to System V. In a Usenet posting from 2000, Dennis Ritchie described this relationship between BSD and Research Unix: Research Unix 8th Edition started from (I think) BSD 4.1c, but with enormous amounts scooped out and replaced by our own stuff. This continued with 9th and 10th. The ordinary user command-set was, I guess,

1922-576: The AT&;T code. Within eighteen months, all of the AT&T utilities had been replaced, and it was determined that only a few AT&T files remained in the kernel. These files were removed, and the result was the June 1991 release of Networking Release 2 (Net/2), a nearly complete operating system that was freely distributable. Net/2 was the basis for two separate ports of BSD to the Intel 80386 architecture:

setuid - Misplaced Pages Continue

1984-661: The CSRG was dissolved and development of BSD at Berkeley ceased. Since then, several variants based directly or indirectly on 4.4BSD-Lite (such as FreeBSD , NetBSD , OpenBSD and DragonFly BSD ) have been maintained. The permissive nature of the BSD license has allowed many other operating systems, both open-source and proprietary, to incorporate BSD source code. For example, Microsoft Windows used BSD code in its implementation of TCP/IP and bundles recompiled versions of BSD's command-line networking tools since Windows 2000 . Darwin ,

2046-545: The System V copyright and the Unix trademark. The USL v. BSDi lawsuit was filed in 1992 and led to an injunction on the distribution of Net/2 until the validity of USL's copyright claims on the source could be determined. The lawsuit slowed development of the free-software descendants of BSD for nearly two years while their legal status was in question, and as a result systems based on the Linux kernel , which did not have such legal ambiguity, gained greater support. The lawsuit

2108-410: The basis for Apple's macOS and iOS , is based on 4.4BSD-Lite2 and FreeBSD. Various commercial Unix operating systems, such as Solaris , also incorporate BSD code. Starting with the 8th Edition, versions of Research Unix at Bell Labs had a close relationship to BSD. This began when 4.1cBSD for the VAX was used as the basis for Research Unix 8th Edition. This continued in subsequent versions, such as

2170-422: The basis for several open-source operating systems including FreeBSD, OpenBSD, NetBSD, DragonFly BSD, Darwin and TrueOS . These, in turn, have been used by proprietary operating systems, including Apple 's macOS and iOS , which derived from them and Microsoft Windows (since at least 2000 and XP ), which used (at least) part of its TCP/IP code, which was legal. Code from FreeBSD was also used to create

2232-412: The core of the operating system. Several operating systems are based on BSD, including FreeBSD , OpenBSD , NetBSD , MidnightBSD , MirOS BSD , GhostBSD , Darwin and DragonFly BSD . Both NetBSD and FreeBSD were created in 1993. They were initially derived from 386BSD (also known as "Jolix"), and merged the 4.4BSD-Lite source code in 1994. OpenBSD was forked from NetBSD in 1995, and DragonFly BSD

2294-429: The directory named 'videogames'. A user named 'wozniak', who is also part of the group 'engineers', attempts to delete the file named 'tekken' but he cannot, since he is not the owner. Without sticky bit, 'wozniak' could have deleted the file, because the directory named 'videogames' allows read and write by 'engineers'. A default use of this can be seen at the /tmp folder. 3171 on a directory named 'blog' owned by

2356-509: The first eight bytes of the original message (in this case header of the ICMP echo request, including the quench value), so the ping utility can match responses to originating queries. An ICMP packet transported with IPv4 looks like this. Most Linux systems use a unique Identifier for every ping process, and Sequence Number is an increasing number within that process. Windows uses a fixed Identifier , which varies between Windows versions, and

2418-458: The free 386BSD by William and Lynne Jolitz , and the proprietary BSD/386 (later renamed BSD/OS) by Berkeley Software Design (BSDi). 386BSD itself was short-lived, but became the initial code base of the NetBSD and FreeBSD projects that were started shortly thereafter. BSDi soon found itself in legal trouble with AT&T's Unix System Laboratories (USL) subsidiary, then the owners of

2480-411: The group 'engineers' and the user 'root' A user named 'torvalds' who belongs primarily to the group 'torvalds' but secondarily to the group 'engineers' creates a file or directory named 'thoughts' inside the directory 'blog'. A user named 'wozniak' who also belongs to the group 'engineers' cannot delete, rename, or move the file or directory named 'thoughts', because he is not the owner and the sticky bit

2542-517: The growth of the Internet. Until then, all versions of BSD used proprietary AT&T Unix code, and were therefore subject to an AT&T software license. Source code licenses had become very expensive and several outside parties had expressed interest in a separate release of the networking code, which had been developed entirely outside AT&T and would not be subject to the licensing requirement. This led to Networking Release 1 ( Net/1 ), which

setuid - Misplaced Pages Continue

2604-418: The new directory named 'electronic' inherits 'engineers.' This is the same when making a new file named 'imagine.txt' Without SGID the group ownership of the new directory/file would have been 'torvalds' as that is the primary group of user 'torvalds'. 1770 on a directory named 'videogames' owned by the user 'torvalds' and the group 'engineers'. A user named 'torvalds' creates a file named 'tekken' under

2666-499: The new kernel, ports of the 2BSD utilities to the VAX, and the utilities from 32V was released as 3BSD at the end of 1979. 3BSD was also alternatively called Virtual VAX/UNIX or VMUNIX (for Virtual Memory Unix), and BSD kernel images were normally called /vmunix until 4.4BSD. After 4.3BSD was released in June 1986, it was determined that BSD would move away from the aging VAX platform. The Power 6/32 platform (codenamed "Tahoe") developed by Computer Consoles Inc. seemed promising at

2728-496: The operating systems for the PlayStation 5 , PlayStation 4 , PlayStation 3 , PlayStation Vita , and Nintendo Switch . The earliest distributions of Unix from Bell Labs in the 1970s included the source code to the operating system, allowing researchers at universities to modify and extend Unix. The operating system arrived at Berkeley in 1974, at the request of computer science professor Bob Fabry who had been on

2790-456: The originating host to a destination computer that are echoed back to the source. The name comes from active sonar terminology that sends a pulse of sound and listens for the echo to detect objects under water. Ping operates by means of Internet Control Message Protocol (ICMP) packets . Pinging involves sending an ICMP echo request to the target host and waiting for an ICMP echo reply . The program reports errors, packet loss , and

2852-462: The program committee for the Symposium on Operating Systems Principles where Unix was first presented. A PDP-11/45 was bought to run the system, but for budgetary reasons, this machine was shared with the mathematics and statistics groups at Berkeley, who used RSTS , so that Unix only ran on the machine eight hours per day (sometimes during the day, sometimes during the night). A larger PDP-11/70

2914-470: The raised privilege, although signals from the terminal will still be accepted. While the setuid feature is very useful in many cases, its improper use can pose a security risk if the setuid attribute is assigned to executable programs that are not carefully designed. Due to potential security issues, many operating systems ignore the setuid attribute when applied to executable shell scripts . The presence of setuid executables explains why

2976-685: The requests and time to wait for a response. Many systems provide a companion utility ping6, for testing on Internet Protocol version 6 (IPv6) networks, which implement ICMPv6 . The ping utility was written by Mike Muuss in December 1983 during his employment at the Ballistic Research Laboratory , now the US Army Research Laboratory . A remark by David Mills on using ICMP echo packets for IP network diagnosis and measurements prompted Muuss to create

3038-475: The round-trip time in a stateless manner without needing to record the time of transmission of each packet. The payload may also include a magic packet for the Wake-on-LAN protocol, but the minimum payload, in that case, is longer than shown. The Echo Request typically does not receive any reply if the host was sleeping in hibernation state, but the host still wakes up from sleep state if its interface

3100-413: The same functionality in a software stack with a different architecture, but the wide distribution of the existing sockets library reduced the impact of the new API . Early versions of BSD were used to form Sun Microsystems ' SunOS , founding the first wave of popular Unix workstations. Some BSD operating systems can run native software of several other operating systems on the same architecture , using

3162-540: The time, but was abandoned by its developers shortly thereafter. Nonetheless, the 4.3BSD-Tahoe port (June 1988) proved valuable, as it led to a separation of machine-dependent and machine-independent code in BSD which would improve the system's future portability. In addition to portability, the CSRG worked on an implementation of the OSI network protocol stack, improvements to the kernel virtual memory system and (with Van Jacobson of LBL ) new TCP/IP algorithms to accommodate

SECTION 50

#1732793536752

3224-420: The user 'root'. The owner of the process is not the user running the executable file but the owner of the executable file 2770 on a directory named 'music' owned by the user 'root' and the group 'engineers' A user named 'torvalds' who belongs primarily to the group 'torvalds' but secondarily to the group 'engineers' makes a directory named 'electronic' under the directory named 'music'. The group ownership of

3286-413: The utility to troubleshoot network problems. The author named it after the sound that sonar makes since its methodology is analogous to sonar's echolocation. The backronym Packet InterNet Groper for PING has been used for over 30 years, and although Muuss says that from his point of view, PING was not intended as an acronym, he has acknowledged Mills' expansion of the name. The first released version

3348-465: The values 4 for setuid and 2 for setgid in the high-order octal digit of the file mode. For example, 6711 has both the setuid and setgid bits ( 4 + 2 = 6 ) set, and also the file read/write/executable for the owner (7), and executable by the group (first 1) and others (second 1). Most implementations have a symbolic representation of these bits; in the previous example, this could be u=rwx,go=x,ug+s . Typically, chmod does not have

3410-564: Was public domain software ; all subsequent versions have been licensed under the BSD license . Ping was first included in 4.3BSD . The FreeDOS version was developed by Erick Engelke and is licensed under the GPL . Tim Crawford developed the ReactOS version. It is licensed under the MIT License . Any host must process ICMP echo requests and issue echo replies in return. The following

3472-435: Was at one point vulnerable to an exploit using setuid and an environment variable that allowed executing code from untrusted shared libraries . The setuid bit was invented by Dennis Ritchie and included in su . His employer, then Bell Telephone Laboratories , applied for a patent in 1972; the patent was granted in 1979 as patent number US 4135240   "Protection of data file contents". The patent

3534-469: Was based on the source code of the original Unix developed at Bell Labs . In the 1980s, BSD was widely adopted by workstation vendors in the form of proprietary Unix variants such as DEC Ultrix and Sun Microsystems SunOS due to its permissive licensing and familiarity to many technology company founders and engineers. These proprietary BSD derivatives were largely superseded in the 1990s by UNIX SVR4 and OSF/1 . Later releases of BSD provided

3596-535: Was installed at Berkeley the following year, using money from the Ingres database project. BSD began life as a variant of Unix that programmers at the University of California at Berkeley, initially led by Bill Joy , began developing in the late 1970s. It included extra features, which were intertwined with code owned by AT&T. In 1975, Ken Thompson took a sabbatical from Bell Labs and came to Berkeley as

3658-435: Was later placed in the public domain . Ping (networking utility) ping is a computer network administration software utility used to test the reachability of a host on an Internet Protocol (IP) network. It is available for virtually all operating systems that have networking capability, including most embedded network administration software. Ping measures the round-trip time for messages sent from

3720-400: Was made available to non-licensees of AT&T code and was freely redistributable under the terms of the BSD license . It was released in June 1989. After Net/1, BSD developer Keith Bostic proposed that more non-AT&T sections of the BSD system be released under the same license as Net/1. To this end, he started a project to reimplement most of the standard Unix utilities without using

3782-463: Was released on March 9, 1978. 1BSD was an add-on to Version 6 Unix rather than a complete operating system in its own right. Some thirty copies were sent out. The second Berkeley Software Distribution (2BSD), released in May 1979, included updated versions of the 1BSD software as well as two new programs by Joy that persist on Unix systems to this day: the vi text editor (a visual version of ex ) and

SECTION 60

#1732793536752

3844-614: Was settled in January 1994, largely in Berkeley's favor. Of the 18,000 files in the Berkeley distribution, only three had to be removed and 70 modified to show USL copyright notices. A further condition of the settlement was that USL would not file further lawsuits against users and distributors of the Berkeley-owned code in the upcoming 4.4BSD release. The final release from Berkeley was 1995's 4.4BSD-Lite Release 2 , after which

#751248