← Back to section · Tutorials & Labs

A Code Review Checklist for Cryptography: The Questions a Reviewer Should Ask, Item by Item

Bugs in cryptographic code usually do not crash — they silently stop protecting. This article provides a checklist ready to use in review: randomness, algorithms and modes, key handling, comparison and timing, error handling, parameters and encoding — with the question to ask and the rejection bar for each item.

Published 22 November 2026 · 5 min read · PQ Frontier

A Code Review Checklist for Cryptography: The Questions a Reviewer Should Ask, Item by Item
AI-generated site artwork
Video explainer · Developer practice: secure coding

Bugs in ordinary code manifest as functional errors; bugs in cryptographic code manifest as “functionally perfect, security absent”: encrypt–decrypt round-trip tests all pass, yet the key was generated with predictable randomness; signatures verify successfully, yet the comparison function leaves a timing side channel. Such problems cannot be found by running tests — only by asking questions against a checklist during review. This article fixes crypto code review into a checklist organized in six domains, each item giving the question to ask and the bar for handling it, ready to paste into a team’s review template. The checklist’s goal is not to replace security experts, but to let ordinary reviewers catch the highest-frequency class of errors.

Domain one: randomness — the source of all security

First question: where does the randomness in this code come from? For every security use (keys, nonces, salts, tokens, challenge values) it must come from a cryptographically secure interface backed by the OS entropy source; an ordinary PRNG, a timestamp seed, or a home-assembled entropy source means rejection on the spot. Second question: how was the length decided? Require the author to state the basis — the bit length of tokens and keys, the collision probability of nonces — not “we have always written 16”. Third question: are there reuse and repetition scenarios? Can a nonce repeat under the same key; does random state replay after process fork or snapshot restore? If the author cannot answer, require a design note before reviewing further.

Domain two: algorithms and modes — is it a standard combination?

First question: are the algorithm and mode a whitelisted standard combination? Authenticated encryption should be the default, and bare unauthenticated encryption needs a separate justification plus an integrity plan. Second question: is there hand-written cryptographic logic — invented algorithms, hand-assembled protocols, custom token formats and verification logic? Reject by default; exceptions go through a separate security review. Third question: do parameters meet the current baseline — key lengths, KDF iteration parameters, password-hash cost parameters — or are they still sitting at defaults from years ago? Fourth question: is the algorithm choice hardcoded or configurable, and is a migration path reserved (connecting to the cryptographic agility requirements)?

Domain three: key handling — is the whole lifecycle closed?

Trace a key through its life, stage by stage: is generation based on secure randomness with sufficient length; is storage kept out of code and ordinary configuration, going through a KMS or envelope encryption; does transmission stay inside protected channels, and does the key appear in logs, error messages, or debug output; are there unnecessary copies or long residence in memory during use; and do destruction and rotation paths exist, with a defined way for old keys to retire? Watch especially for two common oversights: real keys in test code (even “revoked” ones are treated as leaked), and error-handling branches that splice key material into error messages.

Domain four: comparison and timing — are there side channels?

Every comparison involving secret data — MAC verification, password-hash comparison, token validation — must use constant-time comparison; an ordinary string equality check is grounds for rejection. Then look at branches and table lookups: array accesses indexed by secret data, and early returns conditioned on secrets, are classic sources of timing and cache side channels in cryptographic implementations. Application-layer code that avoids home-grown crypto implementations entirely and only calls mature libraries eliminates most of this domain; the moment someone hand-writes a low-level implementation, this domain escalates to expert review.

Domain five: error handling and logs — is there an oracle for the attacker?

First question: are failure responses distinguishable? Returning different error codes or messages for “wrong key”, “bad padding”, and “authentication failed” hands the attacker an oracle for byte-by-byte probing; the correct behavior is one uniform, vague failure response. Second question: what is in the logs? Ciphertext may be logged; plaintext, keys, passwords, and full tokens must never be; in review, search the logging statements and check them one by one. Third question: do error paths fail safely — does an error deny the operation or allow it? Default-allow behavior in authentication and verification code is a fatal flaw and must be changed to fail-closed.

Domain six: parameters and encoding — the devil in the details

The last group is mundane but high-frequency: does converting random bytes to strings use a modulo mapping that introduces bias; do Base64 and hex codecs handle padding and invalid input; are there overflow and truncation risks in length and integer parsing; is character encoding unambiguous (are passwords and strings explicitly encoded before hashing); and does the clock source behind timestamps and expiry checks deserve trust? None of these is hard individually; the difficulty is remembering to check them during review — which is exactly why the checklist exists.

One more sweep: test code and example code

Do not limit the review scope to production code. Hardcoded keys in test fixtures, bypass switches left in for debugging convenience, and unsafe simplifications in documentation examples all leak into production in various ways: fixtures get copied, switches get forgotten, examples get pasted verbatim by the next developer. In review, specifically confirm: are test keys and certificates obviously fake data with no relation to production material; are debug backdoors completely removed by build switches in release builds; and do external documentation and examples show only the secure way of doing things — because example code often spreads further than the prose around it, and one bad habit in an example gets copied into countless projects. This sweep adds little work and closes a very hidden source of problems.

Wrap-up: how the checklist is enforced

For a checklist to work, enforcement matters more than content: make the six domains mandatory fields in the review template, requiring every change that touches cryptography to tick each item with a one-line explanation; any item answered “not sure” pauses the change until a design note fills the gap; and the rejection bar is uniform across the team, never relaxed for a release deadline. The essence of crypto review is institutionalizing one question — “have the security assumptions been broken?” — and with the checklist in hand, ordinary reviewers can hold that line.

Tags: Code ReviewCryptographyChecklistSecure Coding