Cloud Security Architecture Questions
Designing and reasoning about the security posture of cloud and hybrid infrastructure: the shared responsibility model, network segmentation and boundary design, multi-account and multi-region security architecture, workload identity as an architectural choice, threat modeling a cloud architecture, cloud-specific attack vectors and mitigations, defense-in-depth control selection, secure cloud deployment patterns, and continuous cloud risk assessment and posture. IAM policy authoring, role/trust-policy mechanics, and secrets/credential lifecycle belong to identity-and-access-management; logging-pipeline design and SIEM/detection-rule engineering belong to security-monitoring-and-detection; encryption-key-management mechanics (KMS/CMK/BYOK) belong to data-protection-and-encryption; compliance-framework mapping (SOC2, PCI-DSS, HIPAA, GDPR) belongs to compliance-frameworks-and-certification-standards. This topic keeps identity, logging, or encryption content only when it is one ingredient inside a genuinely multi-control cloud-hardening question, not as a standalone ask.
Design a plan to minimize blast radius and prevent privilege escalation for a tenant onboarding flow where tenants can upload custom plugins executed in your platform. Include sandboxing options, resource limits, policy enforcement, and monitoring. Discuss trade-offs between extensibility and security.
Sample Answer
Direct answer
A tenant-onboarding flow that runs custom, tenant-uploaded plugins is a deliberate extensibility feature that inverts the platform's normal trust model: every other part of a multi-tenant platform treats the tenant as a data owner, but a plugin-execution feature treats the tenant as a code contributor, which is a categorically higher-trust grant, and the design has to assume every uploaded plugin is hostile until sandboxing, resource limits, and policy enforcement prove otherwise for that specific execution.
Structured elaboration
Sandboxing options. A dedicated, per-execution isolated environment (a microVM such as Firecracker, or a gVisor-style user-space kernel, rather than a standard container alone) gives the strongest isolation, since a standard container shares the host kernel with every other container on that host, and a kernel-level vulnerability in the plugin's execution path could escape a standard container more readily than a microVM's stronger isolation boundary. The trade-off is cold-start latency and per-execution resource overhead, both meaningfully higher for a microVM than a lightweight container, which matters if the platform's extensibility feature needs to support low-latency, frequent plugin invocations rather than occasional, longer-running ones.
Resource limits. CPU, memory, execution-time, and disk quotas enforced per plugin execution, sized conservatively against the platform's actual legitimate use cases rather than generously "to be safe for whatever a plugin might need," since a generous default resource allocation is itself an attack surface, a resource-exhaustion attack against the host or against other tenants' plugins sharing the same infrastructure.
Policy enforcement. A plugin's network access should default to none, with any legitimate external call requiring an explicit, reviewed allow-list entry (which specific destination, for which specific plugin), rather than a plugin having general outbound internet access by default; filesystem access should be limited to a scratch space specific to that execution, with no access to the host filesystem or to another tenant's data; and the plugin's own execution identity (if it needs to call back into the platform's own APIs at all) should hold the narrowest possible, per-tenant-scoped permissions, never a broad platform-wide credential.
Monitoring. Runtime behavioral monitoring specific to plugin executions (unusual resource consumption, an unexpected network connection attempt, an attempt to access a filesystem path outside the assigned scratch space) should be treated as a higher-priority detection surface than the platform's general workload monitoring, since this is the one execution context the platform has deliberately opened to untrusted, tenant-authored code; every plugin execution's full resource usage and any policy-violation attempt should be logged, both for security investigation and to build the behavioral baseline a genuinely malicious plugin would eventually deviate from.
Trade-offs between extensibility and security
Isolation strength versus latency and cost. Stronger sandboxing (a microVM per execution) costs more in cold-start time and per-execution infrastructure overhead than a lighter-weight container-based approach; a platform whose extensibility feature needs to support fast, frequent, low-latency plugin calls faces real pressure to weaken isolation for performance, which is exactly the trade-off that needs to be made deliberately and documented, not eroded gradually under performance pressure without anyone revisiting the original security rationale.
Capability richness versus attack surface. The more a plugin is permitted to do (broader network access, more platform API surface, longer execution time), the more genuinely useful and differentiated the extensibility feature becomes for legitimate tenants, and the larger the attack surface for a malicious one; this needs to be a deliberate, reviewed API surface, not "whatever the plugin SDK happens to expose," with each additional capability weighed against what it would let a hostile plugin do.
Development friction versus review depth. A policy-enforcement layer that requires per-plugin review before granting any elevated capability (a network allow-list entry, for instance) protects the platform but slows down legitimate tenant developers; an automated, policy-as-code review path for common, well-understood capability requests can reduce that friction for the common case while still requiring human review for anything genuinely novel or broad.
Worked example
A platform allowing tenants to upload plugins that process customer data during a workflow step runs each plugin execution in a Firecracker microVM, with a hard CPU and memory limit sized against the platform's own profiling of legitimate plugin workloads, a 30-second execution timeout, no default network access, and filesystem access limited to a per-execution scratch directory that is destroyed after the execution completes. A malicious plugin attempts to exfiltrate processed data by opening an outbound network connection to an external destination; because network access defaults to none and this plugin was never granted an allow-list entry, the connection attempt fails at the sandbox boundary, and the attempt itself is logged and flagged, triggering a review of the plugin and the tenant account that uploaded it. A separate, legitimate plugin genuinely needs to call one specific external API as part of its documented function; that specific destination was reviewed and added to that plugin's own narrow allow-list at onboarding time, distinct from every other plugin's own (likely empty, or differently-scoped) allow-list.
Trade-offs and pitfalls
- A shared, platform-wide network allow-list (rather than a per-plugin, per-tenant one) is a common shortcut that defeats the isolation the rest of the design carefully builds, since it would let any plugin reach any destination another plugin was legitimately granted access to, reintroducing exactly the cross-tenant reach this design otherwise structurally prevents.
- Resource limits sized too conservatively break legitimate plugin use cases, while limits sized too generously widen the resource-exhaustion attack surface; getting this right requires actual profiling of legitimate plugin workloads before setting the limits, not a guessed value, and revisiting the limits as the platform's actual plugin ecosystem evolves rather than treating the initial sizing as permanent.
- The isolation-versus-latency trade-off is the one most likely to erode gradually under performance pressure, since a slow cold start is a visible, immediate complaint from tenant developers, while a weakened isolation boundary's cost is invisible until an actual exploit occurs; the original security rationale for the stronger isolation choice needs to be documented and revisited deliberately if performance pressure ever prompts a proposal to weaken it, not silently traded away.
- Runtime behavioral monitoring depends on plugin executions actually generating enough signal to establish a meaningful baseline, a genuine limitation for a very low-volume or brand-new plugin, similar to the cold-start baseline problem present in other anomaly-detection designs in this domain; a new or rarely-invoked plugin's monitoring needs either a more conservative default sensitivity or a longer observation period before its behavioral detection can be trusted at full confidence.
Prepare a ransomware prevention and recovery design for cloud workloads and data. Cover immutable backups (WORM/Object Lock), backup account separation, cross-region replication strategy, backup encryption and KMS key separation, least-privilege for backup operators, automated testing of restores, and cost controls. Also describe detection signals that might indicate ransomware activity and the immediate playbook actions you'd take.
Sample Answer
Direct answer
A ransomware-resilient backup design assumes the attacker will eventually hold valid credentials in the production environment, and builds the recovery path so that credential is structurally incapable of reaching the backups: immutable storage (Write Once Read Many (WORM), enforced via Object Lock), a dedicated backup account the production credentials cannot touch, and least-privilege backup operators are the three controls that together mean "the attacker compromised production" does not also mean "the attacker can delete the recovery path."
Structured elaboration
flowchart TB
subgraph WA["Workload account"]
App["Application"] --> Prod[("Production data")]
end
subgraph BA["Dedicated backup account (separate from workload)"]
Vault1[("Backup vault, region A, Object Lock: Compliance mode")]
Vault2[("Backup vault, region B, cross-region copy")]
end
Prod -->|"one-way backup role, PutObject only"| Vault1
Vault1 -->|"scheduled cross-region copy"| Vault2
Restorer["Restore-test job (least-privilege, read-only)"] -->|"weekly automated restore drill"| Vault1
Attacker(["Compromised workload credential"]) -.->|"no delete/overwrite permission on vault"| Vault1
Immutable backups (WORM/Object Lock). Object Lock in Compliance mode (not Governance mode, which even an account root user can override) means no principal, including a compromised administrative credential, can delete or overwrite a locked backup object before its retention period expires; this is the single control that most directly defeats a ransomware actor's typical playbook of deleting backups before encrypting production data.
Backup account separation. The backup destination lives in a dedicated AWS account (or equivalent project/subscription on GCP/Azure) that the production workload's own credentials have no delete or administrative access to at all, only a narrow, one-way write path. This means a full compromise of the production account's identity and access management (IAM), including a compromised administrator credential in that account, still cannot reach into the backup account to remove the recovery path, since that permission was never granted in the first place, not merely restricted.
Cross-region replication strategy. Backups replicate to a second region on a scheduled basis, protecting against a region-level event independent of ransomware specifically (an infrastructure outage, a regional service disruption), and adding a second layer of recovery even in the unlikely case the primary backup vault's own region is somehow compromised.
Backup encryption and Key Management Service (KMS) key separation. Backup data is encrypted with a KMS key that lives in the backup account, not the production account; a compromised production credential cannot decrypt, and more importantly cannot request deletion of, a key it was never granted access to. Key separation matters as much as account separation, since a shared key would leave decrypt access reachable from production even if the storage itself were otherwise isolated.
Least-privilege for backup operators. The identity that writes new backups holds exactly PutObject (and equivalent) permission on the vault, nothing else, no delete, no ability to modify Object Lock settings, and no read access to unrelated data; the identity that runs restore tests holds read-only access scoped to the vault, never write or delete. Neither identity is broad enough to undo the immutability guarantee even if it were itself compromised.
Automated testing of restores. A scheduled job performs a genuine restore, not just a checksum verification, on a regular cadence (weekly, in the diagram above), because a backup that has never actually been restored is an unverified assumption, not a working recovery capability; ransomware-readiness reviews routinely find backups that technically exist but fail to restore when actually needed.
Cost controls. Immutable, cross-region, versioned backups accumulate storage cost indefinitely unless a lifecycle policy transitions older, still-locked backups to a cheaper storage tier after their compliance-critical recency window passes, and eventually expires versions once their retention period is satisfied; cost control has to be designed alongside immutability, not treated as a reason to shorten retention below what the recovery objective actually requires.
Detection signals for ransomware activity. A sudden spike in file-modification or encryption-pattern activity across a filesystem or object store; an unusual volume of PutObject calls overwriting existing keys in rapid succession; a spike in failed decryption or file-open errors reported by monitoring agents; and, specifically relevant to the backup design itself, any attempted delete or Object Lock modification call against the backup vault, which should never happen legitimately and is a near-certain indicator of an attack in progress given the least-privilege design above.
Immediate playbook actions. Isolate the affected workload (network-level quarantine, not deletion, to preserve forensic evidence) the moment ransomware activity is detected; confirm the backup vault's integrity and immutability status independently, since this design assumes it cannot have been touched, but confirming that assumption explicitly is still the first recovery-readiness check; identify the last known-clean restore point using the tested restore capability; and begin restoring to a clean, isolated environment rather than back into the still-compromised production account.
Worked example
A ransomware actor gains administrator-level credentials in a company's production AWS account through a phishing attack and begins encrypting data across the account's storage. Detection: the security team's monitoring flags an unusual spike in PutObject calls overwriting existing object keys across several buckets within a short window, well outside the account's normal write pattern. Immediate action: the affected instances and their network access are isolated. The team confirms, as designed, that the attacker's credentials, scoped entirely within the production account, have no path to the separate backup account at all; an attempted DeleteObject call against the backup vault (which the attacker's automated ransomware tooling did in fact attempt, per the design's detection signal) is denied outright by IAM before it ever reaches the Object Lock check, since the compromised credential was never granted delete permission on that account in the first place. Recovery proceeds from the most recent tested restore point, into a newly-provisioned, isolated environment, not back into the still-potentially-compromised original account.
Trade-offs and pitfalls
- Governance mode is a common, dangerous shortcut. It is easier to configure than Compliance mode because it permits an override by a sufficiently privileged principal, but that is exactly the property ransomware exploits if the attacker's compromised credential happens to hold that override permission; Compliance mode's inflexibility is the actual point of the control, not a limitation to work around.
- Backup account separation only holds if the separation is genuinely one-way. A backup account that grants the production account any administrative or delete-capable role back into itself (even one intended only for emergency operator use) reopens exactly the path this design exists to close; any emergency access needs to be a separate, tightly audited, out-of-band process, not a standing IAM relationship.
- Untested restores are the single most common gap discovered during an actual ransomware incident, not a hypothetical risk. A backup program with excellent immutability and account separation but no regular, automated restore testing can still fail at the moment of truth if the backup format has silently drifted from what the restore tooling expects; the weekly restore drill in the design above is not a nice-to-have, it is the control that validates every other control actually works end to end.
- Cost controls that shorten retention below the actual recovery objective undermine the whole design for the sake of a smaller storage bill. A retention window shortened to save cost, without re-evaluating whether it still covers a realistic "time to detect a slow, stealthy ransomware campaign," can leave the organization with only encrypted, already-compromised backups by the time the attack is finally noticed.
List and explain ten common cloud misconfigurations that frequently lead to breaches or data exposure across AWS, Azure, and GCP (for example: open storage buckets, overly permissive IAM policies, public database endpoints, default credentials). For each misconfiguration briefly state how you would detect it and the primary remediation step.
Sample Answer
Direct answer
Most cloud breaches trace back to a small, repeatable set of configuration mistakes rather than novel exploits: open storage, over-broad identity and access management (IAM), exposed management interfaces, and defaults left unchanged. The ten below are the ones that recur across AWS, Azure, and GCP specifically, generalized so the same mental checklist applies regardless of which provider is in front of you.
Structured elaboration
| # | Misconfiguration | Detection | Primary remediation |
|---|---|---|---|
| 1 | Publicly readable/writable object storage (S3 buckets, Azure Blob containers, GCS buckets) | Cloud security posture management (CSPM) inventory scan checking public ACLs (access control lists) and bucket/container policies | Enable Block Public Access (or the provider equivalent) as an account-wide default, not a per-bucket opt-in |
| 2 | Overly permissive IAM policies (wildcard actions/resources) | Policy analyzer or access-analysis tooling scanning for "*" in the action or resource fields of attached policies | Replace with a least-privilege policy scoped to actual usage, validated against real call history |
| 3 | Publicly reachable database endpoints (RDS/Cloud SQL/Azure SQL with a public IP and open security group) | Network configuration scan cross-referencing public IP assignment with the database's security group or firewall rule | Move the database to a private subnet with no public IP, and restrict access to the application tier's security group only |
| 4 | Default or unrotated credentials (default service account keys, unrotated root/admin keys) | Credential-age reporting (IAM credential report on AWS, equivalent identity audit on GCP/Azure) | Rotate immediately, then enforce a maximum credential age with automated rotation for anything long-lived |
| 5 | Management ports open to the internet (SSH/22, RDP (Remote Desktop Protocol)/3389 reachable from 0.0.0.0/0) | Security group/network security group audit for ingress rules with an unrestricted source CIDR on those ports | Restrict to a bastion host, VPN (Virtual Private Network) range, or a just-in-time access mechanism, never a direct internet-wide allow |
| 6 | Missing encryption at rest on storage or database resources | Configuration scan checking each resource's encryption setting against policy | Enable default encryption (provider-managed or customer-managed key) at the account or organization level so new resources inherit it |
| 7 | Overly permissive cross-account or cross-tenant trust relationships | IAM trust-policy scan for Principal values referencing an external account without a condition (such as an external ID) | Add an external ID condition and scope the trust to only the specific external principal that needs it |
| 8 | Logging or audit trail disabled or not centralized (CloudTrail/Activity Log/Cloud Audit Logs turned off or not shipped to a separate account) | Organization-level check confirming every account or subscription has logging enabled and forwarding to a dedicated log-archive destination | Enable organization-wide logging as a baseline requirement, enforced by policy, not left to each team to configure |
| 9 | Excessive network access between environments (no segmentation between development, staging, and production networks) | Network topology review confirming routing and security group boundaries actually separate environments, not just naming conventions | Enforce separate VPCs/virtual networks per environment with explicit, minimal peering rather than one flat network |
| 10 | Serverless functions or compute instances with broader IAM permissions than their event source or workload requires | Access-analysis tooling comparing a role's granted permissions against the resource's actual API call history | Scope down to the resources actually used, deployed behind a monitored canary period before full cutover |
Worked example
Applying items 1, 2, and 5 to one small environment: a startup's AWS account has a public documentation bucket (correctly public, item 1 does not apply here), an application role with dynamodb:* on Resource: "*" (item 2), and a bastion security group allowing SSH from 0.0.0.0/0 (item 5). Detection: the access-analysis tool flags the DynamoDB role because its actual CloudTrail history shows only GetItem and PutItem calls against one table, and the security group audit flags the bastion rule because its source CIDR is unrestricted. Remediation: the role is narrowed to dynamodb:GetItem/PutItem on that one table's ARN (Amazon Resource Name), and the bastion's security group is restricted to the company's VPN egress CIDR. Neither fix touches the intentionally-public documentation bucket, which is why detection needs to distinguish "public" from "wrongly public" rather than flagging every public resource identically.
Trade-offs and pitfalls
- Detection tooling is only as good as its baseline. A CSPM scan that flags every public bucket without a way to mark a bucket as intentionally public generates enough noise that a team starts ignoring its alerts, which is functionally the same as not scanning at all.
- Access-analysis-based least privilege depends on a representative sample of usage. A role scoped from 30 days of call history can miss a legitimate but infrequent code path (a monthly batch job, a quarterly report), so a scoped-down policy needs a monitored rollback window before being treated as final, not a one-shot cutover.
- Item 9 (environment segmentation) is the one most often skipped entirely, because a flat network is simpler to set up initially and the cost of the missing boundary is invisible until a development environment's weaker controls become the actual path into production.
- A single remediation step listed per item is a starting point, not a complete fix. Restricting a security group's source CIDR (item 5) reduces exposure but does not replace enforcing MFA (multi-factor authentication) or session logging on whatever the bastion ultimately grants access to; treat each remediation as the first of several controls, not the only one needed.
Explain how defense-in-depth applies to cloud-native services like managed databases, serverless functions, and managed caches. List concrete controls at the network, identity, compute, and data layers and explain how these layers compensate for each other's failures.
Sample Answer
Direct answer
Defense-in-depth for managed cloud-native services (a managed database, serverless functions, a managed cache) means the four layers, network, identity, compute, and data, still all apply, but each one is expressed differently than it would be for a self-managed server, since the provider has already absorbed part of the compute layer's traditional responsibility; the value of the remaining layers is precisely that they compensate for each other when one fails, not that any single layer is expected to be perfect.
Structured elaboration
Network layer. For a managed database: private subnet placement with no public endpoint, security-group scoping to only the application tier. For serverless functions: no network perimeter in the traditional sense, but Virtual Private Cloud (VPC) endpoints for the specific managed services the function depends on, and egress restricted to only what the function's logic actually requires. For a managed cache: identical private-placement and security-group scoping to the managed database's pattern, since a cache holding session data or partially-processed sensitive data deserves the same network isolation as a database, a control frequently under-applied because caches are perceived as lower-stakes than the primary data store.
Identity layer. For a managed database: identity and access management (IAM)-based database authentication (short-lived, auto-rotated tokens) rather than a static database password, and database-native least-privilege roles scoped per application. For serverless functions: a dedicated, narrowly-scoped execution role per function, never a shared role across multiple functions. For a managed cache: an authentication token or IAM-based access policy scoped to the specific application that legitimately reads and writes it, since a cache left with default or no authentication is a common, underestimated gap precisely because caches are often assumed to hold only "non-sensitive, disposable" data.
Compute layer. For a managed database: the provider handles the underlying host and engine patching entirely, so the compute layer's remaining customer responsibility is narrow but real, confirming the maintenance window and patch-application settings match the organization's own risk tolerance (deferring critical security patches too long, or accepting the provider's default schedule without review). For serverless functions: the compute layer's customer responsibility is the function's own code and its dependency tree, since the provider owns the execution environment. For a managed cache: similar to the database, the provider owns host and engine patching, with customer responsibility narrowed to configuration (eviction policy, persistence settings) that can have security implications (data lingering longer than intended if eviction is misconfigured).
Data layer. Encryption at rest with a customer-managed key (for the database and, where the cache offering supports at-rest persistence, the cache); encryption in transit enforced, not merely available, for connections to all three; and, specific to caches, a data-classification decision about whether the cache should ever hold genuinely sensitive data at all, since a cache's original design intent (fast, ephemeral, ideally non-critical data) is often violated in practice as an application evolves to cache something more sensitive than its original design assumed.
How the layers compensate for each other's failures
If the network layer fails (a security group accidentally widened, exposing the managed database's private endpoint to a broader range than intended), the identity layer's IAM-based authentication and narrow database role still require a valid, short-lived credential scoped to specific actions, meaning the network exposure alone does not grant an attacker meaningful access. If the identity layer fails (an overly broad execution role attached to a serverless function), the network layer's egress restriction still limits what that broadly-permissioned function can actually reach externally, even if its internal permissions are wider than ideal. If the compute layer fails (an unpatched vulnerability in a function's dependency is exploited), the data layer's encryption and the identity layer's narrow role together limit what the resulting compromise can actually read or exfiltrate, since the attacker inherits the function's own narrow scope, not broader account access.
Worked example
A managed cache is used to store partially-processed customer session data, more sensitive than the cache's original "just performance optimization" design intent, a drift that happened gradually as the application evolved. The network layer places it in a private subnet with a security group scoped to the specific application tier. The identity layer requires an authentication token scoped to that application. The data layer enforces encryption in transit. When a misconfiguration accidentally widens the cache's security group to a broader internal range (a network-layer failure), the identity layer's authentication requirement still blocks any of the newly-and-unintentionally-reachable internal services from actually reading cache contents, since none of them hold the required authentication token, illustrating the compensating relationship directly: the network-layer mistake did not become a data breach because the identity layer independently held.
Trade-offs and pitfalls
- Caches are the service most likely to be under-secured relative to their actual data sensitivity, precisely because their original design intent (fast, disposable, non-critical) creates an assumption that ages poorly as an application evolves to store more sensitive data in them over time. The worked example's session-data drift is a common, realistic pattern, not a contrived edge case, and it argues for periodically re-evaluating what a cache actually holds against its original security configuration, not assuming the initial classification remains correct indefinitely.
- The compensating-layers property only holds if each layer is genuinely independently configured, not derived from or dependent on another layer's own settings; a design where the identity layer's access decision itself depends on the network layer already having correctly restricted reachability (rather than being independently enforced regardless of network position) would not have caught the worked example's network-layer failure the way the independent identity check did.
- The narrower customer responsibility on the compute layer for managed services (patch scheduling and window review, rather than patching itself) is easy to treat as "nothing to do here," when the maintenance-window decision itself carries real risk if a critical patch is deferred too long relative to the organization's actual risk tolerance. A managed service reducing the compute-layer workload does not reduce it to zero.
- A common wrong turn is assuming that because the provider manages more of the compute layer for these services, fewer of the four layers need customer attention overall; the worked example shows the opposite is true in practice, all four layers still matter, they are simply expressed through different, service-specific mechanisms than they would be for a self-managed server.
You are reviewing an infrastructure-as-code repository (Terraform/CloudFormation) for a production cloud environment. List the most common high-risk misconfigurations you would look for across IAM, storage, networking, and compute. Also explain how you would automate detection of these misconfigurations in CI/CD before changes reach production.
Sample Answer
Direct answer
A production infrastructure-as-code (IaC) review should walk the same four surfaces every time: identity and access management (IAM), storage, networking, and compute, because that is the order in which a real breach typically chains (a broad credential finds an open door, and an open door leads to unencrypted data). Catching these at review time is necessary but not sufficient: the same checks need to run automatically on every pull request, not just when a human remembers to look.
Structured elaboration
| Category | High-risk misconfiguration to look for | Why it matters |
|---|---|---|
| IAM | Wildcard actions or resources ("Action": "*", "Resource": "*"); trust policies allowing AssumeRole from "Principal": "*"; missing multi-factor authentication (MFA) condition on privileged roles; static long-lived access keys checked into the repository | Turns any single compromised identity into an account-wide foothold |
| Storage | Bucket ACLs or policies allowing public read/write; Block Public Access disabled; missing default encryption; missing versioning on buckets holding data that must survive accidental deletion | Direct data exposure or irreversible data loss, often the visible symptom of a breach even when the entry point was elsewhere |
| Networking | Security groups with ingress from 0.0.0.0/0 on management ports (22, 3389); overly permissive network access control lists (NACLs); VPC (Virtual Private Cloud) flow logs disabled; resources placed in a public subnet with no clear reason | Widens the reachable surface for the earlier two categories to be exploited from the internet |
| Compute | Instances with unnecessary public IPs; hard-coded credentials in user-data or launch templates; instance metadata service left without http_tokens = "required" (IMDSv2 (Instance Metadata Service version 2) not enforced); containers configured to run as a privileged user | Gives an attacker who reaches a compute resource a path to the temporary IAM credentials or secrets on that host |
Worked example
The Terraform snippet below intentionally seeds one misconfiguration from each category; it is syntax-valid HashiCorp Configuration Language (HCL) against the AWS provider (validated with terraform validate), and each block is annotated with what a reviewer, or an automated check, should flag:
# IAM: wildcard action + wildcard resource
resource "aws_iam_policy" "too_wide" {
name = "app-policy"
policy = jsonencode({
Version = "2012-10-17"
Statement = [{
Effect = "Allow"
Action = "*" # flag: no wildcard actions
Resource = "*" # flag: no wildcard resources
}]
})
}
# Storage: bucket has no Block Public Access resource attached
resource "aws_s3_bucket" "app_data" {
bucket = "example-app-data-bucket"
# flag: missing aws_s3_bucket_public_access_block, missing
# aws_s3_bucket_server_side_encryption_configuration
}
# Networking: SSH open to the entire internet
resource "aws_security_group" "app" {
name = "app-sg"
ingress {
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"] # flag: should be a bastion/VPN CIDR only
}
}
# Compute: IMDSv2 not enforced (http_tokens left at its default "optional")
resource "aws_instance" "app" {
ami = "ami-0123456789abcdef0"
instance_type = "t3.micro"
metadata_options {
http_endpoint = "enabled"
# flag: http_tokens = "required" is missing
}
}
Automating detection in CI/CD
- Static analysis on every pull request. A policy-as-code scanner (Checkov, tfsec, or Terrascan) runs against the raw HCL before a human ever reviews it, catching exactly the four patterns above by pattern-matching the resource configuration, not by executing anything.
- Plan-time policy gate. Beyond static patterns, evaluate the actual
terraform planJSON output with a policy engine (Open Policy Agent (OPA)/Conftest, or a managed equivalent such as HashiCorp Sentinel) so the check sees the fully resolved configuration, including values coming from variables or modules that a purely static scan might miss. - Secret scanning on the IaC repository itself. A tool such as gitleaks or truffleHog run in the same pipeline catches a credential accidentally committed into a
.tffile or aterraform.tfvars. - Post-deploy drift detection. A pipeline gate only catches what goes through the pipeline; a scheduled cloud-native check (AWS Config managed rules, or an equivalent cloud security posture management (CSPM) tool) catches the same four categories of misconfiguration when they are introduced through the console instead of through IaC.
Trade-offs and pitfalls
- A pipeline gate that only runs against production IaC misses the source of the problem. Misconfigurations are frequently written first in a development or staging module and then copied into production later; the same static and policy-as-code checks need to run against every environment's plan, not just the one that matters most.
- Over-strict gates get bypassed. If a policy-as-code check blocks a legitimate, reviewed exception (a genuinely public documentation bucket, for instance) with no override path, teams learn to route around the pipeline instead of fixing the finding; a documented, time-boxed exception mechanism keeps the gate credible.
- Static analysis alone cannot see values resolved at plan time from a module or a data source, which is why the plan-time policy gate is a separate, necessary layer rather than a duplicate of the static scan.
Unlock Full Question Bank
Get access to all Cloud Security Architecture interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.