Secure Key Derivation with PBKDF2 & Salt Basics
12 Lessons • Hands-on practice
Secure Key Derivation with PBKDF2 & Salt
Storing passwords with fast hashes like MD5 or raw SHA-256 leaves credentials defenseless against GPU rainbow table attacks. PBKDF2 applies a cryptographically random salt and thousands of HMAC iterations to deliberately slow down computation, making brute-force cracking mathematically infeasible.
Ephemeral Nonce Cache with TTL Expiry
Attackers intercepting valid signed API requests can replay them across networks to duplicate financial transactions or unauthorized state changes. An ephemeral nonce cache tracks unique request identifiers (nonces) within a time window, rejecting duplicate replay requests.
Memory Scrubbing & Buffer Zeroization
Python strings are immutable; reassigning secret variables abandons unencrypted passwords on the heap where core dumps or memory scrapers can harvest them. Using mutable bytearrays allows explicit zeroization in-place, overwriting private keys with zeros immediately after cryptographic operations.
Zero-Trust HTTP Header Validator
HTTP headers passed by reverse proxies or web clients can contain CRLF injection characters ( ) or conflicting Transfer-Encoding and Content-Length headers. Validating headers against RFC 7230 rules thwarts HTTP Request Smuggling, header splitting, and cache poisoning attacks.
Cross-Site Request Forgery (CSRF) Token Generator
Cross-Site Request Forgery (CSRF) tricks authenticated users into submitting unwanted commands via third-party websites. An HMAC-signed CSRF token binds the user's active session ID to an expiration timestamp, cryptographically ensuring state-changing requests originate from legitimate application forms.
Anti-Brute-Force Lockout State Machine
Automated credential-stuffing bots test thousands of breached password pairs against login endpoints. An account lockout state machine tracks consecutive failed authentication attempts, transitioning the account to a temporary locked state when failure thresholds are breached.
Certificate Expiration & SAN Inspector
TLS certificates expire after fixed terms, causing sudden browser warnings and broken API webhooks. Inspecting certificate metadata requires evaluating the not_after expiration timestamp and matching request domains against Subject Alternative Names (SANs) supporting wildcards (*.domain.com).
Content Security Policy (CSP) Header Builder
Content Security Policy (CSP) headers instruct client browsers to reject unauthorized inline scripts, styles, or framing, stopping Cross-Site Scripting (XSS) attacks. Building robust policies requires quoting keywords ('self', 'none') and interpolating dynamic nonce tokens into script-src.
Module 45 Capstone: Zero-Trust Cryptographic Auth Guard
Zero-trust architectures reject implicit perimeter trust, validating every network transaction independently. A zero-trust auth guard validates clock skew, enforces single-use ephemeral nonces, verifies request payload hashes, and checks HMAC-SHA256 signatures in constant time.
Gauntlet 01: Mini Redis In-Memory KV Server
Redis delivers microsecond key-value caching using in-memory hash tables and time-to-live (TTL) expiration. Keys expire through passive checks on access and proactive background evictions. Implementing Redis primitives requires managing atomic dictionary states and timestamp expiration counters.
Gauntlet 02: Pure-Python HTTP 1.1 Web Server
Web frameworks like FastAPI and Flask abstract HTTP mechanics. A pure-Python HTTP 1.1 server handles raw socket byte streams directly, parsing method lines, extracting headers, routing request paths, and formatting compliant HTTP responses with CRLF delimiters.
Gauntlet 03: Barebones Git Object Store
Git is not magic; it is a content-addressable directed acyclic graph (DAG) of immutable objects. Every object begins with a type header and byte size, is hashed via SHA-1, and compressed with zlib. Blobs store file data, while commits bind tree pointers to commit messages.