2.1.6 Man-In-The-Middle Attacks

What is a "Man-In-The-Middle" attack? When we communicate with a server, it is not uncommon to go through several devices on our way to the server. A Man-In-The-Middle attack is when a hacker makes use of one of the "pass-through" servers to maliciously manipulate the code for our application.

Unfortunately, there is nothing we can do in JavaScript to prevent this, but there are things we can do server-side. All communications should be encrypted with SSL (https). SSL stands for "Secure Socket layer". This encrypts the communication making man-in-the-middle attacks harder. We can ensure this is used by having the http protocol header use Strict-Transport-Security. There are also things we can do when transmitting cookies by only allowing http secure cookies to be transmitted.