Course contentsShow
← Security
Lesson 2042 of 3,05241. Secure Development LifecycleFree lesson

Cryptography and Secrets Review

Auditing cryptographic implementations, key management, random number usage, and identifying hardcoded secrets in code.

Cryptography and Secrets Review

You'll learn how to systematically audit cryptographic implementations and secrets handling during secure code reviews.

When reviewing code for cryptographic security, you're acting like a safety inspector checking both the locks on the doors (encryption) and where the keys are hidden (secrets management). You need to verify that cryptographic operations are correctly implemented and that sensitive credentials aren't accidentally exposed.

Core Review Focus Areas

Cryptographic Implementation Audits

Check that code uses approved, modern algorithms rather than weak or deprecated ones. Look for hardcoded algorithm choices—reject MD5, SHA-1 for security purposes, and outdated protocols like SSLv3 or TLS 1.0. Verify proper key lengths (AES-256, RSA-2048 minimum).

Review that encryption modes are appropriate—authenticated encryption modes like GCM are preferred over ECB (which should raise red flags). Ensure initialization vectors (IVs) and nonces are generated securely and never reused with the same key.

Key Management Practices

Scrutinize how cryptographic keys are generated, stored, and rotated. Keys should never be hardcoded in source code or configuration files. Verify they're stored in secure key management systems, encrypted at rest, and properly scoped with expiration policies.

Random Number Generation

Confirm that cryptographic operations use cryptographically secure random number generators (CSRNG), not standard pseudo-random functions. Using Math.random() for encryption is like using a child's toy lock on a bank vault.

Hardcoded Secrets Detection

Search for API keys, passwords, tokens, and connection strings embedded in code. Look in constants, comments, commit history, and environment variable defaults. Use pattern matching for common secret formats.

Key Takeaway: Cryptography code review demands verification that strong algorithms are properly implemented, keys are securely managed through dedicated systems, cryptographically-secure randomness is used, and no secrets are hardcoded anywhere in your codebase.