ssl_prequisites.tex 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. \chapter{The Secure Layer \label{chap:ssl}}
  2. Transport Layer Security, formerly known as SSL (Secure Socket Layer), aims
  3. to bring some security features over a communication channel, specifically
  4. providing \strong{integrity} and \strong{confidentiality} of the message, \strong{authenticity} of the server and
  5. optionally the client.
  6. %% fuck osi layers: there is no code explicitly structuring the internet in 7
  7. %% layers.
  8. Many ancient application protocols wrapped themselves to be over TLS/SSL, with
  9. the only difference of the ``s'' appended to the protocol name (such as HTTPs,
  10. IMAPs).It is nowadays widely adopted all over the world, becoming the de-facto standard for
  11. end-to-end encryption.
  12. \paragraph{Certification Authorities} are authorities to whom it is granted the
  13. power to \emph{authenticate} the peer. Pragmatically, they are public keys
  14. pre-installed on your computer that decide who and who not to trust employing
  15. of a digital signature. A more detailed analysis of the inside of a certificate
  16. will be given in section ~\ref{sec:ssl:x509}.
  17. In order to overcome the proliferation of keys to distribute, and satisfy the
  18. use-case of a mindless user willing to accomplish a secure transaction on the
  19. internet, the concept of a hierarchical model issuing digital certificates
  20. proliferated with the following trust model:
  21. \\
  22. \\
  23. %% E` BELLISSIMO QUESTO COSO
  24. \begin{center}
  25. \begin{tikzpicture}[
  26. scale=.8,
  27. ->,>=stealth',
  28. ,level/.style={sibling distance = 10cm/#1,
  29. level distance = 2.5cm}]
  30. \node {Root CA}
  31. child{ node {\small{Intermediate CA}}
  32. child{ node {Issuer CA}
  33. child{ node {} edge from parent node[above left]
  34. {\tiny{loltrust}}}
  35. child{ node {}}
  36. }
  37. child{ node {CA}
  38. child{ node {Sub-CA}}
  39. child{ node {}}
  40. }
  41. }
  42. child{ node {\small{Intermediate CA}}
  43. child{ node {CA}
  44. child{ node {hacked computer}}
  45. child{ node {CA}}
  46. }
  47. child{ node {GVMT CA}
  48. child{ node {}}
  49. child{ node {}}
  50. }
  51. }
  52. ;
  53. \end{tikzpicture}
  54. \end{center}
  55. \paragraph{The protocol} is actually a collection of many sub-protocols:
  56. \begin{itemize}
  57. \setlength{\itemsep}{1pt}
  58. \setlength{\parskip}{0pt}
  59. \setlength{\parsep}{0pt}
  60. \item \strong{\emph{handshake}} protocol, a messaging protocol that allows to
  61. \emph{authenticate} the peers, and eventually restore a past encrypted
  62. session.
  63. \item \strong{\emph{record}} protocol, permitting the encapsulation of higher level protocols,
  64. like HTTP and even the next two sub-protocols. It is the fulcrum for all data
  65. transfer.
  66. \item \strong{alert} protocol, which steps-in at any time from handshake to closure of the
  67. session in order to signal a fatal error. The connection will be closed
  68. immediately after sending an alert record.
  69. \item \strong{changespec} protocol, to negotiate with and notify the receiver that
  70. subsequent records will be protected under the just negotiated keys and
  71. \texttt{Cipher Spec}.
  72. \end{itemize}
  73. We will proceed with a brief synopsis of the first two of these protocols,due to
  74. their relevant role inside the connection and furthermore, because they are the
  75. only two we actually made use of during our investigations.
  76. \section{The \texttt{handshake} protocol}
  77. As mentioned above, the handshake occurs whenever a machine attempts to start
  78. a TLS connection. If there is no session identifier, a new one is being build
  79. up; otherwise the client will include the session-id in the initial
  80. communication and the server will eventually skip the key agreement phase since
  81. it has already happened recently.\footnote{``recently'' is not well-defined in
  82. the standard - it is suggested an upper limit of 24-hours lifetime, but the
  83. only constraint is that both client and server shall agree on it.}\\
  84. A new session-id identifier gets built via a challenge-response mechanism: the
  85. client issues a challenge, the server chooses a connection-id and presents it
  86. with its certificate. The client verifies the server's identity, and then
  87. chooses both a session key and the security specifications for the current
  88. session. Note that the session key should be different for any connection and
  89. direction. At this point the server can either send back the challenge and
  90. generate a session-id, or it can ask for the client
  91. certificate and finally ask for it (client authentication).
  92. \section{The \texttt{record} protocol}
  93. All TLS protocol messages moves in records of up to 16K, containing 3
  94. main components: MAC-data, data, and padding.
  95. \\
  96. {MAC-data} is no other than the Message Authentication Code over the
  97. encrypted \emph{data} sent
  98. (SSL performs the encrypt-than-mac mode of operation).
  99. It provides \strong{authenticity} and \strong{integrity} of the message.
  100. Failure to authenticate, decrypt will result in I/O error and a close of the
  101. connection.
  102. \\
  103. {Data} is the actual message, compressed and encrypted. Compression comes
  104. for free in order to fasten cryptanalysis of the cipher, since protocols such
  105. as HTTP have a common set of standard message.
  106. \\
  107. The {Padding} section contains informations about the padding algorithm
  108. adopted, and the padding size.
  109. \section{What's inside a certificate \label{sec:ssl:x509}}
  110. SSL certificates employed the X.509 PKI standard, which specifies, among other
  111. things, the format for revocation lists, and certificate path validation
  112. algorithms:
  113. \\
  114. \begin{center}
  115. \scalebox{0.7}{
  116. \begin{bytefield}[bitwidth=0.95em]{16}
  117. \begin{rightwordgroup}{Certificate}
  118. \wordbox{1}{Version} \\
  119. \wordbox{1}{Serial Number} \\
  120. \wordbox{1}{Algorithm ID} \\
  121. \wordbox{2}{Validity \\ \tiny{$\angular{\text{NotBefore, NotAfter}}$}} \\
  122. \wordbox{2}{Issuer \\ \tiny{eventually plus Issuer Unique Identifier}} \\
  123. \wordbox{2}{Subject \\ \tiny{eventually plus Subject Unique Identifier}} \\
  124. \wordbox{2}{Subject Public Key Information \\
  125. \tiny{$\angular{\text{PubKey algorithm, PubKey}}$}} \\
  126. \wordbox[lrt]{1}{Extensions} \\
  127. \skippedwords \\
  128. \wordbox[lrb]{1}{}
  129. \end{rightwordgroup} \\
  130. \wordbox{1}{Certificate Signature Algorithm} \\
  131. \wordbox{1}{Certificate Signature} \\
  132. \end{bytefield}
  133. }
  134. \end{center}
  135. It is a pretty old standard, defined in the eighties by the ITU.
  136. Born before HTTP, it was initially thought \emph{in abstracto} to be
  137. extremely flexible and general\footnote{
  138. \textit{``X.509 certificates can contain just anything''} ~\cite{SSLiverse}
  139. }.
  140. And precisely this flexibility and its adaptation to the SSL/TLS protocol
  141. without a very-well defined structure have been its major flaws: it is still
  142. difficult to write good, reliable software parsing a X.509 certificate.
  143. \section{Remarks among SSL/TLS versions}
  144. The first, important difference to point out here is that SSLv2 is no more
  145. considered secure. There are known attacks on the ciphers adopted (md5, for
  146. example) as well as protocol flaws.
  147. SSLv2 would allow a connection to be closed via a not-authenticated TCP segment
  148. with the \texttt{FIN} flag set. Padding informations are sent in clear, and the
  149. payload is not compressed before encrypting, allowing a malicious attacker
  150. traffic analysis capabilities. The ciphersuite is negotiated using
  151. non-authenticated informations, allowing an attacker to influence to choice and
  152. weaken the security of the communication.
  153. Most of these vulnerabilities have been addressed by the later SSLv3, which
  154. introduced compression and protection against truncation attacks.
  155. Its standardized twin, TLS 1.0, only differs on the cipher suite and key
  156. calculation requirements, strengthen in order to increase the security of the
  157. channel.
  158. Both SSLv3 and TLS 1.0 have been threatened in 2011 by an attack that could break
  159. the same origin policy, known as BEAST. It is not dramatic, and almost any
  160. browser now mitigates its spectrum of action.
  161. TLS 1.1, and TLS 1.2 are considered safe as of today.
  162. %%% Local Variables:
  163. %%% mode: latex
  164. %%% TeX-master: "question_authority.tex"
  165. %%% End: