Uni IT Security Notes

Notes for the IT security course at HdM Stuttgart

Felicitas Pojtinger

2022-02-01

These study materials are heavily based on professor Schmitz’s “IT Security” lecture at HdM Stuttgart and prior work of fellow students.

1.1 Basics

1.1.1 Security Mindset

1.1.2 Aspects of IT Security

1.1.3 Security Objectives

1.1.4 Safety vs. Security

1.1.5 Attacks, Threats and Vulnerabilities

1.1.6 Risk and Threat Analysis

graph TD
    subgraph Threat analysis
        A[System inventory and definition]-->B
        B[Threat identification]-->C
        C[Threat evaluation]
    end

    C-->D

    subgraph Risk analysis
        D[Impact evaluation]-->E
        E[Risk calculation]-->A
    end

1.1.7 Threat Identification

1.1.8 Trade-offs in Security

1.2 Security Frameworks

1.2.1 Network Specific Threat Examples

1.2.2 STRIDE: Attacks on a Multi-User System

1.2.3 Security Policies

1.2.4 Security Mechanisms and Concepts

graph TD
    A[Security policy]-->|requires|B
    B[Security objectives]-->|realized by|C
    C[Security mechanisms]-->|described by|D
    D[Security concept]

1.2.5 Mitigation Strategies

1.3 Malware

1.3.1 Malware General Definition

1.3.2 Infection Paths

1.3.3 Malware Types

1.3.4 Trojan Horses

1.3.5 Backdoors

Intentionally created remote code execution vulnerability/ingress into system (Hello, Five Eyes!).

1.3.6 Logic Bomb

Malicious function, which is called once condition evaluates to true.

1.3.7 Rootkit

Collection of services installed on a compromised system, which enables hiding …

from users other than root.

1.3.8 Advanced Persistent Threat

Advanced:

Persistent:

Threats: Often uses Zero-Day vulnerabilities

1.3.9 Botnet

1.3.10 Common Reasons for Vulnerabilities

Issues in …

… lead to attack vectors:

1.3.11 Side-Channel Attacks

Indirect (physical) attack on a system; i.e. smudge patterns on a smartphone

1.3.12 Buffer Overflow

1.3.13 Race Conditions

Information is being changed after it has been checked, but before it has been executed.

1.4 Networking

1.4.1 TCP Overview

1.4.2 TCP Connection Establishment

An example connection from the client to the server:

<Client>                                              <Server>

[Closed]                                              [Closed]
                  SEQ=x     CTL=SYN               =>
[SYN Sent]
              <=  SEQ=y     CTL=SYN+ACK   ACK=x+1
                                                      [SYN Received]
                  SEQ=x+1   CTL=ACK       ACK=y+1 =>
[Established]                                         [Established]

1.4.3 IP Security Issues

1.4.4 TCP Security Issues

1.4.5 Port Scanning

1.4.6 TCP Protection Mechanisms

1.4.7 Session Hijacking

1.4.8 RST Attacks (In-Connection DoS)

Inject packet with RST flag into ongoing connection: Connection has to be aborted immediately

1.4.9 Blind IP Spoofing

Firewall is configured to only allow one source IP address and destination IP address (A → B).

To circumvent this restriction:

  1. Attackers starts DoS attack on A to prevent A from sending RST packets to B
  2. Attacker sends TCP connection setup packet with A’s source IP address to B
  3. B sends SYN+ACK packet to A, but can’t respond due to DoS
  4. Attacker sends TCP connection ACK packet to B with ACK matching the initial sequence number chosen by B (which has to be guessed, as B sent the SYN+ACK packet to A, not the attacker)

Only works if B uses a predicable algorithm for it’s ISN and packet filters aren’t in place.

1.5 Perimeter Defense in Practice

1.5.1 Architecture Recommendations

1.5.2 Application in Networking

1.5.3 Stateless Packet Filter

1.5.4 Stateful Packet Filters

1.5.5 Stateful Firewalls

1.5.6 Application Layer Proxies

1.5.7 Application Level Gateways

1.5.8 Circuit Level Gateway

1.5.9 Demilitarized Zone (DMZ)

The DMZ creates 2/3 lines of defense by the use of a stub network.

Multi-Level DMZs can create even more secure perimeter defenses:

Global Internet → Access Router and Packet Filter → Public Services Host (offers i.e. public Web services) → Screening Router and Packet filter (prevents IP spoofing) → Mail host (for external mail communication) → Bastion host (i.e. proxy for FTP and Web access) → Intranet

1.5.10 Web Application Firewalls (WAFs)

1.5.11 Cross-Site Scripting (XSS)

Injection of malicious client-side code (JS, WASM) into site. There are multiple types:

1.5.12 Cross Site Request Forgery (CSRF)

Sniffing of cookies/tokens from a connection in another tab.

1.5.13 Intrusion Detection Systems (IDS)

1.5.14 Injections

1.6 Symmetric Encryption

1.6.1 Symmetric Encryption Overview

Alice:

  1. Creates message
  2. Chooses key
  3. Computes ciphertext
  4. Send ciphertext to Bob

Eve (Attacker):

  1. Copies ciphertext
  2. Tries to guess the key

Bob:

  1. Receives ciphertext
  2. Uses key
  3. Computes plaintext
  4. Reads message

1.6.2 Kerckhoffs’ Principle

1.6.3 Strong Algorithms

1.6.4 Crypto Attack Classes

1.6.5 Perfect Security

Ciphertext does not give any information you don’t already have about the plaintext (p(m(c))=p(m))

1.6.6 One-Time-Pad

1.6.7 Stream Cyphers

Encryption like one-time-pad, but using pseudo-random bits instead of true random (using a Crytographically Secure Pseudo-Random Number Generator (CSPRNG))

1.6.8 True Random Number Generators

1.6.9 (Cryptographically Secure) Pseudo-Random Number Generators (CSPRNG)

PSRNGs compute the output based on a seed and an internal state.

A CSPRNG must …

… when the initial state of the CSPRNG is not known

1.6.10 Design Principles for Block Cyphers

Two methods for frustrating a statistical analysis:

1.6.11 Feistel Networks

1.6.12 DES (Tripple DES)

1.6.13 AES Key Features

1.6.14 Modes of Operation for Block Cyphers

1.6.15 Cypher Block Chaining (CBC)

1.6.16 Counter Mode (CTR)

1.6.17 Padding

1.6.18 Key Length Considerations

1.7 Message Authentication

1.7.1 Message Authentication Codes (MACs)

1.7.2 General Scenario

Alice:

  1. m = "I love you. Alice"
  2. Select secret key K
  3. Compute MAC_K(m)

Bob:

  1. Receives m'
  2. Selects secret key K
  3. Computes MAC_K(m')
  4. Compares computed MAC with received MAC → Matches!

Assertion: If computed MAC equals the MAC included in the received message, an owner of the key (Alice) really sent this message and it was not changed on the way.

1.7.3 Scenario with Modified Message

Alice: Same as in General Scenario

Mallory:

Bob

  1. Receives m'
  2. Selects secret key K
  3. Computes MAC_K(m')
  4. Compares computed MAC with received MAC → Doesn’t match!
  5. Ignore m

1.7.4 MAC Computation

1.7.5 Hash Function Requirements

1.8 Asymmetric Encryption

1.8.1 Public Key Cryptography

Alice:

  1. Generates key pair (PK_{Alice},SK_{Alice})
  2. Published PK_{Alice} at Trent’s
  3. c received → decrypts m=D_{SK_{Alice}}(C)

Trent:

Bob:

  1. Wants to send m to Alice confidentially
  2. Obtains PK_{Alice} from Trent
  3. Computes c=E_{PK_{Alice}}(m)
  4. Sends c to Alice

1.8.2 RSA Key Generation

Also see the handwritten notes.

  1. Alice chooses 2 large prime numbers p, q and computes n=p \cdot q, \phi(n)=(p-1)(q-1)
  2. Alice chooses an integer e with 1<e<\phi(n) that is relatively prime to \phi(n)
  3. Alice computes an integer d with 1<d<\phi(n) and d \cdot e = k \cdot \phi(n) + 1
  4. Alice publishes her public key PK_{Alice}=(e,)
  5. Alice keeps her private key SK_{Alice}=d and p, q, \phi(n) secret

1.8.3 RSA Encryption

Also see the handwritten notes.

  1. Bob obtains PK_{Alice}=(e,n)
  2. Bob composes plaintext m \in M=\{1,2,...,n-1\}
  3. Bob computes the ciphertext c=E_{PK{Alice}}(m)=m^e\mod n
  4. Bob sends c to Alice

1.8.4 RSA Decryption

Also see the handwritten notes.

Alice can obtain the plaintext message m by computing m=D_{SK_{Alice}}(c)=c^d\mod n = m^{ed} \mod n

1.8.5 RSA Security

1.8.6 Hybrid Method

Combination of asymmetric and symmetric key methods.

Alice:

  1. Generates key pair (PK_{Alice}, SK_{Alice})
  2. Publishes PK_{Alice} at Trent’s
  3. c received → Decrypts K=D_{SK_{Alice}}(c)
  4. Alice and bob switch over to the symmetric key algorithm with key K

Trent:

Bob:

  1. Obtains PK_{Alice} from Trent
  2. Generates symmetric key K
  3. Computes c=E_{PK_{Alice}}(K)
  4. Sends c to Alice

1.8.7 Discrete Logarithms

Primitive element: Let p be a prime number. An element g\leq p-1 is called primitive element \mod p if for each A \in \{1,2,...,p-1\} there is an x such that A=g^x \mod p

Discrete logarithm: Let p be a prime number and let g \leq p-1 be a primitive element \mod p. Then an element x is called discrete logarithm of A to base g \mod p if A=g^x \mod p.

Discrete logarithm problem: Given A, g, p, find x \leq p-1 with A=g^x \mod p

1.8.8 One-Way Functions

1.8.9 Diffie-Hellman Key Exchange Protocol

Purpose: Allow communication partners without prior knowledge of another to establish a shared secret key over an insecure communication channel

Also see the handwritten notes.

  1. Alice and Bob agree publicly on prime number p and a primitive element g \leq p-1
  2. Alice randomly chooses \alpha \in \{2,...,p-2\} and computes A=g^\alpha \mod p
  3. Bob randomly chooses \beta \in \{2,...,p-2\} and computes B=g^\beta \mod p
  4. Alice and Bob publicly exchange A and B
  5. Alice and Bob hold a common secret key K:
    1. K_B=A^\beta \mod p=g^{\alpha \beta} \mod p
    2. K_A=B^\alpha \mod p=g^{\alpha \beta} \mod p = K_B

1.8.10 Diffie-Hellman Key Exchange Protocol Security

It depends on three properties which can’t be relaxed:

1.9 Trust

1.9.1 Digital Signatures

Alice:

  1. Generates key pair (PK_{Alice}, SK_{Alice})
  2. Publishes PK_{Alice} at Trent’s
  3. Computes sigAlice(m)=E_{SK_{Alice}}(hash(m))

Trent:

Bob:

  1. Obtains PK_{Alice} from Trent
  2. Computes hash(m_{received})
  3. Decrypts signature D_{PK_{Alice}}(sig_{received})
  4. Compares hash(m_{received}) to the received signed hash

1.9.2 RSA Signatures

1.9.3 Certificates

1.10 Transport Security

1.10.1 Internet Model

1.10.2 TLS Handshake Overview

title TLS Handshake

Client->Server: Hello
Server->Client: Hello
Server->Client: Cert public key
Server->Client: Hello Done

note over Client: Pre-master secret
note over Client: Symmetric key

Client->Server: Change cypher key exchange
Client->Server: Client finished

note over Server: Pre-master secret
note over Server: Symmetric key

Server->Client: Change cypher sec
Server->Client: Finished

Client<->Server: Encrypted data transfer

1.10.3 TLS Record Protocol

Sender:

  1. Fragmentation
  2. Compression (optional)
  3. MAC computation (Key dependent; MD5, SHA-1, SHA-256 etc.)
  4. Encryption

Receiver:

  1. Decryption
  2. MAC verification
  3. Decompression (optional)
  4. Reassembly

1.10.4 Connection States

1.10.5 SSH Transport Layer Protocol

1.11 Frequently Asked Questions

1.11.1 Phishing Attacks

1.11.2 Phishing Attack Prevention

1.11.3 Certificates and CAs

1.11.4 Certificate Revocation

1.11.5 Validation of Certificates

1.11.6 Why can DES be decrypted even though F is not invertible?

1.11.7 SQL Injection

1.11.8 DNS Spoofing

1.11.9 Replay Attacks and Signatures

1.11.10 VPN Access from Intranet to external Mail Server

1.11.11 Stateless vs. Stateful Packet Filters/Firewalls

1.11.12 Hash Functions and their Applications

1.11.13 Diffie-Hellman Key Exchange Man-in-the-Middle Attack

1.11.14 Diffie-Hellman Key Exchange Protocol Characteristics

Sequence diagram of protocol

It is an asymmetric challenge-response protocol which is used to provide authentication by checking authentication factors. It does so by sending a hash of a random number, which has been encrypted using Alice’s public key/cert, to Alice, who then decrypts the hash and sends it to Bob.

1.11.15 Plaintext Awareness

1.11.16 Key Reuse in the One-Time Pad

The following is no longer true (C = Cypher, K = Key, M = Message):

C1=M1+K
C2=M2+K
D=C1-C2=(M1+K)-(M2+K)=M1-M2

The difference D now has the same characteristics like M1-M2; this means that frequency analysis can be used.

1.11.17 Ingress and Egress

1.11.18 Caesar Cypher Vulnerability

1.11.19 Authentication vs. Authorization

1.11.20 TCP Vulnerabilities if PRNG is predicable

Attacker can generate a sequence number, which can be used in an existing session between two communication partners → Enables session hijacking

1.11.21 Analog Examples for Security Objectives

1.11.22 Server vs. Client Authentication in HTTPS

A web server is typically accessible to anyone; it is not important who accesses it. A client however wants to know that a site is trustworthy/authentic, which is why typically only the server is authenticated.

1.11.23 Vulnerabilities of non-revoked, faked Certs

1.11.24 Applied Security Objectives

A person is communicating with amazon.com.

1.11.25 Firewall Appliance vs. Personal Firewall

1.11.26 Diffie-Hellman vs. RSA

1.11.27 Indirect Blocklisting

Sender’s mail address is faked and used to send spam, which leads the recipient to block the sender’s address, despite them never having sent any spam themselves. Can be fixed by checking signature and certificate instead and blocking based on signature or blocking all messages without signature or certificate.