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.
How do you think about preventive, detective and corrective controls when you design a system? Take a customer-facing web application and show how you would balance the three, and what a dangerous gap in the mix looks like.
Sample Answer
Direct answer
Controls come in three jobs. Preventive controls stop a bad event from happening. Detective controls notice that it is happening or has happened. Corrective controls limit the damage and restore normal operation. A sound design uses all three because prevention is never perfect, so you need to see failures and be able to act on them. The dangerous gap is a mix with no working detection or no working correction: you cannot respond to what you cannot see, and seeing without a way to act only gives you better information about the loss.
Customer-facing web app, worked example: credential stuffing (attackers replaying passwords leaked elsewhere)
| Class | Control | Stack tier |
|---|---|---|
| Preventive | MFA (multi-factor authentication), rate limits, check passwords against known breached lists | Application and edge |
| Detective | Alert when failed-login volume or distinct-IP spread passes a baseline; alert on a sudden rise in password-reset emails | Logging and monitoring |
| Corrective | Force reset for affected accounts, revoke active sessions, block abusive IP ranges, notify users | Application and operations |
More examples across the stack:
- Cloud storage: a rule that blocks public buckets (preventive), an alert when a bucket policy changes (detective), an automated job that reverts the change (corrective).
- Data: least-privilege database accounts (preventive), alerts on unusually large exports (detective), restore from tested backups (corrective).
- Code: dependency checks in the build pipeline (preventive), runtime anomaly monitoring (detective), a one-step rollback (corrective).
How I balance them
Weight toward prevention where it is cheap and reliable (patching, secure defaults). Weight toward detection and correction where prevention cannot be guaranteed: an attacker holding a valid stolen password looks like a normal user, so detection and fast session revocation matter more than another input filter.
Dangerous gaps
- Preventive only: a breach can run for months unseen.
- Detective without correction: alerts fire but nobody can disable the account or restore data quickly.
- Detective without an owner: the alert goes to an unwatched mailbox at 2 a.m.
- Corrective never tested: the backup that fails on restore day.
How a tester validates each class
Preventive: try to bypass it. Detective: run the attack in a safe test and confirm the alert fired, how fast, and that a human saw it. Corrective: run a restore or revocation drill and time it.
What is attack surface reduction, and how would you apply it to an API platform? How would you tell whether the surface is shrinking or growing over time?
Sample Answer
Direct answer
Attack surface is the sum of all the places an attacker can send input to a system or pull data out of it: endpoints, parameters, open ports, credentials, dependencies and the privileges behind them. Attack surface reduction (ASR) removes or restricts those places so that there is less to find, test and exploit. For an API platform, that means fewer exposed endpoints, fewer ways in, and less power behind each one.
Applying it to an API platform
- Inventory first. Compare three sources: the API specification (such as OpenAPI), the gateway configuration, and real traffic logs. Anything in traffic or gateway but not in the spec is a shadow endpoint (exists but nobody documented it). For example, the spec lists
/ordersand/users, but the logs show real requests to/orders/exportand/internal/debug: those last two are shadow endpoints to investigate. OpenAPI is a standard file format for describing an API's paths and parameters. - Remove. Retire endpoints with no traffic in 90 days, old API versions, debug and admin routes, unused HTTP methods and unused response fields. Do it with a brownout first (a short, announced, temporary switch-off to see who breaks) and delete only if nobody objects.
- Gate what stays. Authentication on everything by default, narrow token scopes (each access token lists the specific actions it may perform, so a leaked one can do little), per-client rate limits, admin APIs reachable only from a private network or SSO.
- Shrink supporting surface. Fewer dependencies and container images, no public cluster API server (the control interface of a Kubernetes cluster should not be reachable from the internet), and a VPN gateway (the server remote staff connect through) that exposes only its tunnel port, with nothing else listening.
- Lightweight automated checks (secure defaults enforced in CI). A spec-diff check fails a pull request that adds a public endpoint without an owner annotation. A cluster admission policy (a rule the Kubernetes cluster checks before it accepts a new workload; OPA Gatekeeper and Kyverno are two example tools, and the idea matters more than the tool names) rejects public load balancers and privileged containers. A scheduled external scan checks the VPN gateway and API hosts for unexpected open ports.
Telling whether the surface is shrinking or growing
Track these weekly and plot the trend, not a single score:
- public endpoints, and of those, how many lack authentication
- shadow endpoints and endpoints with no traffic in 90 days
- externally reachable ports on the cluster and VPN gateway
- active API clients and tokens with broad scope
- third-party dependencies, and how many carry known critical vulnerabilities (CVEs, publicly catalogued security flaws, each with an identifier such as CVE-2021-44228)
Worked example (illustrative numbers)
Quarter start: 240 public endpoints. Of these, 36 had no traffic in 90 days and 18 were old v1 routes (assume the two groups do not overlap). Removing 54 leaves 186. Teams then ship 12 new endpoints, giving 198. Net change is 240 minus 198, which is 42 fewer, a 17.5% reduction. The count alone can mislead, so also check that the 12 new ones are authenticated and scoped: the raw count can fall while risk grows, for example if one of the 12 new endpoints is unauthenticated.
Pitfalls
Do not delete on assumption. Use a brownout before removal, as in step 2. Treat the count as a trend indicator, weighted by sensitivity.
Explain the principle of least privilege and give one concrete way you would enforce it for human users and one for machine identities in a cloud environment. Where does it usually erode over time?
Sample Answer
Direct answer
Least privilege means every person, program or service gets only the access it needs to do its current job, for only as long as it needs it, and nothing more. The point is to shrink the damage when an account is stolen or misused: a stolen account that can read one folder is a small incident, one that can administer everything is a large one.
Humans: just-in-time elevation (JIT)
Day to day, an engineer holds a low-privilege role through group membership. When they need production access, they request it for a stated reason and a short window, a second person or an automated rule approves, and the access expires on its own (for example after an hour). Everything done during the window is logged. The standing "always admin" account disappears, so a phished laptop yields little.
Machine identities: one scoped, short-lived identity per workload
A machine identity is the credential a program uses (a service account or cloud role). Give each service its own role, name the exact actions and resources, and issue short-lived credentials from the platform rather than long-lived keys pasted into config. Example for an invoice service that only reads PDFs (this is an AWS-style policy; other clouds use the same ideas under different syntax):
{
"Effect": "Allow",
"Action": ["s3:GetObject"],
"Resource": ["arn:aws:s3:::acme-invoices/*"]
}
Line by line: Effect: Allow says this rule grants access; Action lists the one operation permitted, s3:GetObject, meaning read a stored file; Resource names exactly what it applies to, here every file in the one storage bucket called acme-invoices (the long arn:aws:s3:::acme-invoices/* string is AWS's unique name format for a resource, and the * means any file inside it). Anything not allowed is denied by default. It cannot list other buckets, write, or touch the database. A related capability-based pattern (holding the token is itself the permission) hands out a narrow token for one operation instead of broad credentials. For example, a pre-signed link is a web address with a signature built in that lets whoever has it download one specific file for a few minutes, with no account needed.
Where it erodes over time
- Privilege creep: Priya moves from the payments team to search but keeps her payments database access, because nobody removes access on a transfer.
- Temporary becomes permanent: an emergency wildcard policy ("Action": "*", where the asterisk means every possible action) added during an outage and never narrowed.
- Orphaned service accounts and keys from retired projects.
- Copy-pasted policies that carry more permissions than the new service needs.
- Request friction: if getting the right permission is slow, people ask for the broad one.
Counter-measures
Tie access to team membership so it moves with the person; expire grants by default; compare granted permissions to permissions actually used (cloud providers report last-used data, and AWS IAM Access Analyzer, one example tool, can generate findings for unused roles, keys and permissions; other platforms have comparable reports) and remove the difference.
Give an example where least privilege and separation of duties pull in different directions on an enterprise system. How would you resolve the conflict technically or procedurally?
Sample Answer
Direct answer
Least privilege says give each person the minimum access for their job. Separation of duties (SoD) says split a sensitive task so no one person can complete it alone. They pull apart because SoD needs several people to each hold part of a powerful capability, and an emergency or a small team makes the cheapest way to get work done put it all in one person's hands. The resolution is to give the combined capability to a system, not a person, and make humans propose and approve.
Example: production database changes
- Least privilege says an on-call engineer fixing an incident should get exactly the access needed, fast.
- SoD says the person who writes a change must not also approve and apply it to production.
- The tension: the fastest fix gives the on-call engineer write access to production, collapsing author, approver and executor into one person. Or, to honor SoD, you create more privileged accounts (reviewers, approvers), which increases how many people hold some production power.
Technical resolution
- The engineer writes the change as code and opens a pull request.
- A second engineer must approve (the system blocks self-approval).
- A deployment pipeline identity, not a human, holds the narrow permission to run migrations. No person holds standing production write.
- For emergencies, a break-glass path grants time-limited write access that needs a second person's approval, records the session and triggers a review the next day.
Procedural resolution where tooling is not enough
Example: a small finance team of three where one person must both create vendors and release payments. Rotate the roles, require a second person to approve payments above a threshold set by finance policy, and have the owner review a report of all vendor changes and payments weekly. The approval above the threshold is preventive; the weekly report of vendor changes and payments is the detective compensating control (a substitute control that reduces the same risk when the ideal one is not practical). The whole arrangement should be documented as a known exception with an owner.
What would change my call
Very small teams or severe availability needs push toward compensating detective controls instead of strict splits. High-value actions keep the strict split even if it slows things down.
Explain defense in depth to me as you would to a new engineer, then show how you would apply it to an enterprise web application running in a hybrid cloud. What makes layers genuinely independent rather than merely redundant?
Sample Answer
Direct answer
Defense in depth means protecting an asset with several different controls in a row, so that when one fails (and eventually one will) the attacker still faces the next. Think of an airport: ID check, ticket check, security scan, boarding gate. A forged ticket gets past one step but not all of them. Layers are only worth having if they are independent: an attacker who beats layer one by some method should gain nothing toward beating layer two.
What makes layers independent rather than merely redundant
Redundant layers fail together; independent layers fail for different reasons. Check four things for any pair of layers:
- Different failure mode: a WAF (web application firewall, a filter that inspects web requests for attack patterns) is defeated by an encoding trick; parameterized database queries are not affected by that trick. For example, a WAF rule may block the text
' OR 1=1 --(a classic SQL injection string). An attacker sends the same characters percent-encoded (%27%20OR%201%3D1--, or encoded twice) in a way the WAF does not decode but the application does, so the attack slips through. A parameterized query sends the SQL text and the user's value to the database separately (SELECT * FROM users WHERE name = ?with the value supplied on its own), so the database treats whatever arrives as plain data and never as SQL, however it was encoded. - Different trust boundary and credentials (a trust boundary is the line where data or requests pass from a less-trusted zone into a more-trusted one, such as internet to web tier, or web tier to database): if one admin password or one management console controls both layers, compromising it removes both.
- Different technology or rule source: two firewalls from one vendor with one copied rule set share the same bug and the same misconfiguration.
- Different owner or change path: one bad deployment should not weaken both.
Quick test to apply in a design review: "Assume layer N is completely bypassed. What does the attacker still need to do?" If the answer is "nothing", the layers were redundant.
Worked example: SQL injection against an enterprise web app in a hybrid cloud (on-prem datacenter plus a public cloud)
| Layer | Control | Still protects if the layer above failed | Pentest check (a penetration test is an authorized, simulated attack by a tester) |
|---|---|---|---|
| Edge | WAF and DDoS protection (flooding attacks) | n/a | Send encoded payloads; then hit the app directly, skipping the WAF |
| Network | Separate segments for web, app and database; deny by default between them, in the datacenter and in the cloud network | A compromised web host cannot reach the database | From a web-tier foothold, try to connect to the database port |
| Identity | MFA (multi-factor authentication) for users; one separate identity per service | Stolen password alone is not enough | Replay a stolen session or password |
| Application | Parameterized queries, input validation | Injection fails even with no WAF | Test injection with the WAF disabled |
| Data | Database account limited to the tables and operations the app needs; encryption at rest | A successful injection reads little, not everything | Run injected queries and see what the account can reach |
| Detection | Central logging to a SIEM (security information and event management, a system that collects and alerts on logs) from both environments | Attack is noticed within minutes | Confirm an alert fires on the test attack |
In the hybrid case, keep the layers consistent across both sides: the same segmentation rules expressed as code in the datacenter and the cloud, one identity provider but separate break-glass (emergency) admin accounts per environment, and one log destination so the picture is not split.
The same idea in a streaming pipeline (Kafka brokers feeding Spark jobs)
Kafka is a system that carries streams of records between programs (brokers are its servers; producers write records and consumers read them), and Spark jobs process those records. The network zone limits who can reach the brokers; TLS plus authentication on every producer and consumer; per-topic ACLs (access control lists) so each job reads only its topics; schema validation at ingest so poisoned records are rejected; encryption at rest; audit logs of topic access.
Pitfalls
- Counting layers rather than testing independence.
- Layers nobody monitors: a layer that fails silently is no layer.
- Validating only from outside. Test each layer assuming the previous one failed (an assume-breach test, where the tester starts with an internal foothold).
Unlock Full Question Bank
Get access to all 10 Secure Architecture and Design Principles interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.