Beginner-Friendly Topic
Take your time - it's perfectly normal to re-read this topic 2-3 times. Try the interactive code editor below to run code yourself. Use the Q&A section to check your understanding before moving on.You've got this!
Lesson 2 of 11
The CIA Triad
The CIA Triad - Confidentiality, Integrity, Availability - is the foundational model for evaluating every security control, policy, and design decision. Every attack targets at least one of these three properties.
Confidentiality
Information is accessible only to those authorized to see it. Violations include unauthorized data access, data leakage, and eavesdropping. Controls: encryption, access control lists, MFA, data classification.
The foundational security model: Confidentiality (privacy), Integrity (trust), and Availability (uptime).
Integrity
Data is accurate, trustworthy, and has not been tampered with - either in transit or at rest. Violations include man-in-the-middle tampering, database corruption, and malicious file modification. Controls: hashing, digital signatures, version control, checksums.
Availability
Systems and data are accessible to authorized users when needed. Violations include DDoS attacks, ransomware, hardware failures, and misconfigurations that bring systems down. Controls: redundancy, load balancing, backups, DDoS mitigation, high-availability architecture.
CIA Triad in Python - Practical Demonstrations
import hashlib
import secrets
import base64
from cryptography.fernet import Fernet
# === CONFIDENTIALITY: Encrypt sensitive data ===
key = Fernet.generate_key()
cipher = Fernet(key)
secret_message = b"Patient record: John Doe, SSN 123-45-6789"
encrypted = cipher.encrypt(secret_message)
print(f"Encrypted: {encrypted[:40]}...")
# === INTEGRITY: Hash a file to detect tampering ===
def compute_hash(data: bytes) -> str:
return hashlib.sha256(data).hexdigest()
original_data = b"Financial report Q4 2025"
original_hash = compute_hash(original_data)
# Simulate tampering
tampered_data = b"Financial report Q4 2025 (modified)"
tampered_hash = compute_hash(tampered_data)
if original_hash != tampered_hash:
print("INTEGRITY VIOLATION: File has been tampered with!")
# === AVAILABILITY: Generate a secure random token for session ===
session_token = secrets.token_urlsafe(32)
print(f"Secure session token: {session_token}")CIA Triad Applied to Real Attacks
- Ransomware attacks all three: Confidentiality (data stolen/exfiltrated), Integrity (files encrypted and corrupted), Availability (systems locked)
- Data breach (e.g., Equifax 2017): Primarily a Confidentiality failure - 147M personal records exposed
- Website defacement: Integrity attack - attackers replace legitimate content with malicious content
- DDoS (e.g., GitHub 2018, 1.3 Tbps attack): Pure Availability attack - overwhelm servers to deny service
- SQL Injection: Can violate all three - read data (C), modify data (I), drop tables (A)
Common Mistakes
- Focusing only on Confidentiality (encryption) while neglecting Integrity (checksums) and Availability (backups)
- Not considering that some attacks explicitly trade one property against another - e.g., logging improves Integrity/Availability monitoring but can create Confidentiality risks if logs contain sensitive data
- Assuming HTTPS alone satisfies all three - HTTPS protects Confidentiality and Integrity in transit, but does nothing for database-level Confidentiality or system Availability
Try It Yourself: CIA Triad Analysis
# CHALLENGE: Classify each attack scenario
# For each attack, identify which CIA property is violated:
# "C" = Confidentiality, "I" = Integrity, "A" = Availability
# Some attacks violate MULTIPLE properties!
import hashlib
scenarios = {
"Hacker steals customer database via SQL injection": "???",
"DDoS attack takes website offline for 6 hours": "???",
"Attacker modifies bank transaction amounts in transit": "???",
"Ransomware encrypts all company files": "???",
"Employee accidentally emails salary spreadsheet externally": "???",
"DNS poisoning redirects users to fake login page": "???",
}
# ANSWER KEY:
answers = {
"Hacker steals customer database via SQL injection": "C (data exposed)",
"DDoS attack takes website offline for 6 hours": "A (service denied)",
"Attacker modifies bank transaction amounts in transit": "I (data altered)",
"Ransomware encrypts all company files": "C + I + A (all three!)",
"Employee accidentally emails salary spreadsheet externally": "C (data leaked)",
"DNS poisoning redirects users to fake login page": "I + C (fake site steals creds)",
}
# BONUS: Verify file integrity using hashing
original_file = b"Quarterly financial report - all figures verified"
file_hash = hashlib.sha256(original_file).hexdigest()
print(f"Original file hash: {file_hash[:16]}...")
# Simulate tampering
tampered_file = b"Quarterly financial report - figures modified"
tampered_hash = hashlib.sha256(tampered_file).hexdigest()
if file_hash != tampered_hash:
print("ALERT: Integrity violation detected! File was tampered with.")
else:
print("File integrity verified.")Tip
Tip
Practice The CIA Triad in small, isolated examples before integrating into larger projects. Breaking concepts into small experiments builds genuine understanding faster than reading alone.
Practice Task
Note
Practice Task - (1) Write a working example of The CIA Triad from scratch without looking at notes. (2) Modify it to handle an edge case (empty input, null value, or error state). (3) Share your solution in the Priygop community for feedback.
Quick Quiz
Common Mistake
Warning
A common mistake with The CIA Triad is skipping edge case testing - empty inputs, null values, and unexpected data types. Always validate boundary conditions to write robust, production-ready cybersecurity code.
Key Takeaways
- The CIA Triad - Confidentiality, Integrity, Availability - is the foundational model for evaluating every security control, policy, and design decision.
- Ransomware attacks all three: Confidentiality (data stolen/exfiltrated), Integrity (files encrypted and corrupted), Availability (systems locked)
- Data breach (e.g., Equifax 2017): Primarily a Confidentiality failure - 147M personal records exposed
- Website defacement: Integrity attack - attackers replace legitimate content with malicious content
Finished this lesson?