logo

drewdevault.com

[mirror] blog and personal website of Drew DeVault git clone https://hacktivis.me/git/mirror/drewdevault.com.git

Himitsu.md (7816B)


  1. ---
  2. title: Introducing the Himitsu keyring & password manager for Unix
  3. date: 2022-06-20
  4. ---
  5. [Himitsu] is a new approach to storing secret information on Unix systems, such
  6. as passwords or private keys, and I released version 0.1 this morning. It's
  7. available on [Alpine Linux] community and the [Arch User Repository], with [more
  8. distributions] hopefully on the way soon.
  9. [Himitsu]: https://himitsustore.org
  10. [Alpine Linux]: https://wiki.alpinelinux.org/wiki/Himitsu
  11. [Arch User Repository]: https://wiki.archlinux.org/title/Himitsu
  12. [more distributions]: https://repology.org/project/himitsu/versions
  13. So, what is Himitsu and what makes it special? The following video introduces
  14. the essential concepts and gives you an idea of what's possible:
  15. <iframe title="Introduction to the Himitsu secret key store" src="https://spacepub.space/videos/embed/5f9e5407-64a6-4776-9175-de744f2e7bc4" allowfullscreen="" sandbox="allow-same-origin allow-scripts allow-popups" width="560" height="315" frameborder="0"></iframe>
  16. If you prefer reading to watching, this blog post includes everything that's in
  17. the video.
  18. ## What is Himitsu?
  19. Himitsu draws inspiration from Plan 9's [factotum], but polished up and
  20. redesigned for Unix. At its core, Himitsu is a key/value store and a simple
  21. protocol for interacting with it. For example, a web login could be stored like
  22. so:
  23. [factotum]: http://man.9front.org/4/factotum
  24. ```
  25. proto=web host=example.org user=jdoe password!=hunter2
  26. ```
  27. Himitsu has no built-in knowledge of web logins, it just stores arbitrary keys
  28. and values. The bang (!) indicates that the password is a "secret" value, and
  29. the "proto" key defines additional conventions for each kind of secret. For
  30. proto=web, each key/value pair represents a form field on a HTML login form.
  31. We can query the key store using the "hiq" command. For instance, we can obtain
  32. the example key above by querying for any key with "proto=web", any "host",
  33. "user", and "password" value, and an optional "comment" value:
  34. ```
  35. $ hiq proto=web host user password! comment?
  36. proto=web host=example.org user=jdoe password!
  37. ```
  38. You'll notice that the password is hidden here. In order to obtain it, we must
  39. ask for the user's consent.
  40. ```
  41. $ hiq -d proto=web host user password! comment?
  42. ```
  43. ![A screenshot of a GTK+ dialog confirming the operation](https://l.sr.ht/aTfn.png)
  44. ```
  45. proto=web host=example.org user=jdoe password!=hunter2
  46. ```
  47. You can also use hiq to add or delete keys, or incorporate it into a shell
  48. pipeline:
  49. ```
  50. $ hiq -dFpassword host=example.org
  51. hunter2
  52. ```
  53. ## A simple, extensible protocol
  54. The protocol is a simple line-oriented text protocol, which is documented in the
  55. [himitsu-ipc(5)] manual page. We can also use it via netcat:
  56. [himitsu-ipc(5)]: https://himitsustore.org/docs/himitsu-ipc.5.html
  57. ```
  58. $ nc -U $XDG_RUNTIME_DIR/himitsu
  59. query host=example.org
  60. key proto=web host=example.org user=jdoe password!
  61. end
  62. query -d host=example.org
  63. key proto=web host=example.org user=jdoe password!=hunter2
  64. end
  65. ```
  66. The consent prompter also uses a standardized protocol, documented by
  67. [himitsu-prompter(5)]. Based on this, you can implement new prompters for Qt, or
  68. the TTY, or any other technology appropriate to your system, or implement a more
  69. novel approach, such as sending a push notification to your phone to facilitate
  70. consent.
  71. [himitsu-prompter(5)]: https://himitsustore.org/docs/himitsu-prompter.5.html
  72. ## Additional frontends
  73. Based on these protocols, a number of additional integrations are possible.
  74. Martijn Braam has written a nice GTK+ frontend called [keyring]:
  75. [keyring]: https://git.sr.ht/~martijnbraam/keyring/
  76. ![A screenshot of the GTK+ frontend](https://brixitcdn.net/metainfo/keyring.png)
  77. There's also a [Firefox add-on] which auto-fills forms for keys with proto=web:
  78. [Firefox add-on]: https://addons.mozilla.org/en-US/firefox/addon/himitsu-integration/
  79. ![Screenshot of himitsu-firefox](https://l.sr.ht/eLcs.png)
  80. We also have a package called [himitsu-ssh] which provides an SSH agent:
  81. [himitsu-ssh]: https://git.sr.ht/~sircmpwn/himitsu-ssh
  82. ```
  83. $ hissh-import < ~/.ssh/id_ed25519
  84. Enter SSH key passphrase:
  85. key proto=ssh type=ssh-ed25519 pkey=pF7SljE25sVLdWvInO4gfqpJbbjxI6j+tIUcNWzVTHU= skey! comment=sircmpwn@homura
  86. $ ssh-add -l
  87. 256 SHA256:kPr5ZKTNE54TRHGSaanhcQYiJ56zSgcpKeLZw4/myEI sircmpwn@homura (ED25519)
  88. $ ssh git@git.sr.ht
  89. Hi sircmpwn! You've successfully authenticated, but I do not provide an interactive shell. Bye!
  90. Connection to git.sr.ht closed.
  91. ```
  92. I hope to see an ecosystem of tools built around Himitsu to grow. New frontends
  93. like keyring would be great, and new integrations like GPG agents would also be
  94. nice to see.
  95. ## Zero configuration
  96. Himitsu-aware software can discover your credentials and connection details
  97. without any additional configuration. For example, a mail client might look for
  98. `proto=imap` and `proto=smtp` and discover something like this:
  99. ```
  100. proto=imap host=imap.migadu.com user=sir@cmpwn.com password! port=993 enc=tls
  101. proto=smtp host=imap.migadu.com user=sir@cmpwn.com password! port=465 enc=tls
  102. ```
  103. After a quick consent prompt, the software can load your IMAP and SMTP
  104. configuration and get connected without any manual steps. With an agent like
  105. himitsu-ssh, it could even connect without actually handling your credentials
  106. directly &mdash; a use-case we want to support with improvements to the prompter
  107. UI (to distinguish between a case where an application will *view* versus *use*
  108. your credentials).
  109. ## The cryptography
  110. Your key store is located at $XDG\_DATA\_HOME/himitsu/. The key is derived by
  111. mixing your password with argon2, and the resulting key is used for AEAD with
  112. XChaCha20+Poly1305. The "index" file contains a list of base64-encoded encrypted
  113. blobs, one per line, enumerating the keys in the key store.[^1] Secret keys are
  114. encrypted and stored separately in files in this directory. If you like the pass
  115. approach to storing your keys in git, you can easily commit this directory to a
  116. git repository, or haul it along to each of your devices with whatever other
  117. means is convenient to you.
  118. [^1]: This offers an improvement over pass, for example, by not storing the list of entries in plain text.
  119. Himitsu is written in Hare and uses cryptography primitives available from its
  120. standard library. Note that these have not been audited.
  121. ## Future plans
  122. I'd like to expand on Himitsu in the future. One idea is to store your full disk
  123. encryption password in Himitsu and stick a subset of your key store into the
  124. initramfs, which you unlock during early boot, pull FDE keys out of, and then
  125. pre-authorize the keyring for your desktop session - which you're logged in to
  126. automatically on the basis that you were pre-authorized during boot.
  127. We also want to add key sharing and synchronization tools. The protocol could
  128. easily be moved to TCP and authorized with your existing key store key (we could
  129. make an ed25519 key out of it, or generate and store one separately), so setting
  130. up key synchronization might be as simple as:
  131. ```
  132. $ hiq -a proto=sync host=himitsu.sr.ht
  133. ```
  134. You could also use Himitsu for service discovery &mdash; imagine a key ring
  135. running on your datacenter LAN with entries for your Postgres database, SMTP
  136. credentials, and so on.
  137. There are some other ideas that we could use your help with:
  138. - himitsu-firefox improvements (web devs welcome!)
  139. - Chromium support (web devs welcome!)
  140. - Himitsu apps for phones (mobile devs welcome!)
  141. - More key management frontends (maybe a TUI?)
  142. - More security options &mdash; smart cards? U2F?
  143. - hare-ssh improvements (e.g. RSA keys)
  144. - PGP support
  145. - Anything else you can think of
  146. Please join us! We hang out on IRC in #himitsu on Libera Chat. Give Himitsu a
  147. shot and let us know what you think.
  148. Alright, back to kernel hacking. I got multi-tasking working yesterday!