README 4.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <dcbw> dwmw2: that auth dialog does a shitload of work
  2. Indeed. But it's quite simple really.
  3. AnyConnect works over HTTPS; authentication is through HTTP forms and
  4. POST responses. Once you've filled in the forms that the server demands,
  5. you're rewarded with an HTTP cookie which is handed on to OpenConnect to
  6. actually make the connection.
  7. The auth-dialog handles the arbitrary forms as the server presents them,
  8. and spits out the cookie after a successful authentication. It's just a
  9. really simple web-browser, effectively. (It has its own HTTP client
  10. implementation instead of using libsoup because it needs to be able to
  11. support certificates from a TPM, and to work around Cisco bugs).
  12. To make it slightly more fun, you have a *choice* of servers; an
  13. AnyConnect VPN is provisioned with an XML file that gives various pieces
  14. of configuration for the client. We ignore most of the XML file, except
  15. the list of available VPN server addresses.
  16. So this is a brief flow of what the auth-dialog does...
  17. 1. Choose a server to connect to.
  18. If we already have the XML configuration file for this VPN, you get
  19. to choose a server from the list. Otherwise, you only have the host
  20. that you configured in the VPN setup.
  21. The auth-dialog will give you the choice of automatically connecting
  22. to the last server you used. It does so by storing the boolean
  23. 'autoconnect' option, as well as the address of the last successful
  24. server, in "secrets" that NetworkManager stores for it, but which
  25. aren't actually used by OpenConnect itself at all.
  26. 2. (Offer your SSL certificate and) fill in all the forms it presents.
  27. The server will present a sequence of forms which are filled in just
  28. like normal web forms. At this point, the auth-dialog is just acting
  29. like a really simple web browser. It uses the same trick with fake
  30. secrets to remember the answers for any multiple-choice selection,
  31. or input elements of type 'text'. Input elements of type 'password'
  32. are not currently saved, but probably should be.
  33. The choices and input boxes that we fill in at this point may not be
  34. limited to *just* authenticating ourselves. You may also get to make
  35. choices which affect your resulting connectivity. Some networks
  36. offer the choice of full-tunnel or split-tunnel routing, IPv6 or
  37. Legacy-only connectivity, etc. (The routing configuration is not
  38. handled by the auth-dialog; that just manifests itself in the IP
  39. configuration which is given to OpenConnect by the server, much
  40. later when the connection is actually made.)
  41. (
  42. 2½. Run the "Cisco Secure Desktop"[sic] trojan.
  43. In some cases you are required to download a strange executable from
  44. the server and run it. It is supposed to perform various "checks" on
  45. your system and report its results to the server. The authentication
  46. sequence is kept in a holding pattern with HTTP refresh responses
  47. until the "trojan" has done its job.
  48. Most people seem to bypass this crap and run a local tool of their
  49. own devising to report the "correct" results. It's just another
  50. simple HTTP POST, although the exact results that are expected may
  51. vary from one server/configuration to another.
  52. Try not to think about it. It will only make you sad.
  53. )
  54. 3. Note the 'webvpn' cookie.
  55. Once authentication is complete, the server's HTTP response will
  56. include a 'webvpn' cookie.
  57. This cookie is one of the three *real* secrets which are actually
  58. passed to OpenConnect to make the connection. The other two are
  59. the address of the server we finally ended up talking to (after
  60. the user's initial choice and any HTTP redirects), and a hash of
  61. the server's SSL certificate (to prevent MiTM attacks).
  62. 4. Check the XML configuration file.
  63. With a successful authentication, we are *also* given the SHA1 of
  64. the current XML configuration for this VPN connection. If it differs
  65. from what we have, we are expected to fetch the new one. We store
  66. this, base64-encoded, in yet another fake "secret".
  67. 5. Dump all the "secrets" to NetworkManager.
  68. Finally, we dump all the secrets to stdout so that NetworkManager can
  69. store them. Note that even on an *unsuccessful* attempt, we still
  70. output the secrets we do have. That includes the state of the
  71. "autoconnect" boolean option, for example, which would otherwise
  72. not get saved except on a successful connection.