← Cloudflare Interview Insights

Cloudflare·Software Engineer·Onsite - System Design / Architecture·Senior

SeniorPrefer not to say
Jun 2026Remote

Summary

Cloudflare system design round focused on building an encrypted key-value store from scratch, which sounds manageable until you realize they want the full stack: crypto primitives, OO design, user auth, and a real conversation about key derivation. Pretty intense for a single session.

Questions Asked (3)

Q1

Design and implement an object-oriented encrypted key-value store with put, get, delete, and list operations, where values are encrypted at rest using a user-supplied password.

System DesignTechnical Trade-offsAPI & Integrations
Author's notes

This is the core of the whole interview and it ate up most of the time.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying requirements and constraints, then outline a high-level object-oriented design with clear separation of concerns (e.g., storage, encryption, API). Discuss key trade-offs such as encryption scheme, key derivation, and persistence, and finally sketch an implementation plan with core classes and methods.

Pro tip: Emphasize security best practices like using authenticated encryption (AES-GCM) and a strong KDF (e.g., Argon2) to protect against tampering and brute-force attacks. Also, mention the importance of not storing the password and handling key rotation gracefully.

1. Clarify Requirements and Constraints

Ask about expected data size, concurrency, persistence needs, and security requirements (e.g., encryption algorithm, key management). This ensures the design meets the actual use case.

2. Define Core Interfaces and Classes

Outline an interface for the key-value store with put, get, delete, list. Identify classes like EncryptedStore, EncryptionService, KeyDerivationService, and StorageBackend, each with single responsibilities.

3. Design Encryption and Key Management

Choose an authenticated encryption scheme (e.g., AES-GCM) and a key derivation function (e.g., Argon2, PBKDF2) to derive a master key from the password. Decide how to handle per-value encryption (unique nonce/IV) and key storage.

4. Discuss Trade-offs and Extensibility

Compare in-memory vs. persistent storage, synchronous vs. asynchronous operations, and performance vs. security. Mention how to extend for features like key rotation or multi-user support.

5. Sketch Implementation and Edge Cases

Provide pseudocode or class diagrams for key methods, and address edge cases like wrong password, missing keys, and concurrent access. Highlight error handling and logging.

Key Points to Mention

  • Use of authenticated encryption (e.g., AES-GCM) to ensure confidentiality and integrity.
  • Key derivation from password using a slow hash (e.g., Argon2) with salt to resist brute-force.
  • Separation of concerns: storage, encryption, and API layers for maintainability.
  • Handling of nonces/IVs uniquely per encryption operation to avoid reuse.
  • Consideration of persistence and concurrency (e.g., thread-safe operations).
  • Error handling for incorrect password or tampered data, and secure deletion of keys.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q2

How would you implement user registration and login, and how does the password get turned into an encryption key?

System DesignTechnical Trade-offs
Author's notes

They wanted PBKDF2 or Argon2, the salt story, and why you can't just hash the password directly.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the requirements and constraints, then walk through a secure registration and login flow using industry best practices like bcrypt for password hashing and TLS for transport. Explain that passwords are never used directly as encryption keys; instead, derive keys using a KDF like PBKDF2 or Argon2, and consider envelope encryption with a KMS for data at rest.

Pro tip: Emphasize that password hashing (for authentication) and key derivation (for encryption) are distinct processes with different security goals, and mention that Cloudflare's scale demands rate limiting, DDoS protection, and possibly hardware security modules (HSMs) for key management.

1. Clarify requirements and constraints

Ask about scale, compliance (e.g., GDPR, PCI), and whether the system needs to store encrypted user data. This shows you consider context before diving into implementation.

2. Design registration flow

Outline steps: validate input, check for existing user, hash password with a strong algorithm (bcrypt, scrypt, or Argon2) and unique salt, store hash and salt, and optionally send verification email. Mention rate limiting to prevent abuse.

3. Design login flow

Describe: retrieve stored hash and salt by username, hash the provided password with the same salt, compare using constant-time comparison, and on success issue a session token or JWT. Include protections against brute force and timing attacks.

4. Explain password-to-key derivation

Clarify that passwords are not directly used as encryption keys. Instead, use a KDF like PBKDF2, bcrypt, or Argon2 to derive a key from the password and a salt. For data encryption, consider envelope encryption: generate a random data encryption key (DEK), encrypt it with a key encryption key (KEK) derived from the user's password or managed by a KMS.

5. Discuss trade-offs and security considerations

Compare algorithms (e.g., bcrypt vs Argon2), discuss performance vs security, and mention additional measures like MFA, account lockout, and secure key storage (HSM, KMS). Highlight how Cloudflare's infrastructure can help with DDoS mitigation and global scale.

Key Points to Mention

  • Use bcrypt, scrypt, or Argon2 for password hashing with unique salts per user.
  • Never store plaintext passwords or use reversible encryption for passwords.
  • Derive encryption keys using a KDF (e.g., PBKDF2, Argon2) with a salt, not directly from the password.
  • Employ envelope encryption: use a DEK for data and a KEK to protect the DEK, managed by a KMS or HSM.
  • Implement rate limiting, account lockout, and constant-time comparison to prevent brute force and timing attacks.
  • Consider MFA and secure session management (e.g., JWT with short expiry, refresh tokens).

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q3

What happens when a user tries to decrypt a value with the wrong password, and how does your system surface that error?

System DesignTechnical Trade-offs
Author's notes

Blanked for a second on this.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by explaining the cryptographic behavior: decryption with the wrong password typically fails authentication (e.g., AEAD tag mismatch) or produces garbage, so the system must detect and handle it. Then describe how your system surfaces the error to the user and logs it internally, emphasizing security and usability trade-offs. Finally, discuss how you avoid leaking sensitive information while still providing actionable feedback.

Pro tip: Mention that you never reveal whether the password or the ciphertext was wrong—just a generic 'decryption failed' message—to prevent oracle attacks, and log the event with enough context for debugging without exposing secrets.

1. Explain the cryptographic outcome

Describe what happens at the algorithm level: with authenticated encryption (e.g., AES-GCM), the authentication tag fails; with unauthenticated encryption, you get random-looking plaintext. Emphasize that the system must not trust the output.

2. Detect and handle the failure

Detail how your code checks for decryption failure—e.g., catching exceptions from the crypto library or verifying the MAC—and then aborts the operation without using the corrupted data.

3. Surface the error to the user

Explain the user-facing behavior: a generic error message like 'Invalid password or corrupted data' that doesn't distinguish between wrong password and tampered ciphertext. Mention any rate limiting or lockout to prevent brute force.

4. Log and monitor internally

Describe what you log (e.g., timestamp, user ID, operation type) without logging the password or plaintext, and how you alert on suspicious patterns like repeated failures.

5. Discuss trade-offs and edge cases

Address trade-offs: usability vs. security (e.g., error specificity), performance impact of authentication, and how you handle partial failures in distributed systems.

Key Points to Mention

  • Authenticated encryption (AEAD) like AES-GCM or ChaCha20-Poly1305 provides integrity and detects wrong passwords via tag mismatch.
  • Never reveal whether the password or ciphertext was wrong to avoid padding oracle or similar attacks.
  • Use constant-time comparison for authentication tags to prevent timing attacks.
  • Implement rate limiting or exponential backoff on decryption attempts to mitigate brute force.
  • Log failures with sufficient context for debugging but redact sensitive data.
  • Consider user experience: provide clear but generic error messages and possibly a 'forgot password' flow.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.