Part I: Fundamentals

Introduction to Security Overview for SRE

The Wide Area of security


Authentication vs Authorization

Common authentication flow (local authentication)

OpenID/OAuth

OpenID is an authentication protocol that allows us to authenticate users without using a local auth system. In such a scenario, a user has to be registered with an OpenID Provider and the same provider should be integrated with the authentication flow of your application. To verify the details, we have to forward the authentication requests to the provider. On successful authentication, we receive a success message and/or profile details with which we can execute the necessary flow.

OAuth is an authorization mechanism that allows your application user access to a provider(Gmail/Facebook/Instagram/etc). On successful response, we (your application) receive a token with which the application can access certain APIs on behalf of a user. OAuth is convenient in case your business use case requires some certain user-facing APIs like access to Google Drive or sending tweets on your behalf. Most OAuth 2.0 providers can be used for pseudo authentication. Having said that, it can get pretty complicated if you are using multiple OAuth providers to authenticate users on top of the local authentication system.


Cryptography

Ciphers


E(k,m) = c
D(k,c) = m


D(k,E(k,m)) = m

Stream Ciphers:

Block Ciphers:

Encryption

Symmetric Key Encryption

DES

Triple DES

AES

Asymmetric Key Algorithm

image8

NOTE: In terms of TLS key exchange, this is the common approach.

Diffie-Hellman

RSA

Hashing Algorithms

MD5

SHA-1

NOTE: SHA-1 is also recently demonstrated to be broken, Minimum current recommendation is SHA-256

Digital Certificates

CA Enrollment process

  1. The end host generates a private-public key pair.
  2. The end host generates a certificate request, which it forwards to the CA.
  3. Manual human intervention is required to approve the enrollment request, which is received by the CA.
  4. After the CA operator approves the request, the CA signs the certificate request with its private key and returns the completed certificate to the end host.
  5. The end host writes the certificate into a nonvolatile storage area (PC hard disk or NVRAM on Cisco routers).

Refer: https://www.ssh.com/manuals/server-zos-product/55/ch06s03s01.html

Login Security

SSH

image9

What SSH is not:

The major features and guarantees of the SSH protocol are:

Kerberos

The KDC includes following two servers:

Certificate Chain

The first part of the output of the OpenSSL command shows three certificates numbered 0, 1, and 2(not 2 anymore). Each certificate has a subject, s, and an issuer, i. The first certificate, number 0, is called the end-entity certificate. The subject line tells us it’s valid for any subdomain of google.com because its subject is set to *.google.com.

$ openssl s_client -connect www.google.com:443 -CApath /etc/ssl/certs CONNECTED(00000005) depth=2 OU = GlobalSign Root CA - R2, O = GlobalSign, CN = GlobalSign verify return:1 depth=1 C = US, O = Google Trust Services, CN = GTS CA 1O1 verify return:1 depth=0 C = US, ST = California, L = Mountain View, O = Google LLC, CN = www.google.com verify return:1 --- Certificate chain 0 s:/C=US/ST=California/L=Mountain View/O=Google LLC/CN=www.google.com i:/C=US/O=Google Trust Services/CN=GTS CA 1O1 1 s:/C=US/O=Google Trust Services/CN=GTS CA 1O1 i:/OU=GlobalSign Root CA - R2/O=GlobalSign/CN=GlobalSign --- Server certificate

TLS Handshake

  1. The client sends a HELLO message to the server with a list of protocols and algorithms it supports.
  2. The server says HELLO back and sends its chain of certificates. Based on the capabilities of the client, the server picks a cipher suite.
  3. If the cipher suite supports ephemeral key exchange, like ECDHE does(ECDHE is an algorithm known as the Elliptic Curve Diffie-Hellman Exchange), the server and the client negotiate a pre master key with the Diffie-Hellman algorithm. The pre master key is never sent over the wire.
  4. The client and server create a session key that will be used to encrypt the data transiting through the connection.

At the end of the handshake, both parties possess a secret session key used to encrypt data for the rest of the connection. This is what OpenSSL refers to as Master-Key

NOTE

“Perfect” Forward Secrecy