Host Access | Simple host-based access control. |
MIT-MAGIC-COOKIE-1 | Shared plain-text "cookies". |
XDM-AUTHORIZATION-1 | Secure DES based private-keys. |
SUN-DES-1 | Based on Sun's secure remote procedure call (RPC) system. |
The cookie is transmitted on the network without encryption, so there is nothing to prevent a network snooper from obtaining the data and using it to gain access to the X server. This system is useful in an environment where many users are running applications on the same computer and want to avoid interference from each other, with the caveat that this control is only as good as the access control to the physical network. In environments where network-level snooping is difficult, this system can work reasonably well.
When connecting to the X server, the application generates 192 bits of data by combining the current time in seconds (since 00:00 1/1/1970 GMT) along with 48 bits of "identifier". For TCP/IP connections, the identifier is the address plus port number; for local connections it is the process ID and 32 bits to form a unique id (in case multiple connections to the same server are made from a single process). This 192-bit packet is then encrypted using the DES key and sent to the X server, which is able to verify if the requester is authorized to connect by decrypting with the same DES key and validating the authenticator and additional data. This system is useful in many environments where host-based access control is inappropriate and where network security cannot be ensured.
xhost keith@ joe@mit.edu
adds "keith" from the NIS domain of the local computer, and "joe" in the "mit.edu" NIS domain. For keith or joe to successfully connect to the display, they must add the principal who started the server to their .Xauthority file. For example (line-break inserted for readability):
xauth add expo.lcs.mit.edu:0 SUN-DES-1 \
xinu.expo.lcs.mit.edu:x.lcs.mit.edu
This system only works on computers that support Secure RPC, and
only for users which have set up the appropriate public/private key
pairs on their system. See the Secure RPC documentation for
details.Except for Host Access control, each of these systems uses data stored in the .Xauthority file to generate the correct authorization information to pass along to the X server at connection set-up. MIT-MAGIC-COOKIE-1 and XDM-AUTHORIZATION-1 store secret data in the file; so anyone who can read the file can gain access to the X server. SUN-DES-1 stores only the identity of the principal who started the server (xinu.hostname@domain when the server is started by xdm(1)), and so it is not useful to anyone not authorized to connect to the server.
Each entry in the .Xauthority file matches a certain connection family (TCP/IP, DECnet or local connections) and X display name (hostname plus display number). This allows multiple authorization entries for different displays to share the same data file. A special connection family (FamilyWild, value 65535) causes an entry to match every display, allowing the entry to be used for all connections. Each entry additionally contains the authorization name and whatever private authorization data is needed by that authorization type to generate the correct information at connection set-up time.
The xauth(1) program manipulates the .Xauthority file format. It understands the semantics of the connection families and address formats, displaying them in an easy-to-understand format. It also understands that SUN-DES-1 uses string values for the authorization data, and displays them appropriately.
The X server (when running on a workstation) reads authorization information from a file name passed on the command line with the -auth option (see the Xserver(1) manual page). The authorization entries in the file are used to control access to the server. In each of the authorization schemes listed above, the data needed by the server to initialize an authorization scheme is identical to the data needed by the client to generate the appropriate authorization information, so the same file can be used by both processes. This is especially useful when xinit(1) is used.