Cryptography Fundamentals Questions
Core concepts and vocabulary of cryptography: confidentiality, integrity, authentication, and non-repudiation; the difference between symmetric and asymmetric primitives; and how standard algorithms, libraries, and protocols fit together. Covers threat models, common standards, and applying primitives and cryptographic libraries correctly to real-world security problems. The entry point for the cryptography track.
Suppose a memory disclosure vulnerability similar to Heartbleed was discovered in an SSL/TLS library used by your fleet. Describe how you would detect whether exploitation occurred, immediate mitigations, patch rollout strategy, and post-incident tasks such as key and certificate rotation, forensic evidence collection, and customer notification.
Sample Answer
Framing
Heartbleed (CVE-2014-0160, disclosed in 2014) is the canonical example of a memory disclosure vulnerability in a Transport Layer Security (TLS) library: a bug in OpenSSL's implementation of the TLS "heartbeat" extension let an unauthenticated remote attacker read chunks of the server process's memory, with no login required and, critically, often no trace in normal logs. The response to a Heartbleed-class bug in your own fleet has to assume the worst rather than wait for proof, because the nature of the bug makes proof unusually hard to get.
Why detection is unusually hard here
The underlying flaw: a heartbeat request includes a payload and a claimed payload length, but the vulnerable code trusted the claimed length without checking it against the payload actually sent, and echoed back that many bytes starting from the payload's location in memory, silently including whatever adjacent memory happened to be there. Since the length field is a 16-bit value, the maximum claimed length is 2^16 - 1 = 65,535 bytes, roughly 64 kilobytes of arbitrary process memory per request, and an attacker can repeat the request as many times as they like, each time potentially recovering a different memory window. Because a heartbeat exchange is a normal, expected part of TLS and the request itself doesn't look malformed at the protocol level, it produces no error and, under most default logging configurations, no log entry at all. Detection cannot rely on finding evidence of exploitation, its absence is not reassuring.
Detecting whether exploitation occurred
- Check the installed OpenSSL version against the known-vulnerable range (OpenSSL 1.0.1 through 1.0.1f were affected; 1.0.1g and later fixed it) across every server, load balancer, and embedded device in the fleet, including things people forget are running TLS termination (internal load balancers, management interfaces, third-party appliances).
- Search any available packet captures or intrusion-detection signatures for heartbeat requests with an anomalous claimed payload length relative to the actual payload sent, this is the one concrete artifact that can prove exploitation if you happen to have captured it, but its absence proves nothing given how rarely this traffic gets captured in practice.
- Treat any server that was running a vulnerable version and was reachable from the internet during the vulnerability window as a presumed compromise for planning purposes, even with zero direct evidence.
Immediate mitigations
- Patch OpenSSL to a fixed version on every affected system, prioritized by internet-facing exposure, and where an immediate patch isn't possible on a given system, disable the heartbeat extension as an interim compensating control if your TLS stack supports doing so.
- Take internet-facing vulnerable endpoints out of service or behind a patched proxy rather than leaving them exposed while a fleet-wide patch rolls out.
Patch rollout strategy
Patch by exposure, not by convenience: internet-facing systems first, then internal systems that terminate TLS for anything sensitive, then everything else. A patch alone does not undo prior exposure, so rollout speed matters less than what happens next.
Post-incident tasks
- Key and certificate rotation. Because the bug could leak a server's private key directly from memory, and there is no reliable way to prove it didn't, every private key that was ever loaded into a vulnerable process's memory should be treated as compromised: revoke the old certificates and reissue new ones with fresh keys, don't just reissue a certificate for the same key.
- Credential rotation. Session tokens, passwords, and any other secrets that could plausibly have passed through a vulnerable process's memory (anything handled during requests to that server in the exposure window) should be treated the same way, force credential resets rather than assuming they were untouched.
- Forensic evidence collection. Preserve whatever logs, packet captures, and system snapshots exist from the exposure window before they age out or get overwritten, even incomplete evidence is useful for later analysis and for any compliance or legal review of the incident.
- Customer notification. Because exploitation cannot be conclusively ruled out or confirmed from typical logging, notification and disclosure decisions should be made on the assumption of potential compromise, honestly communicating that certainty isn't available, rather than waiting for definitive proof that will likely never come.
Trade-offs and pitfalls
The single biggest mistake in a Heartbleed-class incident is treating "we found no evidence of exploitation" as equivalent to "we confirmed no exploitation occurred." Given how the bug works, those are not the same statement, and a post-mortem that conflates them tends to under-rotate keys and credentials, leaving a genuinely compromised key in service simply because nobody could prove it was used.
Walk through the steps you would take to validate an X.509 certificate chain presented by a server. Include signature verification, trust anchor validation, subject alternative name checks, expiration, key usage and extended key usage checks, and handling intermediate and self-signed certificates.
Sample Answer
Direct answer
Validating an X.509 certificate chain (the standard format for public-key certificates) means confirming, step by step from the server's leaf certificate up through any intermediates to a certificate authority (CA) already trusted by the client, that every certificate in the chain is properly signed, currently valid, actually authorized for the purpose it's being used for, and correctly identifies the server you intended to connect to. Skipping or getting any one of these checks wrong is how real-world certificate validation bugs (accepting an expired certificate, accepting a certificate for the wrong hostname, trusting a certificate that was never actually issued by a real CA) turn into exploitable vulnerabilities.
The chain, concretely
A typical chain looks like: leaf certificate (the server's own) -> intermediate certificate authority certificate -> root certificate authority certificate. The root is self-signed (its issuer field equals its own subject field) and is trusted only because it is already present in the client's trust store, nothing about a self-signed certificate is trustworthy on its own, trust comes entirely from the trust store, not from the certificate's structure.
Validation steps
- Build the chain. Starting from the leaf certificate the server presented, find the certificate that issued it (usually sent alongside it), then that certificate's issuer, and so on, until reaching either a certificate already in the trust store or a dead end (no further issuer found, which fails validation).
- Signature verification. For each certificate in the chain except the trust anchor itself, verify its signature using the issuing certificate's public key. If any signature fails to verify, the chain is invalid, someone tampered with a certificate or it was never actually issued by the claimed issuer.
- Trust anchor validation. Confirm the top of the built chain is a certificate the client already trusts (present in its trust store as a trusted root), and, for a self-signed root, that self-signature check is really just confirming internal consistency, actual trust comes from the certificate's presence in the trust store, not from anything provable about the certificate alone.
- Subject Alternative Name (SAN) checks. Confirm the hostname you intended to connect to appears in the leaf certificate's SAN extension. Modern validation relies on SAN, not the older, deprecated practice of matching against the certificate's Common Name field, a certificate with the right Common Name but no matching SAN entry should be rejected.
- Expiration. Every certificate in the chain, not just the leaf, has a validity window (
notBefore/notAfter). If any certificate in the chain, leaf, intermediate, or root, is expired or not yet valid at the time of the check, the whole chain fails. - Key usage and extended key usage checks. The
keyUsageextension states what a certificate's key is cryptographically allowed to do (e.g.digitalSignature,keyCertSign), andextendedKeyUsagenarrows the purpose further (e.g.serverAuthfor TLS server authentication). A certificate authority certificate should carrykeyCertSignand theCA:TRUEbasic-constraints flag; a leaf server certificate should carryserverAuthand should not itself be a CA certificate. Rejecting a leaf certificate that was actually issued as a CA certificate (or vice versa) prevents an attacker from misusing a mis-scoped certificate to mint fraudulent certificates of its own. - Handling intermediate certificates. Multiple intermediates can appear between the leaf and the root, each one needs the same signature, expiration, and key-usage checks applied, a chain isn't valid just because its endpoints check out.
- Handling self-signed certificates. A self-signed certificate presented anywhere except as an already-trusted root (for example, a server presenting a self-signed leaf certificate with no path to any trusted root) should be rejected outright in normal validation, unless it has been explicitly and separately pinned or added to the trust store out of band, which is a deliberate operational decision, not something automatic chain validation should silently accept.
Trade-offs and pitfalls
The most common real-world mistake is validating only the leaf certificate's properties and assuming a signature check on it alone is sufficient, every certificate in the chain needs its own expiration, key-usage, and signature checks, and a server that fails to send its full intermediate chain (a very common misconfiguration) will validate correctly in browsers that cache intermediates from other sites but fail for clients and application programming interface (API) consumers that don't, which is why "it works in my browser" is not evidence a certificate chain is correctly configured.
Design a certificate revocation-checking approach for a global-scale service: compare CRLs, OCSP, and OCSP stapling on latency, availability, and privacy, and explain when short-lived certificates are a better alternative to revocation checking altogether. How would you detect and respond to a spike in failed revocation checks across your client fleet?
Sample Answer
Framing
The job is to let a client learn, in near real time and at global scale, whether a certificate it just received is still trustworthy, without that check itself becoming a single point of failure or a privacy leak. The three classic options, a Certificate Revocation List (CRL), the Online Certificate Status Protocol (OCSP), and OCSP stapling, sit on a spectrum from "cheap and stale" to "fresh but fragile," and short-lived certificates are a way to sidestep the whole problem rather than solve it better.
Comparing the options
| Approach | Latency | Availability | Privacy |
|---|---|---|---|
| CRL (a signed, periodically-published list of revoked certificate serial numbers) | No per-connection network call, but lists can be large and only as fresh as the last publish (often hours to a day old) | Very robust: clients can cache the list and keep working if the certificate authority (CA) is briefly unreachable | Good: no query reveals which specific site you're visiting |
| OCSP (a live, per-certificate revocation query to the CA) | Fresher (minutes), but adds a real-time network round trip to the CA on every new connection | Weak on its own: if the CA's OCSP responder is slow or down, clients either block (hurts availability) or "soft-fail" and skip the check (hurts security) | Poor: the CA sees which certificate, and therefore which site, each client is checking |
| OCSP stapling (the server itself fetches a signed OCSP response and attaches it to the handshake) | Best of both: no extra client round trip and fresh within the response's validity window | Good: the server, not each client, depends on the CA being reachable | Good: the CA never learns which clients are visiting which site, since the server does the fetching, not each browser |
When short-lived certificates beat revocation checking
If a certificate's validity window is a few days instead of a year (a pattern popularized by modern automated issuance), a compromised key becomes far less useful on its own: it expires before most CRL/OCSP infrastructure would even have propagated a revocation. This trades an ongoing revocation-checking system for an operational one, reliable, frequent automated reissuance, and it removes the OCSP privacy leak and the CRL freshness problem entirely, at the cost of needing issuance automation that cannot be allowed to fail silently.
Detecting and responding to a spike in failed revocation checks
- Detection: alert on the rate of OCSP failures or stapled-response absences per fleet, per certificate authority, and per region, since a global spike usually means an infrastructure problem (CA outage, network partition to the CA) while a narrow spike on one certificate points at that certificate specifically (possibly a real revocation event or an expired/misconfigured staple).
- Response: because a bad response here fails toward either "block legitimate traffic" or "silently accept a possibly-revoked certificate," decide and document the fallback behavior in advance (most production systems soft-fail with heavy monitoring rather than hard-fail, accepting the residual risk in exchange for availability) and treat a sustained spike as an incident that pages someone, not a metric that sits in a dashboard, because both failure directions have real security or availability consequences.
Trade-offs and pitfalls
OCSP stapling only helps if the server actually refreshes and serves a valid staple, a server that silently falls back to an unstapled response quietly reintroduces the privacy and latency costs of plain OCSP. Short-lived certificates only remove the revocation problem if issuance automation is treated as production infrastructure with its own on-call ownership, a failed renewal a few hours before expiry is now an outage, not a delayed patch.
Discuss the operational concerns when choosing randomness sources in cloud VMs, containers, and hardware. Explain entropy starvation, how to bootstrap entropy on new instances, and practical mitigations (e.g., rngd, getrandom/URANDOM behavior, provisioning entropy via cloud agent or HSM).
Sample Answer
Direct answer
Entropy starvation happens when a freshly booted virtual machine (VM), container, or device has not
yet gathered enough unpredictable input to safely seed its cryptographically secure pseudorandom
number generator (CSPRNG), which is the source every key, nonce, and token generation call relies
on. Cloud and container environments make this worse than physical hardware because a VM can be
cloned or restored from a snapshot with an already-seeded-looking generator that is, in fact,
identical to another instance's; the fix is to feed real, instance-unique entropy in early rather
than trust the guest kernel's default boot-time sources alone.
Structured elaboration
- How the kernel behaves. On Linux, the
getrandom()system call blocks (or, with a
non-blocking flag, returns an error) until the kernel's internal CSPRNG has been seeded once
after boot;/dev/urandomis meant to behave the same way on modern kernels, but on VM images
built from older kernels or minimal boot paths, that seeding event can be slow if the only inputs
are interrupt timing jitter that a virtualized, otherwise-quiet guest does not generate much of. - Why cloning is the cloud-specific risk. A snapshot or cloned image can, in the worst case,
carry over CSPRNG state from before the clone, so two "freshly booted" instances derived from the
same image can end up seeded almost identically. This is not hypothetical: a widely cited 2012
academic study (Heninger, Durumeric, Wustrow, and Halderman, "Mining Your Ps and Qs") found a
meaningful population of RSA and DSA keys generated on freshly booted embedded Linux devices that
shared factors, traced back to exactly this kind of boot-time entropy shortfall. - Sources available. A hardware random number generator, either a physical Trusted Platform
Module (TPM)/secure element or a paravirtualizedvirtio-rngdevice that channels the host's
hardware entropy into the guest, is the strongest available source in a VM;rngd(a user-space
daemon that feeds a hardware source into the kernel's pool) is the standard way to wire it up.
Worked example
Picture a fleet auto-scaling event: 200 new VM instances boot from the same golden image within a
few seconds of each other. If that image's kernel has no virtio-rng attached and relies solely on
interrupt-timing jitter to seed its CSPRNG, every one of those 200 instances is drawing from the
same class of low-diversity, low-volume noise source at nearly the same wall-clock moment, which is
exactly the "identically seeded clones" risk the 2012 study above found in the wild, just produced
by autoscaling instead of manual imaging. Attaching virtio-rng to the image and running rngd
against it before any cryptographic material is generated removes the shared bottleneck: each
instance now draws from the host hypervisor's own hardware entropy source, which is independent
per host and not tied to how many guest VMs happen to boot in the same second.
Trade-offs & pitfalls
- Bootstrap mitigation. Attach
virtio-rng(or equivalent) to every VM image rather than
relying on interrupt jitter alone; runrngdagainst it; have cloud-init or an equivalent
provisioning agent inject additional per-instance-unique material (instance ID, a fresh
provider-supplied random value fetched over an authenticated channel) mixed into the pool as a
supplement, never as a replacement for real entropy. - Delay, don't fake it. If a service must generate a long-term key at first boot, gate that
generation on confirmation that the kernel's CSPRNG has actually been seeded, rather than
falling back to a weaker, always-available source "so boot doesn't hang." A slow, correct key
beats a fast, predictable one. - Containers usually share the host kernel's entropy pool, so a container does not need its own
hardware RNG in most deployments, but a container started from a frozen, long-cached image on a
host that has not yet accumulated entropy inherits the same startup risk as a VM. - Monitoring. Alert on unusually long blocking on cryptographic syscalls at boot and on
entropy-pool health metrics where the kernel exposes them; a fleet-wide pattern of slow key
generation at scale-out time is a real operational signal, not noise.
Your SIEM shows repeated TLS handshake failures to an internal service after a certificate rotation. Failures indicate 'bad_certificate' from several clients. Explain your investigation steps: what logs and systems you inspect, how to verify certificate chain and private key correctness, and quick mitigations to restore service while preserving forensic data.
Sample Answer
Framing
A bad_certificate alert is Transport Layer Security's (TLS) way of saying the client rejected something specific about the certificate the server presented during the handshake, it is a symptom, not a diagnosis. Given that this started right after a certificate rotation, the investigation should assume the rotation itself introduced the problem until proven otherwise, and the response needs to restore service without destroying the evidence needed to confirm what actually broke.
Investigation steps
- Confirm the timeline. Check when the failures started against the exact deployment time of the certificate rotation across your fleet, a rollout that wasn't atomic (some nodes updated, some not) often shows up as intermittent failures rather than a hard outage, which is itself a diagnostic clue.
- Inspect what's actually being served. Connect directly to an affected node's Transport Layer Security endpoint and retrieve the certificate chain it presents (most TLS tooling can dump the full chain, not just the leaf). Compare it against what you intended to deploy: is the leaf certificate the new one? Is the full intermediate chain present, or did the rotation deploy the new leaf certificate without updating the intermediate bundle, a very common rotation mistake?
- Verify the certificate and private key actually match. A rotation that swaps a certificate file but not its paired private key (or vice versa) produces exactly this kind of failure. Compute a fingerprint of the public key embedded in the certificate and compare it against a fingerprint of the public key derived from the private key file on disk, if they don't match, the server is presenting a certificate for a key it doesn't actually hold, and the handshake will fail every time.
- Check certificate validity and identity fields. Confirm the new certificate's validity window has actually started (a certificate rotated slightly early, before its
notBeforedate, would be rejected), and confirm its Subject Alternative Name entries match the hostnames clients are actually connecting to, a rotation that regenerated a certificate with the wrong hostname list is a common human error. - Check trust store propagation on the client side. If the rotation introduced a new intermediate certificate authority or changed the root, clients (or upstream proxies, load balancers, or internal services) that haven't been updated with the new trust chain will reject the new certificate as untrusted even though the server side is configured correctly, this shows up specifically as failures from some clients, not others.
- Correlate logs across layers. Server-side TLS termination logs, load balancer or reverse proxy logs, and client-side error logs each show a different part of the picture, the exact alert reason and which specific check failed is usually visible in at least one of these, don't stop at the first log source that mentions
bad_certificate.
Quick mitigations that preserve forensic data
- Roll back to the previous, known-good certificate and key pair on affected nodes to restore service immediately, but copy the failing certificate, key, and relevant logs to a separate location before overwriting them on the live nodes, don't let a rollback destroy the only evidence of what went wrong.
- If a full rollback isn't immediately possible everywhere, route traffic away from affected nodes (via load balancer health checks or manual removal from the pool) rather than restarting services repeatedly, repeated restarts can overwrite log buffers and make root-causing harder.
- Avoid regenerating a "fixed" certificate in a hurry before you've confirmed exactly what was wrong with the previous one, a rushed second rotation risks introducing a second, different mistake on top of the first.
Trade-offs and pitfalls
The single most common root cause behind this exact symptom is an incomplete rollout, a certificate and its matching intermediate bundle deployed to some nodes but not others, or a private key file that didn't get updated in lockstep with its certificate. Treat certificate rotation as an atomic, verifiable deployment (verify the live chain and key match on every node before declaring the rotation complete) rather than a file copy, since the failure here is silent until a client actually tries to validate the result.
Unlock Full Question Bank
Get access to all 8 Cryptography Fundamentals interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.