Data security in the cloud
Clear, exam-focused notes on cloud data security: confidentiality, integrity, availability, cryptography (RSA proof and example), key management, access control, logging, and best practices for protecting data at rest and in transit.
Drafted with Aria, reviewed by the AiCanCode.org team · Updated . How we write and check our notes. Spotted an error? Use Give Feedback at the bottom of the page.
Why it matters
Data is the primary asset stored and processed in cloud systems. Engineers design cloud systems to ensure confidentiality, integrity and availability of customer data while supporting multitenancy and scalability. This topic guides design choices (encryption, key management, IAM, logging, lifecycle) engineers implement every day. Also understand the shared responsibility model: cloud providers secure the underlying infrastructure, while customers are responsible for data classification, IAM, and secure configuration of services.
Key ideas
Start from the basic security goals: define each term before use.
- Confidentiality — the property that data is not disclosed to unauthorized entities. Protect by encryption, access control and isolation.
- Integrity — the property that data has not been modified by unauthorized parties. Protect by cryptographic hashing, MACs/HMACs, digital signatures and checksums.
- Availability — the property that data and services remain usable when needed. Protect by replication, backups, DDoS protection and fault tolerance.
- Data-at-rest — data stored on disks, object stores, or databases. Protect mainly by disk-level or object-level encryption.
- Data-in-transit — data moving over networks. Protect by transport security (TLS) and network segmentation.
- Data-in-use — data while being processed in memory/CPU. Protect with confidential computing/TEEs (e.g., Intel SGX, AMD SEV), memory encryption, and strict process isolation when available.
- Encryption — a reversible transformation of plaintext into ciphertext using a key so only authorized parties (with key) can recover plaintext. Two main types:
- Symmetric encryption — same secret key used to encrypt and decrypt (e.g., AES). Fast, used for bulk data.
- Asymmetric encryption — public/private key pair; public key encrypts or verifies, private key decrypts or signs (e.g., RSA, ECC). Used for key exchange, signatures.
- Hash function — a deterministic function H that maps arbitrary-length input to fixed-length output (digest). Important properties: preimage resistance, second-preimage resistance, collision resistance.
- Message Authentication Code (MAC)/HMAC — a keyed digest that verifies integrity and authenticity. HMAC uses a hash function plus a secret key.
- Digital signature — uses asymmetric keys to provide non-repudiation and integrity: sign with private key, verify with public key.
- Key Management — generation, storage, rotation and destruction of cryptographic keys. Central to all cryptography; use a Key Management Service (KMS) and Hardware Security Module (HSM) where feasible. When deriving keys from passwords, use a memory-hard KDF (Argon2, scrypt) or PBKDF2 with a high iteration count.
- Envelope encryption — encrypt data with a data key (symmetric), then encrypt that data key with a key-encryption-key (KMS/HSM). Preferred for large data and scalable key control. Distinguish server-side encryption (provider-managed or customer-managed keys, BYOK/CMK) from client-side encryption (you hold the keys/HYOK) based on control and compliance needs.
- Identity and Access Management (IAM) — policies, roles and permissions controlling who/what can access resources. Implement least privilege and role separation.
- Multitenancy — cloud providers host multiple customers on shared hardware; must ensure logical isolation (VM/container/network) and strict access controls.
- Threat model — list assets, actors (insider/outside), capabilities, attack vectors and mitigations. Always document assumptions.
Cryptographic assumptions and RSA derivation (exam-style): Assumptions: choose two large primes p,q, compute n = p·q. Security of RSA assumes factoring n is computationally hard. Let φ(n) = (p-1)(q-1). Choose e such that gcd(e, φ(n)) = 1. Compute d such that e·d ≡ 1 (mod φ(n)). Encryption: c = m^e mod n. Decryption: m = c^d mod n. Proof uses Euler's theorem: if gcd(m,n)=1 then m^{φ(n)} ≡ 1 (mod n); since e·d ≡ 1 (mod φ(n)), exponentiation recovers m. For completeness, correctness holds for all m ∈ Z_n; a full proof uses the Chinese Remainder Theorem (CRT) to handle cases where gcd(m,n) ≠ 1. In exams you may assume m < n and gcd(m,n)=1 unless asked to show the CRT case.
Design diagram to draw (label exactly):
- Draw client (left) labeled "Client App"; draw arrow labelled "TLS (HTTPS)" to a box labelled "Cloud Object Store / DB" (center).
- Above the object store box, draw a small box labelled "KMS / HSM" and connect with a double-headed arrow labelled "Envelope encryption keys: KEK".
- Inside object store box, draw an encrypted file icon and a small key labelled "Encrypted Data Key (EDK)". Annotate: "Data encrypted with AES-GCM using Data Key (DK); DK encrypted under KEK in KMS."
- Add an IAM box labeled "IAM", and an audit/logging component to the right labeled "Audit Logs / SIEM"; connect "Audit Logs / SIEM" to both the object store/DB and the IAM box. This diagram shows envelope encryption, TLS, KMS, logging and IAM interactions.
Formulas
n = p · q — n is RSA modulus, p and q are primes (no units).
φ(n) = (p - 1) · (q - 1) — Euler's totient for RSA modulus.
e · d ≡ 1 (mod φ(n)) — e is public exponent, d private exponent; modular inverse relation.
c = mᵉ mod n — RSA encryption; m is plaintext integer with 0 ≤ m < n.
m = cᵈ mod n — RSA decryption recovers plaintext.
HMAC(k,m) = H((k ⊕ opad) || H((k ⊕ ipad) || m)) — HMAC definition; H is a hash function, k key, ipad/opad inner/outer pads.
H = -Σ p_i · log₂ p_i — information entropy in bits for discrete distribution (units: bits); used for password/key entropy estimation.
Notes on symbols: exponents and modular arithmetic are dimensionless; bits used for key lengths (e.g., 2048-bit RSA, 256-bit AES). Use recommended key sizes per current guidance (verify with instructor/provider).
Worked examples
Example 1 — RSA numeric (standard exam exercise): Given p = 61, q = 53, choose public exponent e = 17, and plaintext message m = 65. Show key generation, encryption and decryption. Steps:
- Compute n = p · q = 61 · 53 = 3233.
- Compute φ(n) = (p-1)(q-1) = 60 · 52 = 3120.
- e = 17; check gcd(17,3120) = 1 (ok).
- Find d such that e·d ≡ 1 (mod 3120). The modular inverse of 17 mod 3120 is d = 2753 because 17·2753 = 46801 and 46801 ≡ 1 (mod 3120).
- Encryption: c = mᵉ mod n = 65¹⁷ mod 3233 = 2790 (standard computed result).
- Decryption: m = cᵈ mod n = 2790²⁷⁵³ mod 3233 = 65 (returns original). Final answers: private key d = 2753, ciphertext c = 2790, decrypted m = 65. (When showing modular exponentiation in exams, either use repeated squaring or state that intermediate modular exponent steps are computed; the final numeric values above are standard results.)
Example 2 — Model answer: Designing cloud data security for object storage (long question) Problem: Describe a secure architecture to store customer files in cloud object storage. Model answer structure (full-marks):
- Threat model (brief): unauthorized remote attacker, stolen credentials, malicious insider, leaked keys, snapshot-based attacks.
- Goals: confidentiality, integrity, availability, auditability, compliance.
- Controls:
- Transport: enforce TLS 1.2+/TLS 1.3 for all client-server connections; mutual TLS for service-to-service where needed.
- Storage encryption: use envelope encryption — per-object randomly generated Data Key (DK) encrypted with Key Encryption Key (KEK) in KMS/HSM; use AES-GCM for authenticated encryption to provide confidentiality + integrity.
- Key management: central KMS for KEK, HSM for master keys, strict IAM policies to restrict KMS operations, automated key rotation schedule.
- Access control: IAM roles, least privilege, temporary credentials (short-lived tokens), RBAC or ABAC depending on requirements. Log every access using immutable audit logs forwarded to SIEM.
- Backup & lifecycle: encrypted backups, versioning, secure deletion (cryptographic erasure by destroying DK/KEK; zeroize keys in memory/HSM), object lock/WORM for immutability when required, retention policies to meet compliance.
- Monitoring & incident response: anomaly detection, alerts on unusual key usage, revoke/rotate keys on suspected compromise.
- Diagram: (describe drawing — see earlier diagram description).
- Rationale: envelope encryption scales (avoid encrypting large objects with KMS directly) and KMS/HSM protects KEK; TLS protects in-transit; logs support forensics.
- Limitations and trade-offs: availability depends on KMS; design must consider region-failure and cross-region replication with replicated KMS keys or re-encryption. Also consider data/key residency and lawful access/jurisdictional requirements. This model answer includes architecture, components, and justification — what examiners expect.
Common mistakes
- Thinking TLS alone is sufficient for persistent storage confidentiality (must also encrypt at rest and handle keys correctly).
- Using outdated algorithms or short keys: e.g., using MD5, SHA-1, or <2048-bit RSA without justification.
- Rolling your own cryptography instead of using vetted libraries and recommended modes (AES-GCM, AES-CBC+HMAC historically but prefer AEAD).
- Not handling key rotation, revocation, or backup of keys — leads to data loss or prolonged compromise.
- Ignoring metadata leakage (filenames, sizes, timestamps) which can leak sensitive info.
For your exam
Question types you will see:
- Definitions (short): define confidentiality, integrity, envelope encryption, KMS, HSM.
- Short notes: describe data-at-rest vs data-in-transit; explain HMAC; differences between symmetric and asymmetric crypto.
- Derivations/proofs: RSA key generation and proof that decryption recovers plaintext (use Euler's theorem); show HMAC structure and reason it resists extension attacks.
- Design questions (long): propose a secure cloud storage architecture — include diagram, KMS, IAM, logging, backup and lifecycle.
- Case studies and threat modelling: identify assets, threats and mitigations for a given cloud deployment. What a full-marks answer includes:
- Clear definitions with bold terms, stated assumptions.
- Correct formulas and derivations (e.g., RSA proof via Euler's theorem), step-by-step.
- A labelled diagram where asked (draw client, TLS, object store, KMS/HSM, audit logs, IAM).
- Trade-offs and limitations, and references to best practices (use KMS, HSM, AEAD algorithms, key rotation).
Quick check
- What is envelope encryption?
- List the three security properties of a cryptographic hash function.
- In RSA, why must gcd(e, φ(n)) = 1?
Answers: Envelope encryption encrypts data with a data key and encrypts that data key under a key-encryption-key (KMS/HSM); cryptographic hash properties are preimage resistance, second-preimage resistance, collision resistance; gcd(e, φ(n)) = 1 so that e has a modular inverse d (e·d ≡ 1 mod φ(n)), enabling decryption.
Finished this topic? Mark it so your progress, study plan and readiness keep up.
Stuck on something here?