Computer Engineering is coming soon

We're still writing and reviewing the notes for every subject, and we'll open it when every subject is ready. Meanwhile you can practise aptitude, ask Aria about any subject, or see the branches that are ready.

Security attacks, services and mechanisms

Clear definitions and mappings of security attacks (active/passive, insider/outside, DoS, spoofing, replay, etc.), security services (confidentiality, integrity, availability, authentication, non-repudiation, access control) and the mechanisms (encryption, MACs, digital signatures, timestamps, seque

Drafted with Aria, reviewed by the AiCanCode.org team · Updated . How we write and check our notes. Spotted an error? Use Give Feedback at the bottom of the page.

Why it matters

Security engineers design networks and systems to resist attackers and to provide guarantees to users. Understanding common attacks (what an adversary does), services (what security goals we want) and mechanisms (concrete tools to achieve those goals) is needed when you write requirements, choose protocols (e.g. TLS, IPsec), configure firewalls and loggers, and diagnose incidents.

Key ideas

Definitions (each bolded term is defined the first time used):

  • Threat — a potential cause of an unwanted incident that may result in harm to a system or organization. (An event or circumstance.)
  • Vulnerability — a weakness in a system that can be exploited by a threat to perform an attack.
  • Attack — an attempt by a threat agent to violate the security of a system. Attacks can be classified in multiple orthogonal ways.
  • Security service — a property the system must provide to defend against attacks (examples follow).
  • Security mechanism — a specific technique, algorithm or protocol component used to provide one or more security services (examples follow).

Classification of attacks (precise definitions):

  • Passive attack — an attack that attempts to learn or make use of information from the system but does not affect system resources. Example: eavesdropping (also called interception) where an adversary reads packets on a link, and traffic analysis (observing timing/size patterns).
  • Active attack — an attack that attempts to modify system resources or affect their operation. Examples: modification, replay, masquerade, and denial of service (DoS).
  • Insider attack — performed by an actor who has legitimate access credentials but abuses them.
  • Outsider attack — performed by an actor without legitimate access.
  • Spoofing (or masquerade) — presenting false identity or source data to gain unauthorized access.
  • Replay attack — re-transmitting a previously captured valid message to produce an unauthorized effect.
  • Man-in-the-middle (MITM) — attacker interposes between two parties and can read and modify messages in transit.
  • Denial of Service (DoS) — actions that reduce or eliminate availability of a service for legitimate users. When done from many sources it is Distributed DoS (DDoS).

Security services (the classic list and precise definitions):

  • Confidentiality — assurance that information is not disclosed to unauthorized entities. (Often provided by encryption.)
  • Integrity — assurance that information has not been altered in an unauthorized manner. (Often provided by message authentication codes (MACs) or digital signatures.)
  • Availability — assurance that authorized users have access to information and resources when needed. (Defended by redundancy, rate-limiting, DoS mitigation.)
  • Authentication — assurance of the identity of an entity (user, process, or device). Can be one-way or mutual.
  • Non-repudiation — prevention of denial by one party about having performed an action (e.g., digital signatures provide non-repudiation of origin).
  • Access control / Authorization — mechanisms that determine and enforce what authenticated subjects are allowed to do.
  • Accountability / Auditing — keeping reliable records (logs) of actions so that behavior can be traced to actors.

How mechanisms map to services (exact statements):

  • A properly keyed symmetric encryption algorithm + secure key management provides confidentiality. Note: encryption without an integrity check (MAC/AEAD) is vulnerable to modification attacks; use authenticated encryption to get confidentiality + integrity.
  • A message authentication code (MAC) provides integrity and authentication of origin (assuming the key is only known to legitimate sender/receiver). MACs do not provide non-repudiation because the key is shared.
  • A digital signature (using a private key) provides integrity, authentication of origin, and non-repudiation (under the assumption that private keys are not compromised and a trustworthy PKI links keys to identities).
  • Timestamps, nonces (numbers used once) and sequence numbers are mechanisms to prevent replay attacks. Exactly: if each message includes a nonce that the receiver verifies as fresh, then replayed messages are rejected.
  • Certificates and public key infrastructure (PKI) provide binding between public keys and identities, enabling authentication and non-repudiation in open networks.
  • Firewalls, intrusion detection systems (IDS), and rate limiters are mechanisms aimed mainly at availability, access control, and detection.

Security goals are relative and depend on assumptions. Example assumption chains universities ask for: to claim "digital signatures give non-repudiation" you must assume (1) private keys are secret and protected, (2) a certificate or other method reliably binds the public key to an identity, and (3) the signing algorithm is unforgeable under chosen-message attack.

Exam-style diagram to draw for a replay attack and what to label: draw a sequence diagram with three vertical lifelines labelled "A (sender)", "Network / Attacker (M)" and "B (receiver)". Draw an arrow A→Network labelled "M = message, seq=1, MAC(K, M||seq)". From Network to B draw the same arrow. Then draw a dashed arrow from Network to B later labelled "replay of M, seq=1". Label the receiver's check: "if seq not fresh then reject". This shows capture and replay.

Formulas

Availability A = MTBF / (MTBF + MTTR) — where A is availability (dimensionless fraction between 0 and 1), MTBF is mean time between failures (seconds), MTTR is mean time to repair (seconds). Applies to system reliability/availability modeling under the assumption of exponential failure and repair distributions for a simple up/down model. Equivalently, expected downtime per year D_year = (1 - A) * 31,536,000 s (assuming 365 days/year).

Expected brute-force attempts for n-bit key or MAC = 2^(n-1) — where n is number of bits, dimensionless. This is the expected number of random guesses to find the key or MAC by exhaustive search assuming uniform distribution and that attacker stops on first success.

Expected brute-force time T = 2^(n-1) / R — where T is seconds, n is bits, R is attempts per second (s^-1). Applies when attempts are independent and attacker can test R candidates per second.

Work factor (bits) ≈ log2(number of operations) — where work factor in bits expresses computational effort as equivalent key size. Birthday bound for hash collisions: expected trials ≈ 1.17 * 2^(n/2) — for an n-bit ideal hash; dimensionless number of trials.

Note: SI unit for time is second (s). For rates use s^-1.

Worked examples

Example 1 — classify the attack and choose mechanisms (theory question): Question: "A user A uploads a file to a server S over the Internet. An attacker E on the same Wi-Fi captures the TCP stream and later forwards the captured TCP packets to S to cause S to process the same upload again. Classify the attack and propose countermeasures." Answer (model):

  1. Classification: This is a passive capture followed by an active replay (an active attack because the attacker causes an unauthorized repeat of an action). It is a network-layer and transport-layer replay. Attacker is an outsider with network access.
  2. Services violated: Potentially integrity (if duplicate processing alters state) and availability (if repeats consume resources), and authorization if replayed action performs a state-changing privileged operation.
  3. Mechanisms to prevent: (a) Use application-level nonces or sequence numbers plus server-side freshness checks. (b) Use authenticated encryption (AE) or MAC that binds message contents and nonce. (c) Use TLS (record sequence numbers and AEAD/MACs); note TLS 1.3 0-RTT early data is replayable, so make early operations idempotent or disable 0-RTT. (d) Use timestamps with allowed skew, if clocks are synchronized.
  4. Implementation note: server must store or be able to verify freshness without unbounded storage (e.g., maintain per-client last-seen sequence number or use unique request IDs).

Example 2 — step-by-step trace of preventing replay using nonces (algorithmic): Protocol: Client C wants to send command M to Server S; they share symmetric key K.

  1. C → S: "I want to send M" (optional).
  2. S → C: nonce N (random 128-bit).
  3. C computes MAC = MAC_K(M || N) and sends C → S: {M, N, MAC}.
  4. S verifies MAC_K(M || N) using stored K and the N received; if correct and N matches the outstanding challenge, process M; otherwise reject. Why it works: N is random and single-use; a captured {M, MAC} is not reusable because the server will issue a fresh N next time, so the MAC over old N will not match.

Example 3 — numerical: time to brute-force a 32-bit MAC at 10^9 attempts/second

  1. Formula: T = 2^(n-1) / R.
  2. Substitute n = 32, R = 1e9 s^-1: T = 2^(31) / 1e9 attempts per second.
  3. Compute: 2^31 = 2,147,483,648 ≈ 2.147e9. So T ≈ 2.147e9 / 1e9 = 2.147 s.
  4. Final answer: ≈ 2.15 seconds expected. (Shows why 32-bit MACs are weak for high-speed attackers.)

Common mistakes

  • Thinking that if traffic is encrypted it is immune to all attacks — encrypted traffic can still be replayed, delayed, or used for traffic analysis.
  • Forgetting insider threats: assuming all attackers are outsiders leads to poor design of access control and logging.
  • Ignoring assumptions when claiming security: e.g., claiming MACs provide authentication but ignoring key leakage.

For your exam

Question types you will see:

  • Definitions and short notes (define attacker types, services, mechanisms). Full-marks answers give crisp definitions and one-line examples.
  • Diagram questions (draw a replay or MITM attack sequence diagram). Full answer includes a labeled sequence diagram and brief explanation of how to stop it.
  • Derivations and proofs (show why nonces prevent replay in a challenge-response). Full answer steps through protocol runs and shows an adversary’s inability to produce a valid response without the nonce.
  • Numericals (brute-force time / availability). Full marks: write formula, substitute units, compute stepwise, give final answer with units.
  • Design/analysis: given a scenario, classify attacks, list violated services, propose mechanisms and justify them (state assumptions about keys, clocks, storage). Full answer states assumptions and maps each mechanism to the service it provides.

Exam writing tips: always state your assumptions (e.g., "assume clocks are synchronized within ±Δ" or "assume symmetric key is secret"). If asked for a diagram, draw a simple sequence diagram and label messages, attackers and checks.

Quick check

  1. What is a replay attack?
  2. Name two mechanisms that provide integrity.
  3. Why does a MAC not provide non-repudiation when the key is shared?

Answers: 1) Re-transmission of a previously captured message to cause unauthorized effect. 2) Message Authentication Code (MAC) and Digital Signature. 3) Because both sender and receiver know the shared key, either could have generated the MAC, so the sender can deny having produced it (no proof to third party).

Finished this topic? Mark it so your progress, study plan and readiness keep up.

Stuck on something here?