Skip to content

Security

Security is not a feature you add at the end. It is a property of how you think about every line of code, every API boundary, every deployment pipeline, and every human process in your organization. Most breaches don't come from exotic zero-days — they come from an engineer who hardcoded a database password, a forgotten admin endpoint with no authentication, or a JWT implementation that doesn't validate the algorithm header.

This section teaches you to think like an attacker so you can build like a defender. Every vulnerability is shown with both the exploitable code and the fixed version, because understanding why something is vulnerable matters more than memorizing a checklist.

Thinking in Threat Models

Before you can defend a system, you need to understand what you are defending it against. Threat modeling is the practice of systematically asking: what can go wrong?

A simple threat model for any system follows these four steps:

Step 1 — What are we building? Draw a data flow diagram. Identify every entry point, data store, trust boundary, and external dependency. You cannot secure what you cannot see.

Step 2 — What can go wrong? Use the STRIDE framework: Spoofing (can someone pretend to be someone else?), Tampering (can someone modify data in transit or at rest?), Repudiation (can someone deny they did something?), Information disclosure (can someone see data they shouldn't?), Denial of service (can someone make the system unavailable?), Elevation of privilege (can someone gain access they shouldn't have?).

Step 3 — What are we doing about it? For each threat, you either mitigate it (apply a control), accept it (document why), transfer it (insurance, third-party service), or eliminate it (remove the feature).

Step 4 — Did we do a good job? Review, test, pentest, and repeat. Threat models are living documents.

Learning Path

Build security knowledge in this order — each layer depends on the previous one:

OrderSubsectionWhat You'll LearnThreat Category
1OWASP Top 10 (2021)The ten most critical web application security risks, each with exploit demos and fixes. Start here for threat context.All categories
2EncryptionSymmetric vs asymmetric, TLS 1.3 handshake, hashing, key derivation, at-rest and in-transit. Foundation for everything else.Information Disclosure, Tampering
3AuthenticationJWT internals byte-by-byte, OAuth2/OIDC flows, session management, MFA, passkeysSpoofing, Elevation of Privilege
4AuthorizationRBAC, ABAC, Zanzibar-style ReBAC, policy engines (OPA), permission systems at scaleElevation of Privilege
5Secrets ManagementVault, AWS Secrets Manager, env var anti-patterns, rotation strategies, CI/CD secretsInformation Disclosure
6Zero TrustNetwork segmentation, identity-based access, mTLS, BeyondCorp model, policy enginesAll categories
7API SecurityRate limiting, input validation, CORS, CSRF, API key management, GraphQL-specific risksTampering, DoS, Information Disclosure
8Exploits & VulnerabilitiesLog4Shell, Heartbleed, XZ Backdoor — attack techniques for defensive understandingAll categories

Security Principles

Six principles underpin everything in this section:

  1. Defense in depth — No single control is sufficient. Layer your defenses so that a failure in one layer does not mean a total breach.
  2. Least privilege — Every user, service, and process should have the minimum permissions required to do its job, and nothing more.
  3. Fail secure — When something breaks, it should deny access by default, not grant it.
  4. Zero trust — Never trust, always verify. Authenticate and authorize every request regardless of network origin.
  5. Secrets are toxic — Every secret you store is a liability. Minimize them, rotate them, and never put them in source code.
  6. Assume breach — Design your systems so that when (not if) an attacker gets in, the blast radius is contained.

Start with the OWASP Top 10 for a practical survey of what goes wrong most often, then work through authentication and encryption for the fundamental building blocks, and finish with zero trust and API security to tie it all together at the architectural level.

"What I cannot create, I do not understand." — Richard Feynman