SECURITY 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. ***
  2. All cryptographic software in this package is subject to the following legal
  3. notice:
  4. This package includes publicly available encryption source code which,
  5. together with object code resulting from the compiling of publicly
  6. available source code, may be exported from the United States under License
  7. Exception TSU prsuant to 15 C.F.R Section 740.13(e).
  8. ***
  9. Security Design of corosync
  10. The corosync project intends to mitigate the following threats:
  11. 1. forged group messaging messages which are intended to fault the corosync
  12. executive
  13. 2. forged group messaging messages which are intended to fault applications
  14. using corosync apis
  15. 3. monitoring of network data to capture sensitive information
  16. The corosync project does not intend to mitigate the following threats:
  17. 1. physical access to the hardware which could expose the private key
  18. 2. privledged access to the operating system which could expose the private key
  19. or be used to inject errors into the corosync executive.
  20. 3. library user creates requests which are intended to fault the corosync
  21. executive
  22. The corosync project mitigates the threats using two mechanisms:
  23. 1. Authentication
  24. 2. Secrecy
  25. Library Interface
  26. -----------------
  27. The corosync executive authenticates every library user. The library is only
  28. allowed to access services if it's GID is corosync or 0. Unauthorized library
  29. users are rejected.
  30. The corosync group is a trusted group. If the administrator doesn't trust the
  31. application, it should not be added to the group! Any member of the corosync group
  32. could potentially send a malformed request to the executive and cause it to
  33. fault.
  34. Group Messaging Interface
  35. -------------------------
  36. Group messaging uses UDP/IP to communicate with other corosync executives using
  37. messages. It is possible without authentication of every packet that an
  38. attacker could forge messages. These forged messages could fault the corosync
  39. executive distributed state machines. It would also be possible to corrupt
  40. end applications by forging changes.
  41. Since messages are sent using UDP/IP it would be possible to snoop those
  42. messages and rebuild sensitive data.
  43. To solve these problems, the group messaging interface uses two new interfaces
  44. interal to it's implementation:
  45. 1. encrypt_and_sign - encrypts and signs a message securely
  46. 2. authenticate_and_decrypt - authenticates and decrypts a message securely
  47. When the executive wants to send a message over the network, it uses
  48. encrypt_and_sign to prepare the message to be sent. When the executive
  49. wants to receive a message from the network, it uses
  50. authenticate_and_decrypt to verify the message is valid and decrypt it.
  51. There are currently two encryption methods available in corosync.
  52. sha1/hmac/sober which are coded internally, and AES/SHA256 which
  53. are in the Mozilla Network Security Services (libnss) library.
  54. The internal functions utilize the following algorithms:
  55. sha1 - hash algorithm secure for using with hmac
  56. hmac - produces a 16 byte digest from any length input
  57. sober - pseudo random number generator and stream cipher
  58. Every message starts with a
  59. struct security {
  60. unsigned char digest[20]; A one way hash digest
  61. unsigned char salt[16]; A securely generated random number
  62. }
  63. INTERNAL SECURITY CODE:
  64. -----------------------
  65. The hmac algorithm requires a 16 byte key.
  66. The sober algorithm requires a 16 byte private key.
  67. The sober algorithm requires a 16 byte public initial vector.
  68. The private key is read from disk and stored in memory for use with the
  69. sober algorithm to generate the three required keys.
  70. When a message is sent (encrypt_and_sign):
  71. ------------------------------------------
  72. 1. sober is used to create a 16 byte random number (salt) using the md4
  73. algorithm
  74. 2. sober is keyed with the private key and the initial vector is set to the
  75. salt. Then a 48 byte key is read from the sober algorithm. This 48 byte
  76. key is split into 3 16 byte keys. The keys are the hmac key, the sober key
  77. and the sober initial vector.
  78. 3. A sober instance is keyed with the sober key and sober initial vector
  79. from step #2.
  80. 4. The data of the packet, except for the security header, is encrypted using
  81. the sober cipher that was initialized in step #3.
  82. 5. The salt is stored in the security header of the outgoing message.
  83. 6. The hmac is initialized with the hmac key generated in step #2.
  84. 7. The message, except for the security header, is hmaced to produce a digest
  85. using the sha1 algorithm.
  86. 8. The digest is stored in the outgoing message.
  87. 9. The message is transmitted.
  88. When a message is received (decrypt_and_authenticate):
  89. ------------------------------------------------------
  90. 1. sober is keyed with the private key and the initial vector is set to the
  91. salt in the received message. Then a 48 byte key is read from the sober
  92. algorithm. This 48 byte key is split into 3 16 byte keys. The keys are the
  93. hmac key, the sober key and the sober initial vector.
  94. 2. The sober key and sober initial vector from step #1 are used to key a
  95. new sober instance.
  96. 3. The hmac is setup using the hmac key generated in step #1 using sha1.
  97. 5. The message is authenticated, except for the security header.
  98. 6. If the message was not authenticated, the caller is told of the result.
  99. The caller ignores the message.
  100. 7. The message is decrypted, except for the security header, using the sober
  101. algorithm in step #2.
  102. 8. The message is processed.
  103. This does consume some resources. It ensures the private key is never shared
  104. openly, that messages are authenticated, that messages are encrypted, and that
  105. any key exposure of the sober encryption key, sober initial vector, or hmac
  106. key can only be used to attack one of the algorithms. Finally every key used
  107. is randomly unique (within the 2^128 search space of the input to sober) to
  108. ensure that keys are never reused, nonce's are never reused, and hmac's are
  109. never reused.
  110. USING LIBNSS
  111. ------------
  112. The process is similar in concept to the above, but most of the details are
  113. hidden inside the NSS library. When corosync is started up libnss is initialised,
  114. the private key is read into memory and stored for later use by the code.
  115. When a message is sent (encrypt_and_sign):
  116. ------------------------------------------
  117. - The message is encrypted using AES.
  118. - A digest of that message is then created using SHA256 and based on the
  119. private key.
  120. - the message is then transmitted.
  121. When a message is received (decrypt_and_authenticate):
  122. - A Digest of the encrypted message is created using the private key
  123. - That digest is compared to the one in the message security_header
  124. - If they do not match the packet is rejected
  125. - If they do match then the message is decrypted using the private key.
  126. - The message is processed.
  127. Compatibility
  128. -------------
  129. The default mode of operation is to allow for wire-compatibility with existing
  130. openais systems. That means that the internal encryption system is used
  131. and all received packets are expected to use that system. This allows a rolling
  132. upgrade from openais to corosync.
  133. Once all nodes in the cluster are running corosync they can be changed to allow
  134. the newer libnss-based encryption by setting the
  135. totem {
  136. crypto_accept: new
  137. }
  138. option in corosync.conf.
  139. This enables the new encryption system but does not switch it on. It simply
  140. adds a byte to the end of the packets to indicate the encryption type.
  141. Once all nodes have been upgraded and 'crypto_accept: new' has been set,
  142. the encryption type can be set using a single command:
  143. # corosync-cfgtool -c1
  144. This will tell all cluster nodes to start using libnss encryption. Note that
  145. it is possible to upgrade node individially by seetting the encryption type in
  146. corosync.conf. The last byte of the packet indicates the decryption algorithm
  147. that the receiver should use.
  148. Once all nodes are using libnss encryption, the option should be set in
  149. in corosync.conf so that it takes effect at the next system reboot.
  150. Comments welcome mailto:discuss@corosync.org