119-controlport-auth.txt 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. Filename: 119-controlport-auth.txt
  2. Title: New PROTOCOLINFO command for controllers
  3. Author: Roger Dingledine
  4. Created: 14-Aug-2007
  5. Status: Closed
  6. Implemented-In: 0.2.0.x
  7. Overview:
  8. Here we describe how to help controllers locate the cookie
  9. authentication file when authenticating to Tor, so we can a) require
  10. authentication by default for Tor controllers and b) still keep
  11. things usable. Also, we propose an extensible, general-purpose mechanism
  12. for controllers to learn about a Tor instance's protocol and
  13. authentication requirements before authenticating.
  14. The Problem:
  15. When we first added the controller protocol, we wanted to make it
  16. easy for people to play with it, so by default we didn't require any
  17. authentication from controller programs. We allowed requests only from
  18. localhost as a stopgap measure for security.
  19. Due to an increasing number of vulnerabilities based on this approach,
  20. it's time to add authentication in default configurations.
  21. We have a number of goals:
  22. - We want the default Vidalia bundles to transparently work. That
  23. means we don't want the users to have to type in or know a password.
  24. - We want to allow multiple controller applications to connect to the
  25. control port. So if Vidalia is launching Tor, it can't just keep the
  26. secrets to itself.
  27. Right now there are three authentication approaches supported
  28. by the control protocol: NULL, CookieAuthentication, and
  29. HashedControlPassword. See Sec 5.1 in control-spec.txt for details.
  30. There are a couple of challenges here. The first is: if the controller
  31. launches Tor, how should we teach Tor what authentication approach
  32. it should require, and the secret that goes along with it? Next is:
  33. how should this work when the controller attaches to an existing Tor,
  34. rather than launching Tor itself?
  35. Cookie authentication seems most amenable to letting multiple controller
  36. applications interact with Tor. But that brings in yet another question:
  37. how does the controller guess where to look for the cookie file,
  38. without first knowing what DataDirectory Tor is using?
  39. Design:
  40. We should add a new controller command PROTOCOLINFO that can be sent
  41. as a valid first command (the others being AUTHENTICATE and QUIT). If
  42. PROTOCOLINFO is sent as the first command, the second command must be
  43. either a successful AUTHENTICATE or a QUIT.
  44. If the initial command sequence is not valid, Tor closes the connection.
  45. Spec:
  46. C: "PROTOCOLINFO" *(SP PIVERSION) CRLF
  47. S: "250+PROTOCOLINFO" SP PIVERSION CRLF *InfoLine "250 OK" CRLF
  48. InfoLine = AuthLine / VersionLine / OtherLine
  49. AuthLine = "250-AUTH" SP "METHODS=" AuthMethod *(",")AuthMethod
  50. *(SP "COOKIEFILE=" AuthCookieFile) CRLF
  51. VersionLine = "250-VERSION" SP "Tor=" TorVersion [SP Arguments] CRLF
  52. AuthMethod =
  53. "NULL" / ; No authentication is required
  54. "HASHEDPASSWORD" / ; A controller must supply the original password
  55. "COOKIE" / ; A controller must supply the contents of a cookie
  56. AuthCookieFile = QuotedString
  57. TorVersion = QuotedString
  58. OtherLine = "250-" Keyword [SP Arguments] CRLF
  59. For example:
  60. C: PROTOCOLINFO CRLF
  61. S: "250+PROTOCOLINFO 1" CRLF
  62. S: "250-AUTH Methods=HASHEDPASSWORD,COOKIE COOKIEFILE="/tor/cookie"" CRLF
  63. S: "250-VERSION Tor=0.2.0.5-alpha" CRLF
  64. S: "250 OK" CRLF
  65. Tor MAY give its InfoLines in any order; controllers MUST ignore InfoLines
  66. with keywords it does not recognize. Controllers MUST ignore extraneous
  67. data on any InfoLine.
  68. PIVERSION is there in case we drastically change the syntax one day. For
  69. now it should always be "1", for the controller protocol. Controllers MAY
  70. provide a list of the protocol versions they support; Tor MAY select a
  71. version that the controller does not support.
  72. Right now only two "topics" (AUTH and VERSION) are included, but more
  73. may be included in the future. Controllers must accept lines with
  74. unexpected topics.
  75. AuthCookieFile = QuotedString
  76. AuthMethod is used to specify one or more control authentication
  77. methods that Tor currently accepts.
  78. AuthCookieFile specifies the absolute path and filename of the
  79. authentication cookie that Tor is expecting and is provided iff
  80. the METHODS field contains the method "COOKIE". Controllers MUST handle
  81. escape sequences inside this string.
  82. The VERSION line contains the Tor version.
  83. [What else might we want to include that could be useful? -RD]
  84. Compatibility:
  85. Tor 0.1.2.16 and 0.2.0.4-alpha hang up after the first failed
  86. command. Earlier Tors don't know about this command but don't hang
  87. up. That means controllers will need a mechanism for distinguishing
  88. whether they're talking to a Tor that speaks PROTOCOLINFO or not.
  89. I suggest that the controllers attempt a PROTOCOLINFO. Then:
  90. - If it works, great. Authenticate as required.
  91. - If they get hung up on, reconnect and do a NULL AUTHENTICATE.
  92. - If it's unrecognized but they're not hung up on, do a NULL
  93. AUTHENTICATE.
  94. Unsolved problems:
  95. If Torbutton wants to be a Tor controller one day... talking TCP is
  96. bad enough, but reading from the filesystem is even harder. Is there
  97. a way to let simple programs work with the controller port without
  98. needing all the auth infrastructure?
  99. Once we put this approach in place, the next vulnerability we see will
  100. involve an attacker somehow getting read access to the victim's files
  101. --- and then we're back where we started. This means we still need
  102. to think about how to demand password-based authentication without
  103. bothering the user about it.