The CIA Triad#

All security aims to protect three properties:

flowchart TD
    C["Confidentiality<br/>(only authorized access)"]
    I["Integrity<br/>(data not tampered with)"]
    A["Availability<br/>(accessible when needed)"]
PropertyThreatProtection
ConfidentialityData breach, eavesdroppingEncryption, access control
IntegrityTampering, corruptionHashing, digital signatures
AvailabilityDDoS, hardware failureRedundancy, backups

Encryption#

Symmetric Encryption#

Same key encrypts and decrypts — fast, used for bulk data:

AlgorithmKey SizeUse Case
AES-256256 bitsData at rest, TLS data transfer
ChaCha20256 bitsMobile, TLS alternative

Asymmetric Encryption#

Key pair (public + private) — slower, used for key exchange and signatures:

AlgorithmUse Case
RSALegacy key exchange, signatures
ECDSAModern signatures (SSH, TLS)
Ed25519SSH keys, modern signatures

How TLS Uses Both#

sequenceDiagram
    participant C as Client
    participant S as Server
    
    Note over C,S: Asymmetric (slow) — exchange keys
    C->>S: Hello + supported ciphers
    S->>C: Certificate (public key)
    C->>S: Encrypted session key (using server's public key)
    
    Note over C,S: Symmetric (fast) — encrypt data
    C->>S: Data encrypted with session key (AES)
    S->>C: Response encrypted with session key (AES)

Hashing#

One-way function — can’t reverse the output back to input:

AlgorithmOutputUse Case
SHA-256256 bitsFile integrity, blockchain
bcryptVariablePassword storage
Argon2VariablePassword storage (modern)

Never store passwords in plain text. Always hash with a salt (bcrypt/Argon2).


Common Vulnerabilities#

VulnerabilityDescriptionPrevention
SQL InjectionMalicious SQL in user inputParameterized queries
XSSInject scripts into web pagesOutput encoding, CSP
CSRFTrick user into unwanted actionsCSRF tokens
Path TraversalAccess files outside intended directoryInput validation
Insecure DeserializationExecute code via crafted objectsValidate input types
Secrets in CodeAPI keys committed to gitEnvironment variables, secrets manager

Defense in Depth#

Multiple layers of security — if one fails, others still protect:

LayerControls
NetworkFirewalls, VPN, segmentation
HostOS hardening, patching, antivirus
ApplicationInput validation, auth, encryption
DataEncryption at rest, access control, backups
PeopleTraining, least privilege, MFA

Principle of Least Privilege#

Every user, process, and system should have only the minimum permissions needed:

BadGood
App runs as rootApp runs as dedicated user
Admin access for everyoneRole-based access (RBAC)
Wildcard IAM policies (*)Specific resource + action
Shared credentialsIndividual accounts + MFA

Secrets Management#

MethodSecurityUse Case
Hardcoded in source❌ TerribleNever
Environment variables⚠️ AcceptableLocal dev, CI/CD
Secrets manager (AWS SM, Vault)✅ BestProduction
Encrypted config files⚠️ AcceptableWhen secrets manager unavailable

Key Takeaways#

  1. CIA triad — every security decision protects confidentiality, integrity, or availability
  2. Encrypt everything — at rest (AES) and in transit (TLS)
  3. Never store plain-text passwords — use bcrypt or Argon2
  4. Least privilege — minimum permissions needed, nothing more
  5. Defense in depth — multiple layers, not a single control
  6. Secrets in a secrets manager — never in code or git
  7. Patch regularly — most breaches exploit known vulnerabilities