Skip to main content

TLS and Network Security

TLS / HTTPS​

TLS provides confidentiality, integrity and authentication for a connection. HTTPS is HTTP over TLS.

Handshake (TLS 1.3, simplified)​

Client                                  Server
ClientHello (versions, ciphers, key share) ->
<- ServerHello, certificate, key share, Finished
Finished ->
=== encrypted application data ===
  1. The client and server agree on parameters and exchange key shares.
  2. The server proves its identity with a certificate signed by a trusted certificate authority (CA).
  3. Both derive the same symmetric session keys (fast bulk encryption).
PrimitiveRole
Asymmetric crypto (RSA, ECDSA, ECDH)Authentication and key exchange
Symmetric crypto (AES-GCM, ChaCha20)Encrypting the data
Hashes / MACs (SHA-256, HMAC)Integrity

Firewalls and proxies​

ComponentRole
Packet-filter firewallAllow or block by IP, port, protocol
Stateful firewallTracks connection state
Web application firewallInspects HTTP traffic for attacks
Forward proxyClients reach the Internet through it
Reverse proxy / load balancerSits in front of servers
VPNEncrypted tunnel across an untrusted network

Common attacks​

AttackDescriptionMitigation
Sniffing / MITMReading or altering trafficTLS, certificate validation
DoS / DDoSOverwhelm a serviceRate limiting, CDN, scrubbing
SYN floodExhaust half-open connectionsSYN cookies
ARP spoofingPoison ARP cachesDynamic ARP inspection
DNS spoofingForge DNS answersDNSSEC, DoT / DoH
XSSInject script into pagesOutput encoding, CSP
CSRFTrick a browser into sending requestsSameSite cookies, CSRF tokens
SQL injectionInject SQL via inputParameterised queries
CAUTION

Never disable certificate verification in production code to "make it work". It removes the authentication half of TLS.