4

I have a question about sessions implemented through cookies. I have just started to learn about security and I apologise if this question comes across as something elementary.

Let's say I'm using HTTPS, so all cookie data is encrypted and only the server can decrypt it with its private key. But that still isn't stopping someone from sniffing my traffic, and seeing the exact same string in the headers of every request. So someone sniffing traffic can figure out that this constant string in every request header may be a session cookie. If the attacker tries changing any characters within the request body or cookie, it will appear as junk on the server during decryption. However, even though it is encrypted, the attacker can re-submit the request and perform replay attacks, right?

Am I right to say that SSL/TLS prevents cookie tampering, but does not actually prevent stealing and/or replaying?

2
  • "it will appear as junk on the server during decryption" You seem to be under the impression that encryption is mostly about secrecy. Encryption in HTTPS is first about integrity then about secrecy. You can have integrity without secrecy on the HTTP content, you can't possibly have secrecy of HTTP without integrity in the context of a Web browser.
    – curiousguy
    Jul 9, 2018 at 1:51
  • 1
    An answer is already provided but another thing to point out is, that the request is actually not encrypted using the public key of the web server. During TLS handshake, a symmetric key is negotiated, as asymmetric crypto (especially operations involving the private key) is considerably slower (x1000) compared to symmetric crypto. This key is a session key, so it changes over time, generating different "data mud" each time an attacker captures the "same request". In addition "Forward Secrecy" is also provided by this approach.
    – GxTruth
    Jul 9, 2018 at 11:43

1 Answer 1

8

TL;DR: HTTPS prevents both cookie tampering and also cookie stealing and replaying by a man in the middle.

First, HTTPS not only encrypts the cookie but the whole traffic. And, due to the way the encryption is done (random IV and also different encryption key for each TLS session) encrypting the same plain data always results in different encrypted data. This means that an attacker will always see different encrypted data where the cookie is transferred. Also, replaying any encrypted data later will only result in a decryption error.

Note that there are attacks which make use of side channels (size of compressed data) to extract cookies. See Current State of BREACH (GZIP SSL Attack)? and others for more information.

You must log in to answer this question.