1XSECURITY(7)           Miscellaneous Information Manual           XSECURITY(7)
2
3
4

NAME

6       Xsecurity - X display access control
7

OVERVIEW

9       X provides mechanism for implementing many access control systems.  The
10       sample implementation includes five mechanisms:
11           Host Access                   Simple host-based access control.
12           MIT-MAGIC-COOKIE-1            Shared plain-text "cookies".
13           XDM-AUTHORIZATION-1           Secure DES based private-keys.
14           SUN-DES-1                     Based on Sun's secure rpc system.
15           Server Interpreted            Server-dependent methods of access control
16       Not all of these are available in all builds or implementations.
17

ACCESS SYSTEM DESCRIPTIONS

19       Host Access
20              Any client on a host in the host access control list is  allowed
21              access to the X server.  This system can work reasonably well in
22              an environment where everyone trusts everyone, or  when  only  a
23              single  person can log in to a given machine, and is easy to use
24              when the list of hosts used is small.  This system does not work
25              well  when  multiple  people  can log in to a single machine and
26              mutual trust does not exist.   The  list  of  allowed  hosts  is
27              stored  in  the  X server and can be changed with the xhost com‐
28              mand.   The list is stored in the server by network address, not
29              host  names,  so  is not automatically updated if a host changes
30              address while the server is running.  When using the more secure
31              mechanisms listed below, the host list is normally configured to
32              be the empty list, so that only authorized programs can  connect
33              to the display.   See the GRANTING ACCESS section of the Xserver
34              man page for details on how this list is initialized  at  server
35              startup.
36
37       MIT-MAGIC-COOKIE-1
38              When  using  MIT-MAGIC-COOKIE-1,  the  client  sends  a  128 bit
39              "cookie" along with the connection setup  information.   If  the
40              cookie  presented  by  the  client matches one that the X server
41              has, the connection is allowed access.  The cookie is chosen  so
42              that  it  is hard to guess; xdm generates such cookies automati‐
43              cally when this form of access control is used.  The user's copy
44              of  the  cookie is usually stored in the .Xauthority file in the
45              home directory, although the environment variable XAUTHORITY can
46              be  used  to  specify  an alternate location.  Xdm automatically
47              passes a cookie to the server for each new  login  session,  and
48              stores the cookie in the user file at login.
49
50              The  cookie is transmitted on the network without encryption, so
51              there is nothing to prevent a network snooper from obtaining the
52              data  and  using it to gain access to the X server.  This system
53              is useful in an environment where many users are running  appli‐
54              cations  on the same machine and want to avoid interference from
55              each other, with the caveat that this control is only as good as
56              the  access  control  to  the physical network.  In environments
57              where network-level snooping is difficult, this system can  work
58              reasonably well.
59
60       XDM-AUTHORIZATION-1
61              Sites  who  compile  with DES support can use a DES-based access
62              control mechanism called XDM-AUTHORIZATION-1.  It is similar  in
63              usage to MIT-MAGIC-COOKIE-1 in that a key is stored in the .Xau‐
64              thority file and is shared with the X server.  However, this key
65              consists  of two parts - a 56 bit DES encryption key and 64 bits
66              of random data used as the authenticator.
67
68              When connecting to the X server, the application  generates  192
69              bits  of  data  by  combining the current time in seconds (since
70              00:00 1/1/1970 GMT) along with 48  bits  of  "identifier".   For
71              TCP/IPv4  connections,  the  identifier is the address plus port
72              number; for local connections it is the process ID and  32  bits
73              to  form  a  unique id (in case multiple connections to the same
74              server are made from a single process).  This 192 bit packet  is
75              then encrypted using the DES key and sent to the X server, which
76              is able to verify if the requestor is authorized to  connect  by
77              decrypting  with the same DES key and validating the authentica‐
78              tor and additional data.  This system is useful in many environ‐
79              ments where host-based access control is inappropriate and where
80              network security cannot be ensured.
81
82       SUN-DES-1
83              Recent versions of SunOS (and some other systems) have  included
84              a  secure  public key remote procedure call system.  This system
85              is based on the notion of a network principal; a user  name  and
86              NIS  domain  pair.  Using this system, the X server can securely
87              discover the actual user name of  the  requesting  process.   It
88              involves  encrypting data with the X server's public key, and so
89              the identity of the user who started the X server is needed  for
90              this;  this  identity  is  stored  in  the .Xauthority file.  By
91              extending the semantics of "host address" to include this notion
92              of  network  principal, this form of access control is very easy
93              to use.
94
95              To allow access by a new user, use xhost.  For example,
96                  xhost keith@ ruth@mit.edu
97              adds "keith" from the NIS  domain  of  the  local  machine,  and
98              "ruth"  in  the "mit.edu" NIS domain.  For keith or ruth to suc‐
99              cessfully connect to the display, they must  add  the  principal
100              who started the server to their .Xauthority file.  For example:
101                  xauth add expo.lcs.mit.edu:0 SUN-DES-1 unix.expo.lcs.mit.edu@our.domain.edu
102              This system only works on machines which support Secure RPC, and
103              only for users which have set up the appropriate  public/private
104              key pairs on their system.  See the Secure RPC documentation for
105              details.  To access the display from a remote host, you may have
106              to do a keylogin on the remote host first.
107
108       Server Interpreted
109              The  Server  Interpreted  method  provides  two strings to the X
110              server for entry in the access control list.  The  first  string
111              represents the type of entry, and the second string contains the
112              value of the entry.  These strings are interpreted by the server
113              and  different  implementations and builds may support different
114              types of entries.  The types supported in the sample implementa‐
115              tion  are defined in the SERVER INTERPRETED ACCESS TYPES section
116              below.   Entries of this type can be manipulated via xhost.  For
117              example to add a Server Interpreted entry of type localuser with
118              a value of root, the command is xhost +si:localuser:root.
119

THE AUTHORIZATION FILE

121       Except for Host Access control and Server Interpreted  Access  Control,
122       each  of these systems uses data stored in the .Xauthority file to gen‐
123       erate the correct authorization information to  pass  along  to  the  X
124       server at connection setup.  MIT-MAGIC-COOKIE-1 and XDM-AUTHORIZATION-1
125       store secret data in the file; so anyone who can read the file can gain
126       access  to  the  X  server.   SUN-DES-1 stores only the identity of the
127       principal who started the server (unix.hostname@domain when the  server
128       is started by xdm), and so it is not useful to anyone not authorized to
129       connect to the server.
130
131       Each entry in the .Xauthority file matches a certain connection  family
132       (TCP/IP, DECnet or local connections) and X display name (hostname plus
133       display number).  This allows multiple authorization entries  for  dif‐
134       ferent displays to share the same data file.  A special connection fam‐
135       ily (FamilyWild, value 65535) causes an entry to match  every  display,
136       allowing  the  entry  to be used for all connections.  Each entry addi‐
137       tionally contains the authorization name and  whatever  private  autho‐
138       rization data is needed by that authorization type to generate the cor‐
139       rect information at connection setup time.
140
141       The xauth program manipulates the .Xauthority file format.   It  under‐
142       stands  the  semantics  of the connection families and address formats,
143       displaying them in an easy to understand format.  It  also  understands
144       that  SUN-DES-1 uses string values for the authorization data, and dis‐
145       plays them appropriately.
146
147       The X server (when running on a workstation) reads authorization infor‐
148       mation  from  a  file  name  passed  on the command line with the -auth
149       option (see the Xserver manual page).  The authorization entries in the
150       file  are  used to control access to the server.  In each of the autho‐
151       rization schemes listed above, the data needed by the  server  to  ini‐
152       tialize  an authorization scheme is identical to the data needed by the
153       client to generate the appropriate authorization  information,  so  the
154       same  file  can  be  used by both processes.  This is especially useful
155       when xinit is used.
156
157       MIT-MAGIC-COOKIE-1
158              This system uses 128 bits of data shared between  the  user  and
159              the  X  server.  Any collection of bits can be used.  Xdm gener‐
160              ates these keys using a cryptographically secure  pseudo  random
161              number  generator,  and so the key to the next session cannot be
162              computed from the current session key.
163
164       XDM-AUTHORIZATION-1
165              This system uses two pieces of information.  First, 64  bits  of
166              random  data,  second a 56 bit DES encryption key (again, random
167              data) stored in 8 bytes, the last byte of which is ignored.  Xdm
168              generates  these  keys using the same random number generator as
169              is used for MIT-MAGIC-COOKIE-1.
170
171       SUN-DES-1
172              This system needs a string representation of the principal which
173              identifies the associated X server.  This information is used to
174              encrypt the client's authority information when it  is  sent  to
175              the  X  server.   When xdm starts the X server, it uses the root
176              principal for the machine on which  it  is  running  (unix.host‐
177              name@domain,   e.g.,  "unix.expire.lcs.mit.edu@our.domain.edu").
178              Putting the correct  principal  name  in  the  .Xauthority  file
179              causes  Xlib  to generate the appropriate authorization informa‐
180              tion using the secure RPC library.
181

SERVER INTERPRETED ACCESS TYPES

183       The sample implementation includes several  Server  Interpreted  mecha‐
184       nisms:
185           IPv6                          IPv6 literal addresses
186           hostname                      Network host name
187           localuser                     Local connection user id
188           localgroup                    Local connection group id
189
190       IPv6   A  literal  IPv6  address  as  defined  in IETF RFC 3513.   This
191              allows adding IPv6 addresses when the X  server  supports  IPv6,
192              but the xhost client was compiled without IPv6 support.
193
194       hostname
195              The value must be a hostname as defined in IETF RFC 2396. Due to
196              Mobile IP and dynamic DNS, the name service is consulted at con‐
197              nection  authentication time, unlike the traditional host access
198              control list which only contains numeric addresses and does  not
199              automatically  update  when a host's address changes.  Note that
200              this definition of hostname does not allow  use  of  literal  IP
201              addresses.
202
203       localuser & localgroup
204              On  systems  which can determine in a secure fashion the creden‐
205              tials of a client  process,  the  "localuser"  and  "localgroup"
206              authentication  methods  provide  access  based on those creden‐
207              tials.  The format of the values provided is platform  specific.
208              For POSIX & UNIX platforms, if the value starts with the charac‐
209              ter '#', the rest of the string is treated as a decimal  uid  or
210              gid,  otherwise  the  string  is defined as a user name or group
211              name.
212
213              If your system supports this method and you use  it,  be  warned
214              that some programs that proxy connections and are setuid or set‐
215              gid may get authenticated  as  the  uid  or  gid  of  the  proxy
216              process.   For  instance, some versions of ssh will be authenti‐
217              cated as the user root, no matter what user is running  the  ssh
218              client,  so  on  systems  with  such software, adding access for
219              localuser:root may allow wider access than  intended  to  the  X
220              display.
221

FILES

223       .Xauthority
224

SEE ALSO

226       X(7), xdm(1), xauth(1), xhost(1), xinit(1), Xserver(1)
227
228
229
230X Version 11                    xorg-docs 1.7.1                   XSECURITY(7)
Impressum