Secure Architecture and Design Principles Questions
Designing systems that are secure by construction: core design principles (least privilege, separation of duties, fail-safe and fail-secure defaults, secure-by-default, attack surface reduction, assume-breach), defense-in-depth and layered control placement, classifying controls as preventive, detective and corrective, secure design patterns such as tenant isolation and blast-radius limiting, security architecture reviews and secure-by-design checklists, and reasoning about trade-offs between security, usability, performance and delivery speed when selecting and placing controls, including build, native or buy choices and making the secure option the easy one for developers. Covers enterprise-scale reference architecture, such as placing enforcement across hybrid and multi-cloud estates and giving many teams a consistent baseline, how security requirements shape system structure, designing safeguards to degrade safely when a dependency is down or in an emergency, and testing whether layers and isolation hold. Boundary: the mechanics of identity, cryptography, networking, threat models, detection, incident response and compliance evidence are covered elsewhere.
Your cloud estate has hundreds of services and engineers, and permissions have crept up over the years. How would you enforce least privilege through guardrails and defaults rather than periodic manual reviews, without slowing developers down?
Sample Answer
Direct answer
I would stop new over-permissioning at the source with organization-level guardrails and paved-road defaults, then shrink existing excess using usage data, so that least privilege is the easy default rather than a periodic cleanup. Developers keep self-service inside a safe boundary, so security stops being a ticket queue.
Mechanisms, in the order I would roll them out
- Organization guardrails (SCPs, service control policies: a permission ceiling no account below can exceed): deny the things nobody legitimately needs, such as disabling audit logging, creating long-lived access keys for users, or using unapproved regions.
- Permission boundaries for delegated role creation. Teams may create their own roles, but only up to a maximum set of permissions, so self-service cannot become privilege escalation. A permission boundary is a policy attached to a role that sets its ceiling without granting anything: effective access is only what both the role's own policies and the boundary allow. For example, with a boundary that allows only
s3:*,dynamodb:*andsqs:*, a team role that was giveniam:*ands3:*ends up with S3 access only, because IAM actions fall outside the ceiling. - Paved-road templates. A paved road is the platform team's pre-approved, ready-made way to build and deploy a service, so the secure choice needs no extra effort. The standard infrastructure-as-code module (a reusable template that defines cloud resources as code) for a new service creates its own role with only listed actions on named resources and short-lived credentials. The easiest path is the safe path.
- Policy checks in the pipeline. A change that adds a wildcard action or grants new access beyond an approved baseline fails the pull request (cloud providers offer policy-validation and policy-comparison checks; AWS IAM Access Analyzer provides both).
- Right-sizing from usage. Unused-access findings (roles, keys and permissions not used within a window you set, such as 90 days) open automatic pull requests to remove them. A typical before and after, using illustrative names:
Before: Action "s3:*" Resource "*"
After: Action ["s3:GetObject","s3:PutObject"] Resource "arn:aws:s3:::orders-uploads/*"
The access logs showed the service only ever read and wrote objects in one bucket, so everything else could go.
6. Exceptions expire. Broad access is granted with an owner and an end date, enforced by the platform, rather than reviewed by hand.
Patterns across service types
| Layer | Pattern |
|---|---|
| IaaS (virtual machines) | One instance role per workload; no shared admin keys |
| PaaS and containers | Workload identity per Kubernetes service account (each application's pods get their own cloud identity instead of sharing the node's) |
| Serverless | One role per function, with only the resources it touches |
| Databases | Per-service database users with schema-level grants (rights limited to one set of tables rather than the whole database); short-lived credentials where supported; no shared admin login |
Keeping it valid over time
Policies live in version control; the pipeline blocks regressions; unused-access findings flow to owners automatically; and a small sample audit (not a full review) checks the automation is working.
Not slowing developers
Measure request-to-working-permission time. A boundary that lets a team self-serve in minutes removes the incentive to ask for admin "just in case".
Existing creep
Do not try a big-bang cleanup. Fix the most dangerous first: roles with administrator-equivalent rights and cross-account trust (a role that principals in another cloud account are allowed to assume), then the unused ones, with usage data proving removal is safe.
You are the first architect on a greenfield SaaS where performance and scale matter and enterprise customers will soon expect proof of security maturity. How would you decide which security controls to build into the architecture from day one, how would you keep them from hurting performance or developer speed, and how would you estimate and defend their ongoing cost?
Sample Answer
Direct answer. On day one I would build the controls that are cheap now and very expensive to retrofit: identity, tenant isolation, encryption and key handling, logging, and an automated build pipeline. I would defer controls that are expensive to run and easy to add later. I would deliver them as platform defaults so developers get them for free, and defend the cost as a small, explicit share of engineering spend tied to the enterprise deals it unlocks.
1. Deciding what goes in from day one. Score each candidate control on three questions: How hard to retrofit once data and customers exist? How much risk does it remove (what could we lose)? Do enterprise buyers ask for it? Retrofit pain is the main sorting rule.
| Build now | Why | Defer or keep light |
|---|---|---|
| Central sign-in with multi-factor and least-privilege roles | Hard to untangle later | Fine-grained attribute-based access for every feature (permissions decided by attributes such as department, region and data label rather than a few fixed roles) |
| Tenant isolation in the data layer | Retrofitting after launch is a rewrite | Separate infrastructure per tenant (offer later, as a paid tier) |
| Encryption in transit and at rest, managed keys | Cheap with cloud defaults | Customer-managed keys (the customer holds the encryption key and can cut off access by revoking it) |
| Audit logging with tenant and user context | Evidence and detection depend on it | Full security analytics platform |
| Infrastructure as code (the cloud setup written as reviewed text files instead of clicked together), dependency and secret scanning in the pipeline | Cheap, catches issues early | Formal bug bounty (a paid program inviting outside researchers to report vulnerabilities) |
| Backups, tested restore | Resilience baseline | Multi-region active-active (full copies running in several regions, all serving traffic at once) |
The right-hand column holds real options that a specific trigger brings forward: a bank customer asks for customer-managed keys, an outage review demands multi-region, a regulator asks for finer access rules. The other three deferred options get triggers too: separate infrastructure per tenant when a customer will pay for a dedicated tier, a formal bug bounty once the first external audit or penetration test has been closed out, and a full security analytics platform when log volume makes manual search unworkable. Each deferred option has a named trigger, so deferring is a scheduled decision rather than neglect.
2. Without hurting performance or speed.
- Secure by default (paved road): a service template with authentication, tenant scoping, logging and secure headers (response headers that make browsers enforce protections such as HTTPS-only) already wired in. The secure path is the easiest path.
- Cheap on the hot path: token verification and authorisation checks happen at the gateway with caching; heavy work (scanning, analytics) is asynchronous, off the request path. Measure latency in load tests with controls on, and set a budget agreed with the performance owner.
- Fast feedback: pipeline checks run in minutes and block only high-severity findings; the rest become tickets. Exceptions need an owner and an expiry date.
3. Evidence as a by-product. Because controls are code and pipeline steps, they leave records automatically: access reviews from the identity system, change approvals from pull requests, configuration state from infrastructure as code, logs from the platform. When an enterprise customer asks for a SOC 2 report (an independent auditor's attestation report on controls, measured against the AICPA Trust Services Criteria), much of the evidence already exists.
4. Estimating and defending cost (illustrative numbers). Assume 20 engineers at a loaded cost of 200,000 each (salary plus benefits, equipment and overhead, not salary alone), so engineering costs 4,000,000 a year. If the paved road and review process consume 3 percent of engineering time, that is 120,000. Add 60,000 for tooling. Total 180,000, which is 4.5 percent of engineering cost. Compare it with revenue at stake: if enterprise security reviews are blocking two deals of 250,000 annual value each, that is 500,000 a year. The point is not the figures (replace them with your own) but the shape: a named cost, a named benefit, and a review each quarter of whether the spend still earns its place. The 180,000 excludes the SOC 2 audit fee and an annual penetration test, which I would add as separate lines once an audit is scheduled, and the 500,000 is revenue, so I would compare the cost with the margin on it rather than the revenue. Retrofitting later is the alternative cost, and it is usually larger and arrives during a deal.
Pitfalls. Buying a tool stack before knowing the risks; adding a heavy gate that developers route around; promising maturity you cannot evidence. What would change my call: if the first customers are regulated, move audit logging and key management forward; if the data is low-sensitivity, defer more.
What does secure by default mean, and how would you apply it to a service you ship to other teams? Describe the defaults you would choose for a cloud-hosted service and how you handle teams who need to loosen them.
Sample Answer
Direct answer
Secure by default means that when someone uses the service with zero configuration, the result is already the safe one. Insecure behavior must be something a team deliberately asks for, never something they must remember to turn off. For a cloud service shipped to other teams, the safe path should also be the easiest path.
Defaults I would choose for the service
| Area | Default |
|---|---|
| Network | No public endpoint, no inbound access except from named callers; outbound traffic limited to what the service needs |
| Authentication | Required on every endpoint; no default or shared passwords; single sign-on (SSO) for humans, per-service identities for machines |
| Access | Least privilege roles; the creator is not automatically an administrator |
| Data | Encryption at rest on (using a managed key, one held and rotated by the cloud provider's key service, with every use logged), TLS (encrypted transport) required with an old-version floor (refuse old protocol versions, for example anything below TLS 1.2, because they have known weaknesses), storage never public |
| Logging | Audit logging on and shipped to a separate account the service team cannot edit |
| Updates | Automatic patching of images and dependencies |
The same idea applied to a Linux host image and a fresh cloud VM
- OS: a minimal, hardened, centrally built image with only needed packages; patched on a schedule.
- Services: nothing listening that was not asked for; SSH with keys or a managed session tool, password login off, root login off.
- Network: the default firewall rule (security group) allows no inbound traffic; the instance metadata service requires session tokens (IMDSv2 on AWS) so a web bug cannot easily steal credentials. The instance metadata service is a local address that a cloud VM can query for facts about itself, including temporary cloud credentials. In its first version a plain web request to that address returns them, so a bug that makes the application fetch an attacker-chosen URL (server-side request forgery) can leak them. IMDSv2 requires first obtaining a session token with a special request, which that kind of bug usually cannot make.
- Storage: disks encrypted, object storage with public access blocked.
Handling teams who need to loosen a default
Make loosening possible but visible: a self-service exception request names the owner, the reason, the compensating control (an alternative safeguard, such as an IP allow list when a port must open), and an expiry date. Low-risk loosening is approved by the service owner. High-risk loosening, such as a public endpoint or turning off encryption, needs a security sign-off and may be accepted by the business owner who carries the risk. Exceptions expire automatically and are reviewed.
Worked example
A team needs a public endpoint for a partner webhook. Instead of opening the service, they get a time-limited exception that allows exactly one path through the gateway with a WAF rule (a filter limiting that path to expected methods, sizes and request shapes) and request signing (the partner attaches a signature computed with a shared secret over the request body, so the service can verify who sent it and that it was not altered), approved for 90 days and renewed only if still used.
Pitfalls
Defaults that break every team's first deploy get disabled wholesale, so test them with real users. Track the number of active exceptions as a signal: a rising count means a default is wrong, not that teams are careless.
During an incident, your normal safeguards (authentication, rate limits, approval steps) can themselves become the outage. How would you design emergency fallbacks and break-glass paths that preserve continuity without creating a standing bypass attackers can abuse?
Sample Answer
Direct answer
A break-glass path is an emergency access route used only when normal controls cannot work. I design it as the opposite of a bypass: it is off by default, hard to open, narrow, time-limited, loud, and reviewed afterwards. The attacker-abuse risk comes from anything standing (a permanent credential, a flag that stays on, a header that skips authentication), so every fallback must expire on its own and leave evidence.
Principles
- Independent of the failing thing. If the identity provider is the outage, break-glass cannot depend on it. Use a small number of sealed emergency accounts (accounts whose credentials are kept offline, for example a hardware key in a locked safe, so that unsealing them is itself a visible event) held outside the normal login path, with hardware-key multi-factor authentication (a physical key that must be touched to log in, so a stolen password alone is not enough).
- Degrade, do not disable. Raise a rate limit (a cap on how many requests one client may make in a time window) for a named client for 30 minutes (illustrative) rather than removing rate limiting. Serve cached authorization decisions for a bounded time rather than skipping authorization.
- Time-boxed and scoped. Access is granted just in time (at the moment it is needed, not held permanently) for a defined resource set and expires automatically, with no manual cleanup needed.
- Two sets of eyes where possible. A second person approves, or in a true emergency the use is allowed and the approval is reviewed afterwards within a set time (illustrative: one business day).
- Loud and recorded. Any use pages the security team, sessions are recorded, and an alert fires on any login to an emergency account even if nothing else is wrong.
- Single use. Credentials are rotated after every use.
- Rehearsed. Test the path on a schedule, because an untested break-glass fails at 3 a.m.
Fallback per safeguard
| Normal safeguard | How it becomes the outage | Emergency path | Guardrail |
|---|---|---|---|
| Authentication | Identity provider down, nobody can log in | Sealed emergency account for the responders only | Auto-expire, page security, rotate after use |
| Rate limits | Limiter blocks a legitimate traffic spike or a retry storm (clients retrying failed requests all at once, which multiplies the load) | Time-limited higher limit for named clients | Expires on its own, alert if still raised at the deadline |
| Approval steps | Approver unreachable during a P1 (the highest-severity incident) | Pre-agreed emergency change class, approved afterwards | Review within a day, count and trend emergency changes |
One emergency, start to finish (illustrative times). 02:10: the identity provider fails and nobody can log in. 02:14: the on-call responder, Priya, declares a P1. 02:18: she unseals the emergency account with a hardware key; the access system grants a role limited to the identity provider's admin console for 60 minutes, expiring at 03:18. The same moment, a page goes to the security on-call with this alert: "Emergency account used: responder P. Rao, scope idp-admin, expires 03:18, session recorded." 02:50: the identity provider is restored. 03:18: the role expires on its own and the credential is rotated. Next business day: a second person reviews the session recording against the incident timeline, confirms nothing outside the admin console was touched, and records the use in the emergency-access log.
Anti-patterns
A shared emergency password in a wiki, a debug header that skips checks, a feature flag with no expiry, a break-glass role that is also used for daily work, and an emergency account nobody monitors. Each one is a standing bypass.
Trade-offs
Stricter approval slows recovery, looser approval raises abuse risk. I resolve it by letting the responder act first but making every action traceable and reviewed. What would change my call: very small teams, where a second approver is not always reachable, so the after-the-fact review does more of the work.
Design a multi-region service so that the full compromise of one region, including its compute and network, cannot expose data or secrets in the others. What trade-offs are you accepting for failover?
Sample Answer
Direct answer
I treat each region as a separate trust zone (a cell) with its own accounts, keys, secrets and data, and I make sure no credential or key in one region can read anything in another. Then I accept slower, gated failover as the price. The question is not whether regions copy data to each other, but whether an attacker holding everything in region A, including administrator rights there, can turn that into read access in region B.
Design
flowchart LR
subgraph RegionA[Region A: own account, keys, secrets]
A1[Compute] --> A2[(Data A)]
end
subgraph RegionB[Region B: own account, keys, secrets]
B1[Compute] --> B2[(Data B)]
end
P[Deploy pipeline outside both regions] --> RegionA
P --> RegionB
A2 -. one-way replica, B key, A has no read .-> B2
- Separate cloud accounts or projects per region. The account is the strongest boundary the cloud offers. No role in A can be assumed from B and the reverse.
- Per-region keys and secrets. Each region has its own encryption keys and secret store with no shared master key. A key that exists in two regions defeats the isolation.
- Home-region data. Where the business allows, keep each tenant's data only in its home region, so the other regions do not hold it at all.
- Replication that cannot be turned backwards. For disaster recovery, replicate one way with a write-only permission into the replica, encrypted under the replica region's own key. This works because encryption needs only the write side of a key: region B's key service hands the replication role a fresh one-time data key (the key service returns it both in the clear and in a copy locked by B's key). The role encrypts each object with it, stores the locked copy beside the object and discards the clear one. Region A's role is granted that generate-data-key action and permission to put objects in the replica bucket, but not the decrypt action and not get-object, so it can add data under B's key without ever being able to read any of it back. The source region's compromise lets an attacker push junk or delete in the replica unless it has versioning and retention locks, so enable those: versioning keeps every earlier copy of an object when it is overwritten, and a retention lock (object lock, in its strict mode, which AWS calls compliance mode) refuses deletion of a version for a fixed period, say 30 days, even to an administrator or the root user in the replica account. The softer governance mode can be bypassed by anyone granted the bypass permission, so it does not give this guarantee.
- No trust by network location. Calls between regions use short-lived, narrowly scoped credentials, and the receiving region checks authorization per request. "It came from region A" is not an authorization.
- Shared things are common failure points. The deployment pipeline, identity, DNS and configuration service reach all regions. Keep the pipeline outside the regions, give it a separate deploy role per region, require approval for production changes, and monitor for deploys that touch all regions at once.
A worked trace (illustrative)
Region A is us-east and region B is eu-west. An attacker takes full control of A's servers and its administrator role. They try to read B's database: A's role is not trusted in B's account, so the call is refused. They try to read the replica bucket in B: the role lacks get-object, and even if an object were fetched it is encrypted under B's key, whose decrypt action A's role does not hold. They try to delete or overwrite the replica: the retention lock refuses deletion, and an overwrite only adds a new version, so the clean version can be restored. They try the pipeline route: it sits outside both regions and holds a separate deploy role per region, so a push needs approval and a simultaneous push to all regions raises an alert. The attacker's real gain is limited to region A's own data and the ability to add junk to the replica. The guarantee is directional: any data replicated INTO a region is exposed if that region is compromised, so in this one-way design a full compromise of region B would expose the replica of A's data (B holds the key). Replicate only the datasets disaster recovery needs, and if both regions must back each other up, each holds the other's replica and the isolation claim weakens to the data that was never replicated.
Trade-offs for failover
- Slower recovery. Promoting the replica needs a human-approved key grant and runbook, rather than automatic failover. Say, as an illustration, minutes of automated failover traded for tens of minutes. The business has to pick that number against the downtime cost.
- Data loss window. One-way asynchronous replication (the source commits a write first and copies it afterwards) means the replica lags, so recovery loses the most recent writes. The amount of recent data the business can afford to lose, expressed as time, is the recovery point objective (RPO); measure the replication lag and compare it with that target.
- Cost and operations. Duplicated key management, accounts, monitoring and testing.
- Weaker global features. No cross-region read, global search or shared cache without a deliberate, scoped exception.
What would change my call
If availability truly outranks confidentiality (for example a public information service), I would allow automated failover with per-region keys still separate.
Unlock Full Question Bank
Get access to all 37 Secure Architecture and Design Principles interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.