Winter Semester 2026–27 · VIT-AP · BACSE106 · Operating Systems · Dr. Krithika L.B

Session 5.3: Program and network threats; cryptography as a security tool

The CIA goals of security, how Trojan horses, trap doors, buffer overflows, viruses, worms and denial-of-service attacks work, and how symmetric, public-key and hash-based cryptography defend against them.

Module 5 1.5 hours Theory CO5
← Before
5.2 Disk scheduling
FCFS … C-LOOK
You are here
5.3 Program and network threats; cryptography as a security tool
Module 5 · Managing Devices, Security, Protection and Virtualization
Next →
5.4 Protection
Domains, access matrix

Learning objectives

By the end of this session you should be able to:

  • State the goals of security and distinguish threats from attacks and security from protection.
  • Explain Trojan horses, trap doors, logic bombs, buffer overflows, viruses and worms.
  • Describe worms, port scanning and denial-of-service attacks.
  • Compare symmetric and asymmetric encryption and work through a toy RSA example.
  • Explain hashes, MACs, digital signatures and how TLS combines them.

Lecture notes

1. The security problem

A system is secure if its resources are used and accessed as intended under all circumstances. Security distinguishes threats (potential violations) from attacks (attempts to break security). The classic goals are confidentiality (no unauthorised reading), integrity (no unauthorised modification) and availability (no unauthorised destruction or denial of service) — the CIA triad. Security must be applied at four levels: physical, human (phishing, social engineering), operating system, and network.

Protection (Session 5.4) is the internal mechanism controlling access to resources; security also guards against external attacks.

2. Program threats

Trojan horse

A program that appears useful but secretly misuses the rights of the user who runs it — e.g. a fake login screen that steals passwords, or a free utility that installs spyware.

Trap door (back door)

A hidden entry point left by the programmer, e.g. a secret user ID or password that bypasses checks. Can even be inserted by a compromised compiler.

Logic bomb

Code that does harm only when a condition is met — a date, or the programmer's name disappearing from the payroll.

Stack / buffer overflow

Writing past the end of an array on the stack to overwrite the return address, so the function “returns” into code supplied by the attacker. The most common attack on network services.

Virus

A fragment of code embedded in a legitimate program; it replicates by infecting other programs and needs a host to run. Types: file, boot-sector, macro, polymorphic, stealth…

Worm

A standalone program that spreads itself over the network without a host program (see below).

How a buffer overflow happens
#include <string.h>

void greet(char *input)
{
    char buffer[16];
    strcpy(buffer, input);      /* no length check! */
}
/* An input longer than 16 bytes overwrites the saved frame pointer
   and the return address on the stack. A crafted input puts machine
   code in the buffer and sets the return address to point to it.
   Fixes: strncpy/snprintf, bounds checks, non-executable stacks (NX),
   address-space layout randomisation (ASLR), stack canaries. */

3. System and network threats

Worms

The Morris worm (1988) exploited a finger buffer overflow, sendmail debug mode and trusted rsh hosts to infect ~6000 machines in hours. Modern worms spread through unpatched services.

Port scanning

Automatically connecting to ranges of ports to find services with known vulnerabilities (e.g. nmap) — reconnaissance, not an attack by itself.

Denial of service (DoS / DDoS)

Overloading a system so legitimate users cannot use it — e.g. SYN flooding half-opened TCP connections. Distributed DoS uses thousands of compromised machines (a botnet).

Sniffing, spoofing, man-in-the-middle

Eavesdropping on traffic; masquerading as another party; or sitting between two parties and reading or changing their messages.

4. Cryptography as a security tool

On a network we cannot trust that a message came from whom it claims, or that nobody read or changed it. Cryptography constrains the possible senders and receivers using keys.

Encryption

An encryption algorithm E(k) turns plaintext m into ciphertext c; decryption D(k) recovers m. It must be computationally infeasible to obtain m from c without the key.

Symmetric encryption

The same key encrypts and decrypts. Fast. Examples: DES (old, 56-bit), 3DES, AES (128/256-bit, today's standard). Problem: how to share the key securely?

Asymmetric (public-key) encryption

A public key (anyone may know it) encrypts; only the matching private key decrypts. Solves key distribution, but is much slower. Example: RSA.

Toy RSA, step by step
  1. Choose primes p = 7, q = 13 → n = pq = 91, φ(n) = (p − 1)(q − 1) = 72.
  2. Choose public exponent e = 5 (coprime with 72). Public key = (e, n) = (5, 91).
  3. Find private d with e·d ≡ 1 (mod 72): d = 29 (5 × 29 = 145 = 2 × 72 + 1). Private key = (29, 91).
  4. Encrypt m = 69: c = 695 mod 91 = 62.
  5. Decrypt: 6229 mod 91 = 69 ✔. Real RSA uses primes hundreds of digits long — factoring n is infeasible.

Authentication and integrity

  • Hash functions (SHA-256) produce a fixed-size digest; any change to the message changes the digest.
  • Message-authentication code (MAC) — a digest computed with a shared secret key (symmetric).
  • Digital signature — the sender encrypts the digest with its private key; anyone verifies with the public key. Provides integrity, authentication and non-repudiation.
  • Certificates issued by certificate authorities bind a public key to an identity, defeating man-in-the-middle attacks.

TLS (HTTPS) puts it all together. The browser connects and the server sends its certificate (public key signed by a CA).

The browser checks the CA's signature with the CA's public key, built into the browser.

Browser and server agree on a fresh symmetric session key using asymmetric cryptography (e.g. Diffie–Hellman).

All further data is encrypted with fast symmetric encryption (AES) and protected with MACs.

User authentication

Passwords are stored as salted hashes, never in plain text (Linux: /etc/shadow). Stronger schemes use one-time passwords, biometrics and multi-factor authentication (something you know + have + are).

VideoBytes

Program and network threats

Video coming soon

Program and network threats

Recorded by Dr. Krithika L.B. Slot m5-threats

Cryptography as a security tool

Video coming soon

Cryptography as a security tool

Recorded by Dr. Krithika L.B. Slot m5-crypto

Interactive lessons

Work through these in order after the lecture — each one expands a part of the notes with diagrams, hover notes and a quick check.

Lab connection

Check your understanding

Answer each question in your own words first, then reveal the model answer.

Revealed 0
How does a worm differ from a virus?

A virus needs a host program and spreads when the host runs; a worm is a standalone program that spreads by itself over a network.

Why is strcpy dangerous?

It copies until the terminating 0 without checking the destination size, allowing a stack buffer overflow.

Why does HTTPS use both asymmetric and symmetric encryption?

Asymmetric cryptography solves key exchange but is slow; it is used once to agree on a symmetric key that encrypts the bulk data quickly.

With n = 91 and e = 5, encrypt m = 2.

25 = 32; 32 mod 91 = 32.

What does a digital signature provide that encryption alone does not?

Authentication of the sender and non-repudiation (the sender cannot deny signing), plus integrity.

Key takeaways

  • Security protects confidentiality, integrity and availability against external and internal threats.
  • Program threats: Trojan horse, trap door, logic bomb, buffer overflow, viruses; network threats: worms, scanning, DoS.
  • Symmetric (AES) is fast; asymmetric (RSA) solves key distribution; hashes, MACs and signatures give integrity and authentication.

Where this leads

Cryptography protects data on the wire. Inside the machine, the OS must decide which process may touch which object — the job of protection.

Continue to 5.4 — Domains of protection, access matrix and capabilities →