1
0

auth.ms 65 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144
  1. .de SS
  2. .NH 2
  3. ..
  4. .EQ
  5. delim $#
  6. .EN
  7. .TL
  8. Security in Plan 9
  9. .AU
  10. Russ Cox, MIT LCS
  11. .br
  12. Eric Grosse, Bell Labs
  13. .br
  14. Rob Pike, Bell Labs
  15. .br
  16. Dave Presotto, Avaya Labs and Bell Labs
  17. .br
  18. Sean Quinlan, Bell Labs
  19. .br
  20. .CW {rsc,ehg,rob,presotto,seanq}@plan9.bell-labs.com
  21. .AB
  22. The security architecture of the Plan 9™
  23. operating system has recently been redesigned
  24. to address some technical shortcomings.
  25. This redesign provided an opportunity also to make the system more
  26. convenient to use securely.
  27. Plan 9 has thus improved in two ways not usually seen together:
  28. it has become more secure
  29. .I and
  30. easier to use.
  31. .LP
  32. The central component of the new architecture is a per-user
  33. self-contained agent called
  34. .CW factotum .
  35. .CW Factotum
  36. securely holds a
  37. copy of the user's keys and negotiates authentication protocols, on
  38. behalf of the user, with secure services around the network.
  39. Concentrating security code in a single program offers several
  40. advantages including: ease of update or repair to broken security
  41. software and protocols; the ability to run secure services at a lower
  42. privilege level; uniform management of keys for all services; and an
  43. opportunity to provide single sign on, even to unchanged legacy
  44. applications.
  45. .CW Factotum
  46. has an unusual architecture: it is implemented
  47. as a Plan 9 file server.
  48. .FS
  49. To appear, in a slightly different form, in
  50. .I
  51. Proc. of the 2002 Usenix Security Symposium,
  52. .R
  53. San Francisco.
  54. .FE
  55. .AE
  56. .NH 1
  57. Introduction
  58. .LP
  59. Secure computing systems face two challenges:
  60. first, they must employ sophisticated technology that is difficult to design
  61. and prove correct; and second,
  62. they must be easy for regular people to use.
  63. The question of ease of use is sometimes neglected, but it is essential:
  64. weak but easy-to-use security can be more effective than strong but
  65. difficult-to-use security if it is more likely to be used.
  66. People lock their front doors when they leave the house, knowing
  67. full well that a burglar is capable of picking the lock (or avoiding
  68. the door altogether); yet few would accept the cost and
  69. awkwardness of a bank vault door on the
  70. house even though that might reduce the probability of a robbery.
  71. A related point is that users need a clear model of how the security
  72. operates (if not how it actually provides security) in order to use it
  73. well; for example, the clarity of a lock icon on a web browser
  74. is offset by the confusing and typically insecure
  75. steps for installing X.509 certificates.
  76. .LP
  77. The security architecture of the Plan 9
  78. operating system
  79. [Pike95]
  80. has recently been redesigned to make it both more secure
  81. and easier to use.
  82. By
  83. .I security
  84. we mean three things:
  85. first, the business of authenticating users and services;
  86. second, the safe handling, deployment, and use of keys
  87. and other secret information; and
  88. third, the use of encryption and integrity checks
  89. to safeguard communications
  90. from prying eyes.
  91. .LP
  92. The old security architecture of Plan 9
  93. had several engineering problems in common with other operating systems.
  94. First, it had an inadequate notion of security domain.
  95. Once a user provided a password to connect to a local file store,
  96. the system required that the same password be used to access all the other file
  97. stores.
  98. That is, the system treated all network services as
  99. belonging to the same security domain.
  100. .LP
  101. Second, the algorithms and protocols used in authentication,
  102. by nature tricky and difficult to get right, were compiled into the
  103. various applications, kernel modules, and file servers.
  104. Changes and fixes to a security protocol
  105. required that all components using that protocol needed to be recompiled,
  106. or at least relinked, and restarted.
  107. .LP
  108. Third, the file transport protocol, 9P
  109. [Pike93],
  110. that forms the core of
  111. the Plan 9 system, had its authentication protocol embedded in its design.
  112. This meant that fixing or changing the authentication used by 9P
  113. required deep changes to the system.
  114. If someone were to find a way to break the protocol, the system would
  115. be wide open and very hard to fix.
  116. .LP
  117. These and a number of lesser problems, combined with a desire
  118. for more widespread use of encryption in the system, spurred us to
  119. rethink the entire security architecture of Plan 9.
  120. .LP
  121. The centerpiece of the new architecture is an agent,
  122. called
  123. .CW factotum ,
  124. that handles the user's keys and negotiates all security
  125. interactions with system services and applications.
  126. Like a trusted assistant with a copy of the owner's keys,
  127. .CW factotum
  128. does all the negotiation for security and authentication.
  129. Programs no longer need to be compiled with cryptographic
  130. code; instead they communicate with
  131. .CW factotum
  132. agents
  133. that represent distinct entities in the cryptographic exchange,
  134. such as a user and server of a secure service.
  135. If a security protocol needs to be added, deleted, or modified,
  136. only
  137. .CW factotum
  138. needs to be updated for all system services
  139. to be kept secure.
  140. .LP
  141. Building on
  142. .CW factotum ,
  143. we modified
  144. secure services in the system to move
  145. user authentication code into
  146. .CW factotum ;
  147. made authentication a separable component of the file server protocol;
  148. deployed new security protocols;
  149. designed a secure file store,
  150. called
  151. .CW secstore ,
  152. to protect our keys but make them easy to get when they are needed;
  153. designed a new kernel module to support transparent use of
  154. Transport Layer Security (TLS)
  155. [RFC2246];
  156. and began using encryption for all communications within the system.
  157. The overall architecture is illustrated in Figure 1a.
  158. .KF
  159. .EQ
  160. gsize 9
  161. .EN
  162. .PS 3i
  163. # Secstore
  164. Sec: box "Secstore" wid 1.3i ht .5i
  165. # Terminal
  166. Term0: box invis ht .1i with .e at Sec.e + (-1.1i, -.5i)
  167. Term: box wid 1.1i ht 1i with .nw at Term0.ne
  168. Termlab: "\s-2Terminal\s+2" at Term.s + (0, -.15i)
  169. FT: ellipse "$ F sub T#" wid .40i ht .30i with .ne at Term.ne + (-.1i, -.1i)
  170. PT: ellipse "$ P sub T#" wid .6i ht .45i with .sw at Term.sw + (.2i, .2i)
  171. # CPU
  172. Cpu0: box invis ht .1i with .w at Term0.w + (3i, 0)
  173. Cpu: box wid 1.1i ht 1i with .nw at Cpu0.ne
  174. Cpulab: "\s-2CPU Server\s+2" at Cpu.s + (0, -.15i)
  175. FC: ellipse "$ F sub C#" wid .40 ht .30i with .nw at Cpu.nw + (.1i, -.1i)
  176. PC: ellipse "$ P sub C#" wid .6i ht .45i with .se at Cpu.se + (-.2i, .2i)
  177. # Authentication Server
  178. Auth: box dashed "Auth Server" wid 1.3i ht .5i with .e at Sec.e + (0, -2.3i)
  179. # File Server
  180. File0: box invis ht .1i with .w at Cpu0.w + (0, -1.5i)
  181. File: box wid 1.1i ht 1i with .nw at File0.ne
  182. Filelab: "\s-2File Server\s+2" at File.s + (0, -.15i)
  183. FF: ellipse "$ F sub F#" wid .40i ht .30i with .nw at File.nw + (.1i, -.1i)
  184. PF: ellipse "$ P sub F#" wid .6i ht .45i with .se at File.se + (-.2i, .2i)
  185. # Connections
  186. line from PT.e + (0, +0.05i) to PC.w + (0, +0.05i)
  187. spline from PT.e + (0, -0.05i) right 1i then down 1.5i right .5i then right to PF.w + (0, -0.05i)
  188. spline from PC.w + (0, -0.05i) left 1.1i then down 1.4i then right to PF.w + (0, 0.05i)
  189. line <-> from FC.se to PC.nw
  190. line <-> from FT.sw to PT.ne
  191. line <-> from FF.se to PF.nw
  192. spline <-> from Sec.e right .5i then down .655i then left to FT.e
  193. #spline from Auth.e + (0, 0.05i) right .5i then up 1i then to FT.se
  194. #spline from Auth.e + (0, 0.00i) right .7i then up 1i then to FC.sw
  195. #spline from Auth.e + (0, -0.05i) right .5i then to FF.w
  196. .PE
  197. .LP
  198. .ps 9
  199. .vs 10
  200. Figure 1a. Components of the security architecture.
  201. Each box is a (typically) separate machine; each ellipse a process.
  202. The ellipses labeled $F sub X#
  203. are
  204. .CW factotum
  205. processes; those labeled
  206. $P sub X#
  207. are the pieces and proxies of a distributed program.
  208. The authentication server is one of several repositories for users' security information
  209. that
  210. .CW factotum
  211. processes consult as required.
  212. .CW Secstore
  213. is a shared resource for storing private information such as keys;
  214. .CW factotum
  215. consults it for the user during bootstrap.
  216. .sp
  217. .KE
  218. .EQ
  219. gsize 11
  220. .EN
  221. .LP
  222. Secure protocols and algorithms are well understood
  223. and are usually not the weakest link in a system's security.
  224. In practice, most security problems arise from buggy servers,
  225. confusing software, or administrative oversights.
  226. It is these practical problems that we are addressing.
  227. Although this paper describes the algorithms and protocols we are using,
  228. they are included mainly for concreteness.
  229. Our main intent is to present a simple security architecture built
  230. upon a small trusted code base that is easy to verify (whether by manual or
  231. automatic means), easy to understand, and easy to use.
  232. .LP
  233. Although it is a subjective assessment,
  234. we believe we have achieved our goal of ease of use.
  235. That we have achieved
  236. our goal of improved security is supported by our plan to
  237. move our currently private computing environment onto the Internet
  238. outside the corporate firewall.
  239. The rest of this paper explains the architecture and how it is used,
  240. to explain why a system that is easy to use securely is also safe
  241. enough to run in the open network.
  242. .NH 1
  243. An Agent for Security
  244. .LP
  245. One of the primary reasons for the redesign of the Plan 9
  246. security infrastructure was to remove the authentication
  247. method both from the applications and from the kernel.
  248. Cryptographic code
  249. is large and intricate, so it should
  250. be packaged as a separate component that can be repaired or
  251. modified without altering or even relinking applications
  252. and services that depend on it.
  253. If a security protocol is broken, it should be trivial to repair,
  254. disable, or replace it on the fly.
  255. Similarly, it should be possible for multiple programs to use
  256. a common security protocol without embedding it in each program.
  257. .LP
  258. Some systems use dynamically linked libraries (DLLs) to address these configuration issues.
  259. The problem with this approach is that it leaves
  260. security code in the same address space as the program using it.
  261. The interactions between the program and the DLL
  262. can therefore accidentally or deliberately violate the interface,
  263. weakening security.
  264. Also, a program using a library to implement secure services
  265. must run at a privilege level necessary to provide the service;
  266. separating the security to a different program makes it possible
  267. to run the services at a weaker privilege level, isolating the
  268. privileged code to a single, more trustworthy component.
  269. .LP
  270. Following the lead of the SSH agent
  271. [Ylon96],
  272. we give each user
  273. an agent process responsible
  274. for holding and using the user's keys.
  275. The agent program is called
  276. .CW factotum
  277. because of its similarity to the proverbial servant with the
  278. power to act on behalf of his master because he holds the
  279. keys to all the master's possessions. It is essential that
  280. .CW factotum
  281. keep the keys secret and use them only in the owner's interest.
  282. Later we'll discuss some changes to the kernel to reduce the possibility of
  283. .CW factotum
  284. leaking information inadvertently.
  285. .LP
  286. .CW Factotum
  287. is implemented, like most Plan 9 services, as a file server.
  288. It is conventionally mounted upon the directory
  289. .CW /mnt/factotum ,
  290. and the files it serves there are analogous to virtual devices that provide access to,
  291. and control of, the services of the
  292. .CW factotum .
  293. The next few sections describe the design of
  294. .CW factotum
  295. and how it operates with the other pieces of Plan 9 to provide
  296. security services.
  297. .SS
  298. Logging in
  299. .LP
  300. To make the discussions that follow more concrete,
  301. we begin with a couple of examples showing how the
  302. Plan 9 security architecture appears to the user.
  303. These examples both involve a user
  304. .CW gre
  305. logging in after booting a local machine.
  306. The user may or may not have a secure store in which
  307. all his keys are kept.
  308. If he does,
  309. .CW factotum
  310. will prompt him for the password to the secure store
  311. and obtain keys from it, prompting only when a key
  312. isn't found in the store.
  313. Otherwise,
  314. .CW factotum
  315. must prompt for each key.
  316. .LP
  317. In the typescripts, \f6\s9\en\s0\fP
  318. represents a literal newline
  319. character typed to force a default response.
  320. User input is in italics, and
  321. long lines are folded and indented to fit.
  322. .LP
  323. This first example shows a user logging in without
  324. help from the secure store.
  325. First,
  326. .CW factotum
  327. prompts for a user name that the local kernel
  328. will use:
  329. .P1
  330. user[none]: \f6\s9gre\s0\fP
  331. .P2
  332. (Default responses appear in square brackets.)
  333. The kernel then starts accessing local resources
  334. and requests, through
  335. .CW factotum ,
  336. a user/password pair to do so:
  337. .P1
  338. !Adding key: dom=cs.bell-labs.com
  339. proto=p9sk1
  340. user[gre]: \f6\s9\en\s0\fP
  341. password: \f6****\fP
  342. .P2
  343. Now the user is logged in to the local system, and
  344. the mail client starts up:
  345. .P1
  346. !Adding key: proto=apop
  347. server=plan9.bell-labs.com
  348. user[gre]: \f6\s9\en\s0\fP
  349. password: \f6****\fP
  350. .P2
  351. .CW Factotum
  352. is doing all the prompting and the applications
  353. being started are not even touching the keys.
  354. Note that it's always clear which key is being requested.
  355. .LP
  356. Now consider the same login sequence, but in the case where
  357. .CW gre
  358. has a secure store account:
  359. .P1
  360. user[none]: \f6\s9gre\s0\fP
  361. secstore password: \f6*********\fP
  362. STA PIN+SecurID: \f6*********\fP
  363. .P2
  364. That's the last
  365. .CW gre
  366. will hear from
  367. .CW factotum
  368. unless an attempt is made to contact
  369. a system for which no key is kept in the secure store.
  370. .SS
  371. The factotum
  372. .LP
  373. Each computer running Plan 9 has one user id that owns all the
  374. resources on that system \(em the scheduler, local disks,
  375. network interfaces, etc.
  376. That user, the
  377. .I "host owner" ,
  378. is the closest analogue in Plan 9 to a Unix
  379. .CW root
  380. account (although it is far weaker;
  381. rather than having special powers, as its name implies the host owner
  382. is just a regular user that happens to own the
  383. resources of the local machine).
  384. On a single-user system, which we call a terminal,
  385. the host owner is the id of the terminal's user.
  386. Shared servers such as CPU servers normally have a pseudo-user
  387. that initially owns all resources.
  388. At boot time, the Plan 9 kernel starts a
  389. .CW factotum
  390. executing as, and therefore with the privileges of,
  391. the host owner.
  392. .LP
  393. New processes run as
  394. the same user as the process which created them.
  395. When a process must take on the identity of a new user,
  396. such as to provide a login shell
  397. on a shared CPU server,
  398. it does so by proving to the host owner's
  399. .CW factotum
  400. that it is
  401. authorized to do so.
  402. This is done by running an
  403. authentication protocol with
  404. .CW factotum
  405. to
  406. prove that the process has access to secret information
  407. which only the new user should possess.
  408. For example, consider the setup in Figure 1a.
  409. If a user on the terminal
  410. wants to log in to the CPU server using the
  411. Plan 9
  412. .CW cpu
  413. service
  414. [Pike93],
  415. then
  416. $P sub T#
  417. might be the
  418. .CW cpu
  419. client program and
  420. $P sub C#
  421. the
  422. .CW cpu
  423. server.
  424. Neither $P sub C# nor $P sub T#
  425. knows the details of the authentication.
  426. They
  427. do need to be able to shuttle messages back and
  428. forth between the two
  429. .CW factotums ,
  430. but this is
  431. a generic function easily performed without
  432. knowing, or being able to extract, secrets in
  433. the messages.
  434. $P sub T#
  435. will make a network connection to $P sub C#.
  436. $P sub T#
  437. and
  438. $P sub C#
  439. will then relay messages between
  440. the
  441. .CW factotum
  442. owned by the user, $F sub T#,
  443. and the one owned by the CPU server, $F sub C#,
  444. until mutual authentication has been established.
  445. Later
  446. sections describe the RPC between
  447. .CW factotum
  448. and
  449. applications and the library functions to support proxy operations.
  450. .LP
  451. The kernel always uses a single local instance of
  452. .CW factotum ,
  453. running as the
  454. host owner, for
  455. its authentication purposes, but
  456. a regular user may start other
  457. .CW factotum
  458. agents.
  459. In fact, the
  460. .CW factotum
  461. representing the user need not be
  462. running on the same machine as its client.
  463. For instance, it is easy for a user on a CPU server,
  464. through standard Plan 9 operations,
  465. to replace the
  466. .CW /mnt/factotum
  467. in the user's private file name space on the server
  468. with a connection to the
  469. .CW factotum
  470. running on the terminal.
  471. (The usual file system permissions prevent interlopers
  472. from doing so maliciously.)
  473. This permits secure operations on the CPU server to be
  474. transparently validated by the user's own
  475. .CW factotum ,
  476. so
  477. secrets need never leave the user's terminal.
  478. The SSH agent
  479. [Ylon96]
  480. does much the
  481. same with special SSH protocol messages, but
  482. an advantage to making our agent a file system
  483. is that we need no new mechanism to access our remote
  484. agent; remote file access is sufficient.
  485. .LP
  486. Within
  487. .CW factotum ,
  488. each protocol is implemented as a state
  489. machine with a generic interface, so protocols are in
  490. essence pluggable modules, easy to add, modify, or drop.
  491. Writing a message to and reading a message from
  492. .CW factotum
  493. each require a separate RPC and result in
  494. a single state transition.
  495. Therefore
  496. .CW factotum
  497. always runs to completion on every RPC and never blocks
  498. waiting for input during any authentication.
  499. Moreover, the number of simultaneous
  500. authentications is limited only by the amount of memory we're
  501. willing to dedicate to representing the state machines.
  502. .LP
  503. Authentication protocols are implemented only
  504. within
  505. .CW factotum ,
  506. but adding and removing
  507. protocols does require relinking the binary, so
  508. .CW factotum
  509. processes (but no others)
  510. need to be restarted in order to take advantage of
  511. new or repaired protocols.
  512. .LP
  513. At the time of writing,
  514. .CW factotum
  515. contains authentication
  516. modules for the Plan 9 shared key protocol (p9sk1),
  517. SSH's RSA authentication, passwords in the clear, APOP, CRAM, PPP's CHAP,
  518. Microsoft PPP's MSCHAP, and VNC's challenge/response.
  519. .SS
  520. Local capabilities
  521. .LP
  522. A capability system, managed by the kernel, is used to empower
  523. .CW factotum
  524. to grant permission to another process to change its user id.
  525. A
  526. kernel device driver
  527. implements two files,
  528. .CW /dev/caphash
  529. and
  530. .CW /dev/capuse .
  531. The write-only file
  532. .CW /dev/caphash
  533. can be opened only by the host owner, and only once.
  534. .CW Factotum
  535. opens this file immediately after booting.
  536. .LP
  537. To use the files,
  538. .CW factotum
  539. creates a string of the form
  540. .I userid1\f(CW@\fPuserid2\f(CW@\fPrandom-string ,
  541. uses SHA1 HMAC to hash
  542. .I userid1\f(CW@\fPuserid2
  543. with key
  544. .I random-string ,
  545. and writes that hash to
  546. .CW /dev/caphash .
  547. .CW Factotum
  548. then passes the original string to another
  549. process on the same machine, running
  550. as user
  551. .I userid1 ,
  552. which
  553. writes the string to
  554. .CW /dev/capuse .
  555. The kernel hashes the string and looks for
  556. a matching hash in its list.
  557. If it finds one,
  558. the writing process's user id changes from
  559. .I userid1
  560. to
  561. .I userid2 .
  562. Once used, or if a timeout expires,
  563. the capability is discarded by the kernel.
  564. .LP
  565. The capabilities are local to the machine on which they are created.
  566. Hence a
  567. .CW factotum
  568. running on one machine cannot pass capabilities
  569. to processes on another and expect them to work.
  570. .SS
  571. Keys
  572. .LP
  573. We define the word
  574. .I key
  575. to mean not only a secret, but also a description of the
  576. context in which that secret is to be used: the protocol,
  577. server, user, etc. to which it applies.
  578. That is,
  579. a key is a combination of secret and descriptive information
  580. used to authenticate the identities of parties
  581. transmitting or receiving information.
  582. The set of keys used
  583. in any authentication depends both on the protocol and on
  584. parameters passed by the program requesting the authentication.
  585. .LP
  586. Taking a tip from SDSI
  587. [RiLa],
  588. which represents security information as textual S-expressions,
  589. keys in Plan 9 are represented as plain UTF-8 text.
  590. Text is easily
  591. understood and manipulated by users.
  592. By contrast,
  593. a binary or other cryptic format
  594. can actually reduce overall security.
  595. Binary formats are difficult for users to examine and can only be
  596. cracked by special tools, themselves poorly understood by most users.
  597. For example, very few people know or understand what's inside
  598. their X.509 certificates.
  599. Most don't even know where in the system to
  600. find them.
  601. Therefore, they have no idea what they are trusting, and why, and
  602. are powerless to change their trust relationships.
  603. Textual, centrally stored and managed keys are easier to use and safer.
  604. .LP
  605. Plan 9 has historically represented databases as attribute/value pairs,
  606. since they are a good foundation for selection and projection operations.
  607. .CW Factotum
  608. therefore represents
  609. the keys in the format
  610. .I attribute\f(CW=\fPvalue ,
  611. where
  612. .I attribute
  613. is an identifier, possibly with a single-character prefix, and
  614. .I value
  615. is an arbitrary quoted string.
  616. The pairs themselves are separated by white space.
  617. For example, a Plan 9 key and an APOP key
  618. might be represented like this:
  619. .P1
  620. dom=bell-labs.com proto=p9sk1 user=gre
  621. !password='don''t tell'
  622. proto=apop server=x.y.com user=gre
  623. !password='open sesame'
  624. .P2
  625. If a value is empty or contains white space or single quotes, it must be quoted;
  626. quotes are represented by doubled single quotes.
  627. Attributes that begin with an exclamation mark
  628. .CW ! ) (
  629. are considered
  630. .I secret .
  631. .CW Factotum
  632. will never let a secret value escape its address space
  633. and will suppress keyboard echo when asking the user to type one.
  634. .LP
  635. A program requesting authentication selects a key
  636. by providing a
  637. .I query ,
  638. a list of elements to be matched by the key.
  639. Each element in the list is either an
  640. .I attribute\f(CW=\fPvalue
  641. pair, which is satisfied by keys with
  642. exactly that pair;
  643. or an attribute followed by a question mark,
  644. .I attribute\f(CW? ,
  645. which is satisfied by keys with some pair specifying
  646. the attribute.
  647. A key matches a query if every element in the list
  648. is satisfied.
  649. For instance, to select the APOP key in the previous example,
  650. an APOP client process might specify the query
  651. .P1
  652. server=x.y.com proto=apop
  653. .P2
  654. Internally,
  655. .CW factotum 's
  656. APOP module would add the requirements of
  657. having
  658. .CW user
  659. and
  660. .CW !password
  661. attributes, forming the query
  662. .P1
  663. server=x.y.com proto=apop user? !password?
  664. .P2
  665. when searching for an appropriate key.
  666. .LP
  667. .CW Factotum
  668. modules expect keys to have some well-known attributes.
  669. For instance, the
  670. .CW proto
  671. attribute specifies the protocol module
  672. responsible for using a particular key,
  673. and protocol modules may expect other well-known attributes
  674. (many expect keys to have
  675. .CW !password
  676. attributes, for example).
  677. Additional attributes can be used as comments or for
  678. further discrimination without intervention by
  679. .CW factotum ;
  680. for example, the APOP and IMAP mail clients conventionally
  681. include a
  682. .CW server
  683. attribute to select an appropriate key for authentication.
  684. .LP
  685. Unlike in SDSI,
  686. keys in Plan 9 have no nested structure. This design
  687. keeps the representation simple and straightforward.
  688. If necessary, we could add a nested attribute
  689. or, in the manner of relational databases, an attribute that
  690. selects another tuple, but so far the simple design has been sufficient.
  691. .LP
  692. A simple common structure for all keys makes them easy for users
  693. to administer,
  694. but the set of attributes and their interpretation is still
  695. protocol-specific and can be subtle.
  696. Users may still
  697. need to consult a manual to understand all details.
  698. Many attributes
  699. .CW proto , (
  700. .CW user ,
  701. .CW password ,
  702. .CW server )
  703. are self-explanatory and our short experience
  704. has not uncovered any particular difficulty in handling keys.
  705. Things
  706. will likely get messier, however,
  707. when we grapple with public
  708. keys and their myriad components.
  709. .SS
  710. Protecting keys
  711. .LP
  712. Secrets must be prevented from escaping
  713. .CW factotum .
  714. There are a number of ways they could leak:
  715. another process might be able to debug the agent process, the
  716. agent might swap out to disk, or the process might willingly
  717. disclose the key.
  718. The last is the easiest to avoid:
  719. secret information in a key is marked
  720. as such, and
  721. whenever
  722. .CW factotum
  723. prints keys or queries for new
  724. ones, it is careful to avoid displaying secret information.
  725. (The only exception to this is the
  726. ``plaintext password'' protocol, which consists
  727. of sending the values of the
  728. .CW user
  729. and
  730. .CW !password
  731. attributes.
  732. Only keys tagged with
  733. .CW proto=pass
  734. can have their passwords disclosed by this mechanism.)
  735. .LP
  736. Preventing the first two forms of leakage
  737. requires help from the kernel.
  738. In Plan 9, every process is
  739. represented by a directory in the
  740. .CW /proc
  741. file system.
  742. Using the files in this directory,
  743. other processes could (with appropriate access permission) examine
  744. .CW factotum 's
  745. memory and registers.
  746. .CW Factotum
  747. is protected from processes of other users
  748. by the default access bits of its
  749. .CW /proc
  750. directory.
  751. However, we'd also like to protect the
  752. agent from other processes owned by the same user,
  753. both to avoid honest mistakes and to prevent
  754. an unattended terminal being
  755. exploited to discover secret passwords.
  756. To do this, we added a control message to
  757. .CW /proc
  758. called
  759. .CW private .
  760. Once the
  761. .CW factotum
  762. process has written
  763. .CW private
  764. to its
  765. .CW /proc/\f2pid\fP/ctl
  766. file, no process can access
  767. .CW factotum 's
  768. memory
  769. through
  770. .CW /proc .
  771. (Plan 9 has no other mechanism, such as
  772. .CW /dev/kmem ,
  773. for accessing a process's memory.)
  774. .LP
  775. Similarly, the agent's address space should not be
  776. swapped out, to prevent discovering unencrypted
  777. keys on the swapping media.
  778. The
  779. .CW noswap
  780. control message in
  781. .CW /proc
  782. prevents this scenario.
  783. Neither
  784. .CW private
  785. nor
  786. .CW noswap
  787. is specific to
  788. .CW factotum .
  789. User-level file servers such as
  790. .CW dossrv ,
  791. which interprets FAT file systems,
  792. could use
  793. .CW noswap
  794. to keep their buffer caches from being
  795. swapped to disk.
  796. .LP
  797. Despite our precautions, attackers might still
  798. find a way to gain access to a process running as the host
  799. owner on a machine.
  800. Although they could not directly
  801. access the keys, attackers could use the local
  802. .CW factotum
  803. to perform authentications for them.
  804. In the case
  805. of some keys, for example those locking bank
  806. accounts, we want a way to disable or at least
  807. detect such access.
  808. That is the role of the
  809. .CW confirm
  810. attribute in a key.
  811. Whenever a key with a
  812. .CW confirm
  813. attribute is accessed, the local user must
  814. confirm use of the key via a local GUI.
  815. The next section describes the actual mechanism.
  816. .LP
  817. We have not addressed leaks possible as a result of
  818. someone rebooting or resetting a machine running
  819. .CW factotum .
  820. For example, someone could reset a machine
  821. and reboot it with a debugger instead of a kernel,
  822. allowing them to examine the contents of memory
  823. and find keys. We have not found a satisfactory
  824. solution to this problem.
  825. .SS
  826. Factotum transactions
  827. .LP
  828. External programs manage
  829. .CW factotum 's
  830. internal key state
  831. through its file interface,
  832. writing textual
  833. .CW key
  834. and
  835. .CW delkey
  836. commands to the
  837. .CW /mnt/factotum/ctl
  838. file.
  839. Both commands take a list of attributes as an argument.
  840. .CW Key
  841. creates a key with the given attributes, replacing any
  842. extant key with an identical set of public attributes.
  843. .CW Delkey
  844. deletes all keys that match the given set of attributes.
  845. Reading the
  846. .CW ctl
  847. file returns a list of keys, one per line, displaying only public attributes.
  848. The following example illustrates these interactions.
  849. .P1
  850. % cd /mnt/factotum
  851. % ls -l
  852. -lrw------- gre gre 0 Jan 30 22:17 confirm
  853. --rw------- gre gre 0 Jan 30 22:17 ctl
  854. -lr-------- gre gre 0 Jan 30 22:17 log
  855. -lrw------- gre gre 0 Jan 30 22:17 needkey
  856. --r--r--r-- gre gre 0 Jan 30 22:17 proto
  857. --rw-rw-rw- gre gre 0 Jan 30 22:17 rpc
  858. % cat >ctl
  859. key dom=bell-labs.com proto=p9sk1 user=gre
  860. !password='don''t tell'
  861. key proto=apop server=x.y.com user=gre
  862. !password='bite me'
  863. ^D
  864. % cat ctl
  865. key dom=bell-labs.com proto=p9sk1 user=gre
  866. key proto=apop server=x.y.com user=gre
  867. % echo 'delkey proto=apop' >ctl
  868. % cat ctl
  869. key dom=bell-labs.com proto=p9sk1 user=gre
  870. %
  871. .P2
  872. (A file with the
  873. .CW l
  874. bit set can be opened by only one process at a time.)
  875. .LP
  876. The heart of the interface is the
  877. .CW rpc
  878. file.
  879. Programs authenticate with
  880. .CW factotum
  881. by writing a request to the
  882. .CW rpc
  883. file
  884. and reading back the reply; this sequence is called an RPC
  885. .I transaction .
  886. Requests and replies have the same format:
  887. a textual verb possibly followed by arguments,
  888. which may be textual or binary.
  889. The most common reply verb is
  890. .CW ok ,
  891. indicating success.
  892. An RPC session begins with a
  893. .CW start
  894. transaction; the argument is a key query as described
  895. earlier.
  896. Once started, an RPC conversation usually consists of
  897. a sequence of
  898. .CW read
  899. and
  900. .CW write
  901. transactions.
  902. If the conversation is successful, an
  903. .CW authinfo
  904. transaction will return information about
  905. the identities learned during the transaction.
  906. The
  907. .CW attr
  908. transaction returns a list of attributes for the current
  909. conversation; the list includes any attributes given in
  910. the
  911. .CW start
  912. query as well as any public attributes from keys being used.
  913. .LP
  914. As an example of the
  915. .CW rpc
  916. file in action, consider a mail client
  917. connecting to a mail server and authenticating using
  918. the POP3 protocol's APOP challenge-response command.
  919. There are four programs involved: the mail client $P sub C#, the client
  920. .CW factotum
  921. $F sub C#, the mail server $P sub S#, and the server
  922. .CW factotum
  923. $F sub S#.
  924. All authentication computations are handled by the
  925. .CW factotum
  926. processes.
  927. The mail programs' role is just to relay messages.
  928. .LP
  929. At startup, the mail server at
  930. .CW x.y.com
  931. begins an APOP conversation
  932. with its
  933. .CW factotum
  934. to obtain the banner greeting, which
  935. includes a challenge:
  936. .P1
  937. $P sub S -> F sub S#: start proto=apop role=server
  938. $F sub S -> P sub S#: ok
  939. $P sub S -> F sub S#: read
  940. $F sub S -> P sub S#: ok +OK POP3 \f2challenge\fP
  941. .P2
  942. Having obtained the challenge, the server greets the client:
  943. .P1
  944. $P sub S -> P sub C#: +OK POP3 \f2challenge\fP
  945. .P2
  946. The client then uses an APOP conversation with its
  947. .CW factotum
  948. to obtain a response:
  949. .P1
  950. $P sub C -> F sub C#: start proto=apop role=client
  951. server=x.y.com
  952. $F sub C -> P sub C#: ok
  953. $P sub C -> F sub C#: write +OK POP3 \f2challenge\fP
  954. $F sub C -> P sub C#: ok
  955. $P sub C -> F sub C#: read
  956. $F sub C -> P sub C#: ok APOP gre \f2response\fP
  957. .P2
  958. .CW Factotum
  959. requires that
  960. .CW start
  961. requests include a
  962. .CW proto
  963. attribute, and the APOP module requires an additional
  964. .CW role
  965. attribute, but the other attributes are optional and only
  966. restrict the key space.
  967. Before responding to the
  968. .CW start
  969. transaction, the client
  970. .CW factotum
  971. looks for a key to
  972. use for the rest of the conversation.
  973. Because of the arguments in the
  974. .CW start
  975. request, the key must have public attributes
  976. .CW proto=apop
  977. and
  978. .CW server=x.y.com ;
  979. as mentioned earlier,
  980. the APOP module additionally requires that the key have
  981. .CW user
  982. and
  983. .CW !password
  984. attributes.
  985. Now that the client has obtained a response
  986. from its
  987. .CW factotum ,
  988. it echoes that response to the server:
  989. .P1
  990. $P sub C -> P sub S#: APOP gre \f2response\fP
  991. .P2
  992. Similarly, the server passes this message to
  993. its
  994. .CW factotum
  995. and obtains another to send back.
  996. .P1
  997. $P sub S -> F sub S#: write APOP gre \f2response\fP
  998. $F sub S -> P sub S#: ok
  999. $P sub S -> F sub S#: read
  1000. $F sub S -> P sub S#: ok +OK welcome
  1001. $P sub S -> P sub C#: +OK welcome
  1002. .P2
  1003. Now the authentication protocol is done, and
  1004. the server can retrieve information
  1005. about what the protocol established.
  1006. .P1
  1007. $P sub S -> F sub S#: authinfo
  1008. $F sub S -> P sub S#: ok client=gre
  1009. capability=\f2capability\fP
  1010. .P2
  1011. The
  1012. .CW authinfo
  1013. data is a list of
  1014. .I attr\f(CW=\fPvalue
  1015. pairs, here a client user name and a capability.
  1016. (Protocols that establish shared secrets or provide
  1017. mutual authentication indicate this by adding
  1018. appropriate
  1019. .I attr\f(CW=\fPvalue
  1020. pairs.)
  1021. The capability can be used by the server to change its
  1022. identity to that of the client, as described earlier.
  1023. Once it has changed its identity, the server can access and serve
  1024. the client's mailbox.
  1025. .LP
  1026. Two more files provide hooks for a graphical
  1027. .CW factotum
  1028. control interface.
  1029. The first,
  1030. .CW confirm ,
  1031. allows the user detailed control over the use of certain keys.
  1032. If a key has a
  1033. .CW confirm=
  1034. attribute, then the user must approve each use of the key.
  1035. A separate program with a graphical interface reads from the
  1036. .CW confirm
  1037. file to see when a confirmation is necessary.
  1038. The read blocks until a key usage needs to be approved, whereupon
  1039. it will return a line of the form
  1040. .P1
  1041. confirm tag=1 \f2attributes\fP
  1042. .P2
  1043. requesting permission to use the key with those public attributes.
  1044. The graphical interface then prompts the user for approval
  1045. and writes back
  1046. .P1
  1047. tag=1 answer=yes
  1048. .P2
  1049. (or
  1050. .CW answer=no ).
  1051. .LP
  1052. The second file,
  1053. .CW needkey ,
  1054. diverts key requests.
  1055. In the APOP example, if a suitable key had not been found
  1056. during the
  1057. .CW start
  1058. transaction,
  1059. .CW factotum
  1060. would have indicated failure by
  1061. returning a response indicating
  1062. what key was needed:
  1063. .P1
  1064. $F sub C -> P sub C#: needkey proto=apop
  1065. server=x.y.com user? !password?
  1066. .P2
  1067. A typical client would then prompt the user for the desired
  1068. key information, create a new key via the
  1069. .CW ctl
  1070. file, and then reissue the
  1071. .CW start
  1072. request.
  1073. If the
  1074. .CW needkey
  1075. file is open,
  1076. then instead of failing, the transaction
  1077. will block, and the next read from the
  1078. .CW /mnt/factotum/needkey
  1079. file will return a line of the form
  1080. .P1
  1081. needkey tag=1 \f2attributes\f2
  1082. .P2
  1083. The graphical interface then prompts the user for the needed
  1084. key information, creates the key via the
  1085. .CW ctl
  1086. file, and writes back
  1087. .CW tag=1
  1088. to resume the transaction.
  1089. .LP
  1090. The remaining files are informational and used for debugging.
  1091. The
  1092. .CW proto
  1093. file contains a list of supported protocols (to see what protocols the
  1094. system supports,
  1095. .CW cat
  1096. .CW /mnt/factotum/proto ),
  1097. and the
  1098. .CW log
  1099. file contains a log of operations and debugging output
  1100. enabled by a
  1101. .CW debug
  1102. control message.
  1103. .LP
  1104. The next few sections explain how
  1105. .CW factotum
  1106. is used by system services.
  1107. .NH 1
  1108. Authentication in 9P
  1109. .LP
  1110. Plan 9 uses a remote file access protocol, 9P
  1111. [Pike93],
  1112. to connect to resources such as the
  1113. file server and remote processes.
  1114. The original design for 9P included special messages at the start of a conversation
  1115. to authenticate the user.
  1116. Multiple users can share a single connection, such as when a CPU server
  1117. runs processes for many users connected to a single file server,
  1118. but each must authenticate separately.
  1119. The authentication protocol, similar to that of Kerberos
  1120. [Stei88],
  1121. used a sequence of messages passed between client, file server, and authentication
  1122. server to verify the identities of the user, calling machine, and serving machine.
  1123. One major drawback to the design was that the authentication method was defined by 9P
  1124. itself and could not be changed.
  1125. Moreover, there was no mechanism to relegate
  1126. authentication to an external (trusted) agent,
  1127. so a process implementing 9P needed, besides support for file service,
  1128. a substantial body of cryptographic code to implement a handful of startup messages
  1129. in the protocol.
  1130. .LP
  1131. A recent redesign of 9P
  1132. addressed a number of file service issues outside the scope of this paper.
  1133. On issues of authentication, there were two goals:
  1134. first, to remove details about authentication from the
  1135. protocol itself; second, to allow an external program to execute the authentication
  1136. part of the protocol.
  1137. In particular, we wanted a way to quickly incorporate
  1138. ideas found in other systems such as SFS
  1139. [Mazi99].
  1140. .LP
  1141. Since 9P is a file service protocol, the solution involved creating a new type of file
  1142. to be served: an
  1143. .I authentication
  1144. .I file .
  1145. Connections to a 9P service begin in a state that
  1146. allows no general file access but permits the client
  1147. to open an authentication file
  1148. by sending a special message, generated by the new
  1149. .CW fauth
  1150. system call:
  1151. .P1
  1152. afd = fauth(int fd, char *servicename);
  1153. .P2
  1154. Here
  1155. .CW fd
  1156. is the user's file descriptor for the established network connection to the 9P server
  1157. and
  1158. .CW servicename
  1159. is the name of the desired service offered on that server, typically the file subsystem
  1160. to be accessed.
  1161. The returned file descriptor,
  1162. .CW afd ,
  1163. is a unique handle representing the authentication file
  1164. created for this connection to authenticate to
  1165. this service; it is analogous to a capability.
  1166. The authentication file represented by
  1167. .CW afd
  1168. is not otherwise addressable on the server, such as through
  1169. the file name hierarchy.
  1170. In all other respects, it behaves like a regular file;
  1171. most important, it accepts standard read and write operations.
  1172. .LP
  1173. To prove its identity, the user process (via
  1174. .CW factotum )
  1175. executes the authentication protocol,
  1176. described in the next section of this paper,
  1177. over the
  1178. .CW afd
  1179. file descriptor with ordinary reads and writes.
  1180. When client and server have successfully negotiated, the authentication file
  1181. changes state so it can be used as evidence of authority in
  1182. .CW mount .
  1183. .LP
  1184. Once identity is established, the process presents the (now verified)
  1185. .CW afd
  1186. as proof of identity to the
  1187. .CW mount
  1188. system call:
  1189. .P1
  1190. mount(int fd, int afd, char *mountpoint,
  1191. int flag, char *servicename)
  1192. .P2
  1193. If the
  1194. .CW mount
  1195. succeeds, the user now
  1196. has appropriate permissions for the file hierarchy made
  1197. visible at the mount point.
  1198. .LP
  1199. This sequence of events has several advantages.
  1200. First, the actual authentication protocol is implemented using regular reads and writes,
  1201. not special 9P messages, so
  1202. they can be processed, forwarded, proxied, and so on by
  1203. any 9P agent without special arrangement.
  1204. Second, the business of negotiating the authentication by reading and writing the
  1205. authentication file can be delegated to an outside agent, in particular
  1206. .CW factotum ;
  1207. the programs that implement the client and server ends of a 9P conversation need
  1208. no authentication or cryptographic code.
  1209. Third,
  1210. since the authentication protocol is not defined by 9P itself, it is easy to change and
  1211. can even be negotiated dynamically.
  1212. Finally, since
  1213. .CW afd
  1214. acts like a capability, it can be treated like one:
  1215. handed to another process to give it special permissions;
  1216. kept around for later use when authentication is again required;
  1217. or closed to make sure no other process can use it.
  1218. .LP
  1219. All these advantages stem from moving the authentication negotiation into
  1220. reads and writes on a separate file.
  1221. As is often the case in Plan 9,
  1222. making a resource (here authentication) accessible with a file-like interface
  1223. reduces
  1224. .I a
  1225. .I priori
  1226. the need for special interfaces.
  1227. .LP
  1228. .SS
  1229. Plan 9 shared key protocol
  1230. .LP
  1231. In addition to the various standard protocols supported by
  1232. .CW factotum ,
  1233. we use a shared key protocol for native
  1234. Plan 9 authentication.
  1235. This protocol provides backward compatibility with
  1236. older versions of the system. One reason for the new
  1237. architecture is to let us replace such protocols
  1238. in the near future with more cryptographically secure ones.
  1239. .LP
  1240. .I P9sk1
  1241. is a shared key protocol that uses tickets much like those
  1242. in the original Kerberos.
  1243. The difference is that we've
  1244. replaced the expiration time in Kerberos tickets with
  1245. a random nonce parameter and a counter.
  1246. We summarize it here:
  1247. .P1
  1248. $C -> S: ~~ "nonce" sub C#
  1249. $S -> C: ~~ "nonce" sub S , "uid" sub S , "domain" sub S#
  1250. $C -> A: ~~ "nonce" sub S , "uid" sub S , "domain" sub S , "uid" sub C ,#
  1251. $"factotum" sub C#
  1252. $A -> C: ~~ K sub C roman "{" "nonce" sub S , "uid" sub C , "uid" sub S, K sub n roman "}",#
  1253. $K sub S roman "{" "nonce" sub S , "uid" sub C , "uid" sub S, K sub n roman "}"#
  1254. $C -> S: ~~ K sub S roman "{" "nonce" sub S , "uid" sub C , "uid" sub S , K sub n roman "}",#
  1255. $K sub n roman "{" "nonce" sub S , "counter" roman "}"#
  1256. $S -> C: ~~ K sub n roman "{" "nonce" sub C , "counter" roman "}"#
  1257. .P2
  1258. (Here $K roman "{" x roman "}"# indicates $x# encrypted with
  1259. DES key $K#.)
  1260. The first two messages exchange nonces and server identification.
  1261. After this initial exchange, the client contacts the authentication
  1262. server to obtain a pair of encrypted tickets, one encrypted with
  1263. the client key and one with the server key.
  1264. The client relays the server ticket to the server.
  1265. The server believes that the ticket is new
  1266. because it contains
  1267. $"nonce" sub S#
  1268. and that the ticket is from the authentication
  1269. server because it is encrypted in the server key $K sub S#.
  1270. The ticket is basically a statement from the authentication
  1271. server that now $"uid" sub C# and $"uid" sub S# share a
  1272. secret $K sub n#.
  1273. The authenticator $K sub n roman "{" "nonce" sub S , "counter" roman "}"#
  1274. convinces the server that the client knows $K sub n# and thus
  1275. must be $"uid" sub C#.
  1276. Similarly, authenticator $K sub n roman "{" "nonce" sub C , "counter" roman "}"#
  1277. convinces the client that the server knows $K sub n# and thus
  1278. must be $"uid" sub S#.
  1279. Tickets can be reused, without contacting the authentication
  1280. server again, by incrementing the counter before each
  1281. authenticator is generated.
  1282. .LP
  1283. In the future we hope to introduce a public key version of
  1284. p9sk1,
  1285. which would allow authentication even
  1286. when the authentication server is not available.
  1287. .SS
  1288. The authentication server
  1289. .LP
  1290. Each Plan 9 security domain has an authentication server (AS)
  1291. that all users trust to keep the complete set of shared keys.
  1292. It also offers services for users and administrators to manage the
  1293. keys, create and disable accounts, and so on.
  1294. It typically runs on
  1295. a standalone machine with few other services.
  1296. The AS comprises two services,
  1297. .CW keyfs
  1298. and
  1299. .CW authsrv .
  1300. .LP
  1301. .CW Keyfs
  1302. is a user-level file system that manages an
  1303. encrypted database of user accounts.
  1304. Each account is represented by a directory containing the
  1305. files
  1306. .CW key ,
  1307. containing the Plan 9 key for p9sk1;
  1308. .CW secret
  1309. for the challenge/response protocols (APOP, VNC, CHAP, MSCHAP,
  1310. CRAM);
  1311. .CW log
  1312. for authentication outcomes;
  1313. .CW expire
  1314. for an expiration time; and
  1315. .CW status .
  1316. If the expiration time passes,
  1317. if the number of successive failed authentications
  1318. exceeds 50, or if
  1319. .CW disabled
  1320. is written to the status file,
  1321. any attempt to access the
  1322. .CW key
  1323. or
  1324. .CW secret
  1325. files will fail.
  1326. .LP
  1327. .CW Authsrv
  1328. is a network service that brokers shared key authentications
  1329. for the protocols p9sk1, APOP, VNC, CHAP, MSCHAP,
  1330. and CRAM. Remote users can also call
  1331. .CW authsrv
  1332. to change their passwords.
  1333. .LP
  1334. The
  1335. p9sk1
  1336. protocol was described in the previous
  1337. section.
  1338. The challenge/response protocols differ
  1339. in detail but all follow the general structure:
  1340. .P1
  1341. $C -> S: ~~ "nonce" sub C#
  1342. $S -> C: ~~ "nonce" sub S , "uid" sub S ,"domain" sub S#
  1343. $C -> A: ~~ "nonce" sub S , "uid" sub S , "domain" sub S ,#
  1344. $"hostid" sub C , "uid" sub C#
  1345. $A -> C: ~~ K sub C roman "{" "nonce" sub S , "uid" sub C , "uid" sub S, K sub n roman "}",#
  1346. $K sub S roman "{" "nonce" sub S , "uid" sub C , "uid" sub S, K sub n roman "}"#
  1347. $C -> S: ~~ K sub S roman "{" "nonce" sub S , "uid" sub C , "uid" sub S, K sub n roman "}",#
  1348. $K sub n roman "{" "nonce" sub S roman "}"#
  1349. $S -> C: ~~ K sub n roman "{" "nonce" sub C roman "}"#
  1350. .P2
  1351. The password protocol is:
  1352. .P1
  1353. $C -> A: ~~ "uid" sub C#
  1354. $A -> C: ~~ K sub c roman "{" K sub n roman "}"#
  1355. $C -> A: ~~ K sub n roman "{" "password" sub "old" , "password" sub "new" roman "}"#
  1356. $A -> C: ~~ OK#
  1357. .P2
  1358. To avoid replay attacks, the pre-encryption
  1359. clear text for each of the protocols (as well as for p9sk1) includes
  1360. a tag indicating the encryption's role in the
  1361. protocol. We elided them in these outlines.
  1362. .SS
  1363. Protocol negotiation
  1364. .LP
  1365. Rather than require particular protocols for particular services,
  1366. we implemented a negotiation metaprotocol,
  1367. .I p9any ,
  1368. which chooses the actual authentication protocol to use.
  1369. P9any
  1370. is used now by all native services on Plan 9.
  1371. .LP
  1372. The metaprotocol is simple. The callee sends a
  1373. null-terminated string of the form:
  1374. .P1
  1375. v.$n# $proto sub 1#@$domain sub 1# $proto sub 2#@$domain sub 2# ...
  1376. .P2
  1377. where
  1378. .I n
  1379. is a decimal version number, $proto sub k#
  1380. is the name of a protocol for which the
  1381. .CW factotum
  1382. has a key, and $domain sub k#
  1383. is the name of the domain in which the key is
  1384. valid.
  1385. The caller then responds
  1386. .P1
  1387. \f2proto\fP@\f2domain\fP
  1388. .P2
  1389. indicating its choice.
  1390. Finally the callee responds
  1391. .P1
  1392. OK
  1393. .P2
  1394. Any other string indicates failure.
  1395. At this point the chosen protocol commences.
  1396. The final fixed-length reply is used to make it easy to
  1397. delimit the I/O stream should the chosen protocol
  1398. require the caller rather than the callee to send the first message.
  1399. .LP
  1400. With this negotiation metaprotocol, the underlying
  1401. authentication protocols used for Plan 9 services
  1402. can be changed under any application just
  1403. by changing the keys known by the
  1404. .CW factotum
  1405. agents at each end.
  1406. .LP
  1407. P9any is vulnerable to man in the middle attacks
  1408. to the extent that the attacker may constrain the
  1409. possible choices by changing the stream. However,
  1410. we believe this is acceptable since the attacker
  1411. cannot force either side to choose algorithms
  1412. that it is unwilling to use.
  1413. .NH 1
  1414. Library Interface to Factotum
  1415. .LP
  1416. Although programs can access
  1417. .CW factotum 's
  1418. services through its file system interface,
  1419. it is more common to use a C library that
  1420. packages the interaction.
  1421. There are a number of routines in the library,
  1422. not all of which are relevant here, but a few
  1423. examples should give their flavor.
  1424. .LP
  1425. First, consider the problem of mounting a remote file server using 9P.
  1426. An earlier discussion showed how the
  1427. .CW fauth
  1428. and
  1429. .CW mount
  1430. system calls use an authentication file,
  1431. .CW afd ,
  1432. as a capability,
  1433. but not how
  1434. .CW factotum
  1435. manages
  1436. .CW afd .
  1437. The library contains a routine,
  1438. .CW amount
  1439. (authenticated mount), that is used by most programs in preference to
  1440. the raw
  1441. .CW fauth
  1442. and
  1443. .CW mount
  1444. calls.
  1445. .CW Amount
  1446. engages
  1447. .CW factotum
  1448. to validate
  1449. .CW afd ;
  1450. here is the complete code:
  1451. .P1
  1452. .ta 3n +3n +3n +3n
  1453. int
  1454. amount(int fd, char *mntpt,
  1455. int flags, char *aname)
  1456. {
  1457. int afd, ret;
  1458. AuthInfo *ai;
  1459. afd = fauth(fd, aname);
  1460. if(afd >= 0){
  1461. ai = auth_proxy(afd, amount_getkey,
  1462. "proto=p9any role=client");
  1463. if(ai != NULL)
  1464. auth_freeAI(ai);
  1465. }
  1466. ret = mount(fd, afd, mntpt,
  1467. flags, aname);
  1468. if(afd >= 0)
  1469. close(afd);
  1470. return ret;
  1471. }
  1472. .P2
  1473. where parameter
  1474. .CW fd
  1475. is a file descriptor returned by
  1476. .CW open
  1477. or
  1478. .CW dial
  1479. for a new connection to a file server.
  1480. The conversation with
  1481. .CW factotum
  1482. occurs in the call to
  1483. .CW auth_proxy ,
  1484. which specifies, as a key query,
  1485. which authentication protocol to use
  1486. (here the metaprotocol
  1487. .CW p9any )
  1488. and the role being played
  1489. .CW client ). (
  1490. .CW Auth_proxy
  1491. will read and write the
  1492. .CW factotum
  1493. files, and the authentication file descriptor
  1494. .CW afd ,
  1495. to validate the user's right to access the service.
  1496. If the call is successful, any auxiliary data, held in an
  1497. .CW AuthInfo
  1498. structure, is freed.
  1499. In any case, the
  1500. .CW mount
  1501. is then called with the (perhaps validated)
  1502. .CW afd.
  1503. A 9P server can cause the
  1504. .CW fauth
  1505. system call to fail, as an indication that authentication is
  1506. not required to access the service.
  1507. .LP
  1508. The second argument to
  1509. .CW auth_proxy
  1510. is a function, here
  1511. .CW amount_getkey ,
  1512. to be called if secret information such as a password or
  1513. response to a challenge is required as part of the authentication.
  1514. This function, of course, will provide this data to
  1515. .CW factotum
  1516. as a
  1517. .CW key
  1518. message on the
  1519. .CW /mnt/factotum/ctl
  1520. file.
  1521. .LP
  1522. Although the final argument to
  1523. .CW auth_proxy
  1524. in this example is a simple string, in general
  1525. it can be a formatted-print specifier in the manner of
  1526. .CW printf ,
  1527. to enable the construction of more elaborate key queries.
  1528. .LP
  1529. As another example, consider the Plan 9
  1530. .CW cpu
  1531. service, which exports local devices to a shell process on
  1532. a remote machine, typically
  1533. to connect the local screen and keyboard to a more powerful computer.
  1534. At heart,
  1535. .CW cpu
  1536. is a superset of a service called
  1537. .CW exportfs
  1538. [Pike93],
  1539. which allows one machine to see an arbitrary portion of the file name space
  1540. of another machine, such as to
  1541. export the network device to another machine
  1542. for gatewaying.
  1543. However,
  1544. .CW cpu
  1545. is not just
  1546. .CW exportfs
  1547. because it also delivers signals such as interrupt
  1548. and negotiates the initial environment
  1549. for the remote shell.
  1550. .LP
  1551. To authenticate an instance of
  1552. .CW cpu
  1553. requires
  1554. .CW factotum
  1555. processes on both ends: the local, client
  1556. end running as the user on a terminal
  1557. and the remote, server
  1558. end running as the host owner of the server machine.
  1559. Here is schematic code for the two ends:
  1560. .P1
  1561. .ta 3n +3n +3n +3n
  1562. /* client */
  1563. int
  1564. p9auth(int fd)
  1565. {
  1566. AuthInfo *ai;
  1567. ai = auth_proxy(fd, auth_getkey,
  1568. "proto=p9any role=client");
  1569. if(ai == NULL)
  1570. return -1;
  1571. /* start cpu protocol here */
  1572. }
  1573. /* server */
  1574. int
  1575. srvp9auth(int fd, char *user)
  1576. {
  1577. AuthInfo *ai;
  1578. ai = auth_proxy(fd, NULL,
  1579. "proto=p9any role=server");
  1580. if(ai == NULL)
  1581. return -1;
  1582. /* set user id for server process */
  1583. if(auth_chuid(ai, NULL) < 0)
  1584. return -1;
  1585. /* start cpu protocol here */
  1586. }
  1587. .P2
  1588. .CW Auth_chuid
  1589. encapsulates the negotiation to change a user id using the
  1590. .CW caphash
  1591. and
  1592. .CW capuse
  1593. files of the (server) kernel.
  1594. Note that although the client process may ask the user for new keys, using
  1595. .CW auth_getkey ,
  1596. the server machine, presumably a shared machine with a pseudo-user for
  1597. the host owner, sets the key-getting function to
  1598. .CW NULL .
  1599. .NH 1
  1600. Secure Store
  1601. .LP
  1602. .CW Factotum
  1603. keeps its keys in volatile memory, which must somehow be
  1604. initialized at boot time.
  1605. Therefore,
  1606. .CW factotum
  1607. must be
  1608. supplemented by a persistent store, perhaps
  1609. a floppy disk containing a key file of commands to be copied into
  1610. .CW /mnt/factotum/ctl
  1611. during bootstrap.
  1612. But removable media are a nuisance to carry and
  1613. are vulnerable to theft.
  1614. Keys could be stored encrypted on a shared file system, but
  1615. only if those keys are not necessary for authenticating to
  1616. the file system in the first place.
  1617. Even if the keys are encrypted under a user
  1618. password, a thief might well succeed with a dictionary attack.
  1619. Other risks of local storage are loss of the contents
  1620. through mechanical mishap or dead batteries.
  1621. Thus for convenience and
  1622. safety we provide a
  1623. .CW secstore
  1624. (secure store) server in the network to hold each user's permanent list of keys, a
  1625. .I key
  1626. .I file .
  1627. .LP
  1628. .CW Secstore
  1629. is a file server for encrypted data,
  1630. used only during bootstrapping.
  1631. It must provide strong
  1632. authentication and resistance to passive and active protocol attacks
  1633. while assuming nothing more from the client than a password.
  1634. Once
  1635. .CW factotum
  1636. has loaded the key file, further encrypted or authenticated
  1637. file storage can be accomplished by standard mechanisms.
  1638. .EQ
  1639. define mod % ~ roman "mod" ~ %
  1640. define sha1 % "sha1" %
  1641. .EN
  1642. .LP
  1643. The cryptographic technology that enables
  1644. .CW secstore
  1645. is a form of encrypted
  1646. key exchange
  1647. called PAK
  1648. [Boyk00],
  1649. analogous to
  1650. EKE
  1651. [Bell93],
  1652. SRP
  1653. [Wu98],
  1654. or
  1655. SPEKE
  1656. [Jabl].
  1657. PAK was chosen
  1658. because it comes with a proof of equivalence in strength to
  1659. Diffie-Hellman; subtle flaws in some earlier encrypted key exchange
  1660. protocols and implementations have encouraged us to take special care.
  1661. In outline, the PAK protocol is:
  1662. .P1
  1663. $C -> S:~ C, g sup x H#
  1664. $S -> C:~ S, g sup y , hash(g sup xy , C, S)#
  1665. $C -> S:~ hash(g sup xy , S, C)#
  1666. .P2
  1667. where $H# is a preshared secret between client $C# and server $S#.
  1668. There are several variants of PAK, all presented in papers
  1669. mainly concerned with proofs of cryptographic properties.
  1670. To aid implementers, we have distilled a description of the specific
  1671. version we use into an Appendix to this paper.
  1672. The Plan 9 open source license provides for use of Lucent's
  1673. encrypted key exchange patents in this context.
  1674. .LP
  1675. As a further layer of defense against password theft,
  1676. we provide (within the encrypted channel $C -> S#)
  1677. information that is validated at a RADIUS server,
  1678. such as the digits from a hardware token
  1679. [RFC2138].
  1680. This provides two-factor authentication, which potentially
  1681. requires tricking two independent administrators in any attack by
  1682. social engineering.
  1683. .LP
  1684. The key file stored on the server is encrypted with AES (Rijndael) using CBC
  1685. with a 10-byte initialization vector and trailing authentication padding.
  1686. All this is invisible to the user of
  1687. .CW secstore .
  1688. For that matter, it is invisible to the
  1689. .CW secstore
  1690. server as well;
  1691. if the AES Modes of Operation are standardized and a new encryption format
  1692. designed, it can be implemented by a client without change to the server.
  1693. The
  1694. .CW secstore
  1695. is deliberately not backed up; the user is expected to
  1696. use more than one
  1697. .CW secstore
  1698. or save the key file on removable media
  1699. and lock it away.
  1700. The user's password is hashed to create the $H# used
  1701. in the PAK protocol; a different hash of the password is used as
  1702. the file encryption key.
  1703. Finally, there is a command (inside the authenticated,
  1704. encrypted channel between client and
  1705. .CW secstore )
  1706. to change passwords by sending
  1707. a new $H#;
  1708. for consistency, the client process must at the same time fetch and re-encrypt all files.
  1709. .LP
  1710. When
  1711. .CW factotum
  1712. starts, it dials the local
  1713. .CW secstore
  1714. and checks whether the user has an account.
  1715. If so,
  1716. it prompts for the user's
  1717. .CW secstore
  1718. password and fetches the key file.
  1719. The PAK protocol
  1720. ensures mutual authentication and prevents dictionary attacks on the password
  1721. by passive wiretappers or active intermediaries.
  1722. Passwords saved in
  1723. the key file can be long random strings suitable for
  1724. simpler challenge/response authentication protocols.
  1725. Thus the user need only remember
  1726. a single, weaker password to enable strong, ``single sign on'' authentication to
  1727. unchanged legacy applications scattered across multiple authentication domains.
  1728. .NH 1
  1729. Transport Layer Security
  1730. .LP
  1731. Since the Plan 9 operating system is designed for use in network elements
  1732. that must withstand direct attack, unguarded by firewall or VPN, we seek
  1733. to ensure that all applications use channels with appropriate mutual
  1734. authentication and encryption.
  1735. A principal tool for this is TLS 1.0
  1736. [RFC2246].
  1737. (TLS 1.0 is nearly the same as SSL 3.0,
  1738. and our software is designed to interoperate
  1739. with implementations of either standard.)
  1740. .LP
  1741. TLS defines a record layer protocol for message integrity and privacy
  1742. through the use of message digesting and encryption with shared secrets.
  1743. We implement this service as a kernel device, though it could
  1744. be performed at slightly higher cost by invoking a separate program.
  1745. The library interface to the TLS kernel device is:
  1746. .P1
  1747. int pushtls(int fd, char *hashalg,
  1748. char *cryptalg, int isclient,
  1749. char *secret, char *dir);
  1750. .P2
  1751. Given a file descriptor, the names of message digest and
  1752. encryption algorithms, and the shared secret,
  1753. .CW pushtls
  1754. returns a new file descriptor for the encrypted connection.
  1755. (The final argument
  1756. .CW dir
  1757. receives the name of the directory in the TLS device that
  1758. is associated with the new connection.)
  1759. The function is named by analogy with the ``push'' operation
  1760. supported by the stream I/O system of Research Unix and the
  1761. first two editions of Plan 9.
  1762. Because adding encryption is as simple as replacing one
  1763. file descriptor with another, adding encryption to a particular
  1764. network service is usually trivial.
  1765. .LP
  1766. The Plan 9 shared key authentication protocols establish a shared 56-bit secret
  1767. as a side effect.
  1768. Native Plan 9 network services such as
  1769. .CW cpu
  1770. and
  1771. .CW exportfs
  1772. use these protocols for authentication and then invoke
  1773. .CW pushtls
  1774. with the shared secret.
  1775. .LP
  1776. Above the record layer, TLS specifies a handshake protocol using public keys
  1777. to establish the session secret.
  1778. This protocol is widely used with HTTP and IMAP4
  1779. to provide server authentication, though with client certificates it could provide
  1780. mutual authentication. The library function
  1781. .P1
  1782. int tlsClient(int fd, TLSconn *conn)
  1783. .P2
  1784. handles the initial handshake and returns the result of
  1785. .CW pushtls .
  1786. On return, it fills the
  1787. .CW conn
  1788. structure with the session ID used
  1789. and the X.509 certificate presented by the
  1790. server, but makes no effort to verify the certificate.
  1791. Although the original design intent of X.509 certificates expected
  1792. that they would be used with a Public Key Infrastructure,
  1793. reliable deployment has been so long delayed and problematic
  1794. that we have adopted the simpler policy of just using the
  1795. X.509 certificate as a representation of the public key,
  1796. depending on a locally-administered directory of SHA1 thumbprints
  1797. to allow applications to decide which public keys to trust
  1798. for which purposes.
  1799. .NH 1
  1800. Related Work and Discussion
  1801. .LP
  1802. Kerberos, one of the earliest distributed authentication
  1803. systems, keeps a set of authentication tickets in a temporary file called
  1804. a ticket cache. The ticket cache is protected by Unix file permissions.
  1805. An environment variable containing the file name of the ticket cache
  1806. allows for different ticket caches in different simultaneous login sessions.
  1807. A user logs in by typing his or her Kerberos password.
  1808. The login program uses the Kerberos password to obtain a temporary
  1809. ticket-granting ticket from the authentication server, initializes the
  1810. ticket cache with the ticket-granting ticket, and then forgets the password.
  1811. Other applications can use the ticket-granting ticket to sign tickets
  1812. for themselves on behalf of the user during the login session.
  1813. The ticket cache is removed when the user logs out
  1814. [Stei88].
  1815. The ticket cache relieves the user from typing a password
  1816. every time authentication is needed.
  1817. .LP
  1818. The secure shell SSH develops this idea further, replacing the
  1819. temporary file with a named Unix domain socket connected to
  1820. a user-level program, called an agent.
  1821. Once the SSH agent is started and initialized with one or
  1822. more RSA private keys, SSH clients can employ it
  1823. to perform RSA authentications on their behalf.
  1824. In the absence of an agent, SSH typically uses RSA keys
  1825. read from encrypted disk files or uses passphrase-based
  1826. authentication, both of which would require prompting the user
  1827. for a passphrase whenever authentication is needed
  1828. [Ylon96].
  1829. The self-certifying file system SFS uses a similar agent
  1830. [Kami00],
  1831. not only for moderating the use of client authentication keys
  1832. but also for verifying server public keys
  1833. [Mazi99].
  1834. .LP
  1835. .CW Factotum
  1836. is a logical continuation of this evolution,
  1837. replacing the program-specific SSH or SFS agents with
  1838. a general agent capable of serving a wide variety of programs.
  1839. Having one agent for all programs removes the need
  1840. to have one agent for each program.
  1841. It also allows the programs themselves to be protocol-agnostic,
  1842. so that, for example, one could build an SSH workalike
  1843. capable of using any protocol supported by
  1844. .CW factotum ,
  1845. without that program knowing anything about the protocols.
  1846. Traditionally each program needs to implement each
  1847. authentication protocol for itself, an $O(n sup 2 )# coding
  1848. problem that
  1849. .CW factotum
  1850. reduces to $O(n)#.
  1851. .LP
  1852. Previous work on agents has concentrated on their use by clients
  1853. authenticating to servers.
  1854. Looking in the other direction, Sun Microsystem's
  1855. pluggable authentication module (PAM) is one
  1856. of the earliest attempts to
  1857. provide a general authentication mechanism for Unix-like
  1858. operating systems
  1859. [Sama96].
  1860. Without a central authority like PAM, system policy is tied
  1861. up in the various implementations of network services.
  1862. For example, on a typical Unix, if a system administrator
  1863. decides not to allow plaintext passwords for authentication,
  1864. the configuration files for a half dozen different servers \(em
  1865. .CW rlogind ,
  1866. .CW telnetd ,
  1867. .CW ftpd ,
  1868. .CW sshd ,
  1869. and so on \(em
  1870. need to be edited.
  1871. PAM solves this problem by hiding the details of a given
  1872. authentication mechanism behind a common library interface.
  1873. Directed by a system-wide configuration file,
  1874. an application selects a particular authentication mechanism
  1875. by dynamically loading the appropriate shared library.
  1876. PAM is widely used on Sun's Solaris and some Linux distributions.
  1877. .LP
  1878. .CW Factotum
  1879. achieves the same goals
  1880. using the agent approach.
  1881. .CW Factotum
  1882. is the only process that needs to create
  1883. capabilities, so all the network servers can run as
  1884. untrusted users (e.g.,
  1885. Plan 9's
  1886. .CW none
  1887. or Unix's
  1888. .CW nobody ),
  1889. which greatly reduces the harm done if a server is buggy
  1890. and is compromised.
  1891. In fact, if
  1892. .CW factotum
  1893. were implemented on Unix along with
  1894. an analogue to the Plan 9 capability device, venerable
  1895. programs like
  1896. .CW su
  1897. and
  1898. .CW login
  1899. would no longer need to be installed ``setuid root.''
  1900. .LP
  1901. Several other systems, such as Password Safe [Schn],
  1902. store multiple passwords in an encrypted file,
  1903. so that the user only needs to remember one password.
  1904. Our
  1905. .CW secstore
  1906. solution differs from these by placing the storage in
  1907. a hardened location in the network, so that the encrypted file is
  1908. less liable to be stolen for offline dictionary attack and so that
  1909. it is available even when a user has several computers.
  1910. In contrast, Microsoft's Passport system
  1911. [Micr]
  1912. keeps credentials in
  1913. the network, but centralized at one extremely-high-value target.
  1914. The important feature of Passport, setting up trust relationships
  1915. with e-merchants, is outside our scope.
  1916. The
  1917. .CW secstore
  1918. architecture is almost identical to
  1919. Perlman and Kaufman's
  1920. [Perl99]
  1921. but with newer EKE technology.
  1922. Like them, we chose to defend mainly against outside attacks
  1923. on
  1924. .CW secstore ;
  1925. if additional defense of the files on the server
  1926. itself is desired, one can use distributed techniques
  1927. [Ford00].
  1928. .LP
  1929. We made a conscious choice of placing encryption, message integrity,
  1930. and key management at the application layer
  1931. (TLS, just above layer 4) rather than at layer 3, as in IPsec.
  1932. This leads to a simpler structure for the network stack, easier
  1933. integration with applications and, most important, easier network
  1934. administration since we can recognize which applications are misbehaving
  1935. based on TCP port numbers. TLS does suffer (relative to IPsec) from
  1936. the possibility of forged TCP Reset, but we feel that this is adequately
  1937. dealt with by randomized TCP sequence numbers.
  1938. In contrast with other TLS libraries, Plan 9 does not
  1939. require the application to change
  1940. .CW write
  1941. calls to
  1942. .CW sslwrite
  1943. but simply to add a few lines of code at startup
  1944. [Resc01].
  1945. .NH 1
  1946. Conclusion
  1947. .LP
  1948. Writing safe code is difficult.
  1949. Stack attacks,
  1950. mistakes in logic, and bugs in compilers and operating systems
  1951. can each make it possible for an attacker
  1952. to subvert the intended execution sequence of a
  1953. service.
  1954. If the server process has the privileges
  1955. of a powerful user, such as
  1956. .CW root
  1957. on Unix, then so does the attacker.
  1958. .CW Factotum
  1959. allows us
  1960. to constrain the privileged execution to a single
  1961. process whose core is a few thousand lines of code.
  1962. Verifying such a process, both through manual and automatic means,
  1963. is much easier and less error prone
  1964. than requiring it of all servers.
  1965. .LP
  1966. An implementation of these ideas is in Plan 9 from Bell Labs, Fourth Edition,
  1967. freely available from \f(CWhttp://\%plan9.bell-labs.com/\%plan9\fP.
  1968. .SH
  1969. Acknowledgments
  1970. .LP
  1971. William Josephson contributed to the implementation of password changing in
  1972. .CW secstore .
  1973. We thank Phil MacKenzie and Martín Abadi for helpful comments on early parts
  1974. of the design.
  1975. Chuck Blake,
  1976. Peter Bosch,
  1977. Frans Kaashoek,
  1978. Sape Mullender,
  1979. and
  1980. Lakshman Y. N.,
  1981. predominantly Dutchmen, gave helpful comments on the paper.
  1982. Russ Cox is supported by a fellowship from the Fannie and John Hertz Foundation.
  1983. .SH
  1984. References
  1985. .LP
  1986. [Bell93]
  1987. S.M. Bellovin and M. Merritt,
  1988. ``Augmented Encrypted Key Exchange,''
  1989. Proceedings of the 1st ACM Conference on Computer and Communications Security, 1993, pp. 244 - 250.
  1990. .LP
  1991. [Boyk00]
  1992. Victor Boyko, Philip MacKenzie, and Sarvar Patel,
  1993. ``Provably Secure Password-Authenticated Key Exchange using Diffie-Hellman,''
  1994. Eurocrypt 2000, 156\-171.
  1995. ... http://www.bell-labs.com/who/philmac/research/pak-final.ps.gz
  1996. .LP
  1997. [RFC2246]
  1998. T . Dierks and C. Allen,
  1999. ``The TLS Protocol, Version 1.0,''
  2000. RFC 2246.
  2001. .LP
  2002. [Ford00]
  2003. Warwick Ford and Burton S. Kaliski, Jr.,
  2004. ``Server-Assisted Generation of a Strong Secret from a Password,''
  2005. IEEE Fifth International Workshop on Enterprise Security,
  2006. National Institute of Standards and Technology (NIST),
  2007. Gaithersburg MD, June 14 - 16, 2000.
  2008. .LP
  2009. [Jabl]
  2010. David P. Jablon,
  2011. ``Strong Password-Only Authenticated Key Exchange,''
  2012. \f(CWhttp://\%integritysciences.com/\%speke97.html\fP.
  2013. .LP
  2014. [Kami00]
  2015. Michael Kaminsky.
  2016. ``Flexible Key Management with SFS Agents,''
  2017. Master's Thesis, MIT, May 2000.
  2018. .LP
  2019. [Mack]
  2020. Philip MacKenzie,
  2021. private communication.
  2022. .LP
  2023. [Mazi99]
  2024. David Mazières, Michael Kaminsky, M. Frans Kaashoek and Emmett Witchel,
  2025. ``Separating key management from file system security,''
  2026. Symposium on Operating Systems Principles, 1999, pp. 124-139.
  2027. .LP
  2028. [Micr]
  2029. Microsoft Passport,
  2030. \f(CWhttp://\%www.passport.com/\fP.
  2031. .LP
  2032. [Perl99]
  2033. Radia Perlman and Charlie Kaufman,
  2034. ``Secure Password-Based Protocol for Downloading a Private Key,''
  2035. Proc. 1999 Network and Distributed System Security Symposium,
  2036. Internet Society, January 1999.
  2037. .LP
  2038. [Pike95]
  2039. Rob Pike, Dave Presotto, Sean Dorward, Bob Flandrena, Ken Thompson, Howard Trickey, and Phil Winterbottom,
  2040. ``Plan 9 from Bell Labs,''
  2041. Computing Systems, \f3\&8\fP, 3, Summer 1995, pp. 221-254.
  2042. .LP
  2043. [Pike93]
  2044. Rob Pike, Dave Presotto, Ken Thompson, Howard Trickey, Phil Winterbottom,
  2045. ``The Use of Name Spaces in Plan 9,''
  2046. Operating Systems Review, \f3\&27\fP, 2, April 1993, pp. 72-76
  2047. (reprinted from Proceedings of the 5th ACM SIGOPS European Workshop,
  2048. Mont Saint-Michel, 1992, Paper nº 34).
  2049. .LP
  2050. [Resc01]
  2051. Eric Rescorla,
  2052. ``SSL and TLS: Designing and Building Secure Systems,''
  2053. Addison-Wesley, 2001. ISBN 0-201-61598-3, p. 387.
  2054. .LP
  2055. [RFC2138]
  2056. C. Rigney, A. Rubens, W. Simpson, S. Willens,
  2057. ``Remote Authentication Dial In User Service (RADIUS),''
  2058. RFC2138, April 1997.
  2059. .LP
  2060. [RiLa]
  2061. Ronald L. Rivest and Butler Lampson,
  2062. ``SDSI\(emA Simple Distributed Security Infrastructure,''
  2063. \f(CWhttp://\%theory.lcs.mit.edu/\%~rivest/\%sdsi10.ps\fP.
  2064. .LP
  2065. [Schn]
  2066. Bruce Schneier, Password Safe,
  2067. \f(CWhttp://\%www.counterpane.com/\%passsafe.html\fP.
  2068. .LP
  2069. [Sama96]
  2070. Vipin Samar,
  2071. ``Unified Login with Pluggable Authentication Modules (PAM),''
  2072. Proceedings of the Third ACM Conference on Computer Communications and Security,
  2073. March 1996, New Delhi, India.
  2074. ... http://www1.acm.org/pubs/articles/proceedings/commsec/238168/p1-samar/p1-samar.pdf
  2075. .LP
  2076. [Stei88]
  2077. Jennifer G. Steiner, Clifford Neumann, and Jeffrey I. Schiller,
  2078. ``\fIKerberos\fR: An Authentication Service for Open Network Systems,''
  2079. Proceedings of USENIX Winter Conference, Dallas, Texas, February 1988, pp. 191\-202.
  2080. ... ftp://athena-dist.mit.edu/pub/kerberos/doc/usenix.PS
  2081. .LP
  2082. [Wu98]
  2083. T. Wu,
  2084. ``The Secure Remote Password Protocol,''
  2085. Proceedings of
  2086. the 1998 Internet Society Network and Distributed System Security
  2087. Symposium, San Diego, CA, March 1998, pp. 97-111.
  2088. .LP
  2089. [Ylon96]
  2090. Ylonen, T.,
  2091. ``SSH\(emSecure Login Connections Over the Internet,''
  2092. 6th USENIX Security Symposium, pp. 37-42. San Jose, CA, July 1996.
  2093. .SH
  2094. Appendix: Summary of the PAK protocol
  2095. .LP
  2096. Let $q>2 sup 160# and $p>2 sup 1024# be primes
  2097. such that $p=rq+1# with $r# not a multiple of $q#.
  2098. Take $h ∈ Z sub p sup *# such that $g == h sup r# is not 1.
  2099. These parameters may be chosen by the NIST algorithm for DSA,
  2100. and are public, fixed values.
  2101. The client $C# knows a secret $pi#
  2102. and computes $H == (H sub 1 (C, ~ pi )) sup r# and $H sup -1#,
  2103. where $H sub 1# is a hash function yielding a random element of $Z sub p sup *#,
  2104. and $H sup -1# may be computed by gcd.
  2105. (All arithmetic is modulo $p#.)
  2106. The client gives $H sup -1# to the server $S# ahead of time by a private channel.
  2107. To start a new connection, the client generates a random value $x#,
  2108. computes $m == g sup x H#,
  2109. then calls the server and sends $C# and $m#.
  2110. The server checks $m != 0 mod p#,
  2111. generates random $y#,
  2112. computes $ mu == g sup y#,
  2113. $ sigma == (m H sup -1 ) sup y#,
  2114. and sends $S#, $mu#, $k == sha1 ( roman "\"server\"", C, S, m, mu , sigma , H sup -1 )#.
  2115. Next the client computes $sigma = mu sup x#,
  2116. verifies $k#,
  2117. and sends $k' == sha1 ( roman "\"client\"", C, S, m, mu , sigma , H sup -1 )#.
  2118. The server then verifies $k'# and both sides begin
  2119. using session key $K == sha1 ( roman "\"session\"", C, S, m, mu , sigma , H sup -1 )#.
  2120. In the published version of PAK, the server name $S#
  2121. is included in the initial
  2122. hash $H#, but doing so is inconvenient in our application,
  2123. as the server may be known by various equivalent names.
  2124. .LP
  2125. MacKenzie has shown
  2126. [Mack]
  2127. that the
  2128. equivalence proof [Boyk00]
  2129. can be adapted to cover our version.