auth.ms 65 KB

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