Security boundaries in system design: trust zones and where to enforce them, private networking (VNets, private endpoints, egress control), workload identity between services, least privilege, data segmentation and blast-radius reduction on Azure.
I draw trust zones on the diagram — internet, edge, application, data, admin and third parties — and treat every arrow that crosses a zone as a boundary with explicit controls. I design for zero trust: the network isn't the security boundary, so every call is authenticated and authorised with Microsoft Entra ID identities, and private networking is an extra layer. In Azure that means Front Door with WAF at the edge, private endpoints with public access disabled for SQL, Storage, Key Vault and Service Bus, managed identities with Entra tokens between services instead of shared secrets, least-privilege RBAC and PIM for admins. Azure Policy enforces those rules on every new resource and Defender for Cloud watches for drift and threats. To limit blast radius I separate environments into subscriptions, give each service its own identity and database role, and keep sensitive data in as few places as possible. The trade-off: every boundary adds friction, so the strongest ones go around the most sensitive data.
"I'd draw the zones on the diagram first. Internet; the edge, which is Front Door with the WAF; the application zone, where the APIs and workers run; the data zone with Azure SQL, Storage and Key Vault; the admin zone, which is how engineers and pipelines get in; and third parties like the payment provider. Every arrow that crosses a zone line is a boundary, and for each one I say how the caller is authenticated, what it's allowed to do, and how the traffic is protected.
The principle is zero trust: being inside the VNet doesn't make a caller trusted. So service to service, each workload has its own managed identity, gets an Entra ID token for the callee's audience, and the callee checks the audience and an app role — no shared API keys in config. The network is the second layer: PaaS services sit behind private endpoints with public network access disabled, the apps use VNet integration, and outbound traffic goes through Azure Firewall so a compromised container can't send data anywhere it likes. For example, at [company] we [found during a pen test that a reporting service had a connection string with db_owner on the main database and the storage account allowed public access]. I [moved each service to its own managed identity with a database role limited to the tables it needed, put storage behind a private endpoint, and moved admin access to PIM with approval], [and the pen test retest closed all [N] high findings].
The mistake I see is a flat design: one identity for everything, one database user with owner rights, PaaS on public endpoints 'protected' by a firewall rule, and engineers with standing admin. Then one leaked secret opens everything. So I design for blast radius: separate subscriptions per environment, one identity per service, per-tenant or per-domain data separation where the data is sensitive, and the fewest possible copies of personal data. Boundaries should be strongest where the data is most valuable, and everything that crosses one should be authenticated, authorised and logged."
Internet
| TLS 1.2+, WAF, rate limits, bot protection
[Front Door + WAF] ---------------------------- edge zone
| Private Link origin / access restrictions
[API (Container Apps / App Service, VNet-integrated)] --- app zone
| managed identity + Entra token | egress via Azure Firewall
[Worker] [Service Bus PE] -> [payment provider] third party
| managed identity, DB role per service
[Azure SQL PE] [Storage PE] [Key Vault PE] ----- data zone (public access off)
Admin zone: Entra ID + MFA + PIM -> Bastion / pipelines with workload identity federation
| Boundary | Authentication | Authorisation | Protection |
|---|---|---|---|
| User → edge | OIDC (Entra External ID), MFA where needed | Scopes / roles in token | TLS, WAF, rate limiting |
| Edge → API | Private Link origin or header check + access restrictions | Only Front Door may reach the API | No public origin |
| Service → service | Managed identity → Entra token | App roles, audience validation | Private networking, mTLS in a mesh if used |
| Service → data | Managed identity (Entra auth for SQL) | DB role per service, RBAC data roles | Private endpoints, TDE, Always Encrypted for the most sensitive columns |
| App → third party | Provider credentials in Key Vault | Least scope API keys | Egress allow-list, webhook signature checks |
| Human → production | Entra ID + MFA | PIM just-in-time roles with approval | Bastion, audit logs |
| Technique | Limits | Cost |
|---|---|---|
| Subscription per environment | A dev compromise reaching prod | More subscriptions to manage |
| Identity per service | Lateral movement | More role assignments |
DB role per service, no db_owner at runtime |
Data access to what the service needs | Migration identity separate |
| Per-tenant data separation (DB or key) | One tenant's breach exposing others | Ops and cost |
| Short-lived tokens, no secrets | Value of a leak | Some setup |
| Egress control | Data exfiltration | Firewall cost, allow-list upkeep |
After moving [12] services from shared SQL logins to managed identities with per-service roles and putting all PaaS behind private endpoints, the number of credentials stored anywhere dropped from [~40] to [3] third-party keys in Key Vault, and a pen test retest closed all [5] high findings with no performance impact beyond [~2 ms] of token caching on cold calls.
Checks whether the candidate builds security into the design as explicit boundaries with concrete controls, rather than a generic "we'll add HTTPS and a firewall".
Green flags
Red flags
db_owner for everythingThe old model was a hard perimeter with a soft inside. Cloud systems have many entry points (public PaaS endpoints, pipelines, third-party webhooks, developer laptops), so attackers who get one foothold move laterally. Zero trust assumes breach: verify explicitly, use least privilege, and limit blast radius.
Use STRIDE on the data flow diagram: for each element and each arrow crossing a trust boundary, ask about Spoofing, Tampering, Repudiation, Information disclosure, Denial of service and Elevation of privilege. The output is a list of controls tied to specific arrows, which is exactly what an interviewer wants to hear.
privatelink.database.windows.net) must resolve to the private IP — the most common setup mistake.Worker (managed identity)
-> Entra ID: client credentials, scope api://orders/.default
<- JWT (aud=api://orders, roles=[Orders.Read])
-> Orders API validates issuer, audience, signature, role
In .NET, DefaultAzureCredential (or ManagedIdentityCredential in production) gets and caches tokens; Azure SDK clients and Microsoft.Data.SqlClient (Authentication=Active Directory Managed Identity) use them directly. No secret exists to leak or rotate.
Most serious breaches go through privileged access. Use PIM for just-in-time roles, MFA for all admins, workload identity federation (OIDC) for GitHub Actions or Azure Pipelines instead of stored service principal secrets, and separate the identity that runs migrations from the runtime identity. These map to the ACSC Essential Eight controls on restricting administrative privileges and MFA.
nslookup from inside and outside the VNet resolves differently.db_datareader on one schema.DefaultAzureCredential and validate the audience and an app role in the callee.Service-to-service calls with managed identity on both sides: no secrets, explicit audience and role checks.
// Caller (Worker): gets a token for the Orders API using its own managed identity.
namespace Billing.Worker;
using System.Net.Http.Headers;
using Azure.Core;
using Azure.Identity;
public sealed class OrdersApiAuthHandler(TokenCredential credential) : DelegatingHandler
{
private static readonly TokenRequestContext Scope = new(["api://orders-api/.default"]);
protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken ct)
{
// Azure.Identity caches the token and refreshes it before expiry.
var token = await credential.GetTokenAsync(Scope, ct);
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", token.Token);
return await base.SendAsync(request, ct);
}
}
// Program.cs (Worker)
// builder.Services.AddSingleton<TokenCredential>(new ManagedIdentityCredential(ManagedIdentityId.SystemAssigned));
// builder.Services.AddTransient<OrdersApiAuthHandler>();
// builder.Services.AddHttpClient("orders", c => c.BaseAddress = new("https://orders.internal.example"))
// .AddHttpMessageHandler<OrdersApiAuthHandler>();
// Callee (Orders API): accept only tokens for this API that carry the right app role.
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.Identity.Web;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddMicrosoftIdentityWebApi(builder.Configuration.GetSection("AzureAd")); // validates issuer, audience, signature
builder.Services.AddAuthorizationBuilder()
.AddPolicy("OrdersReader", p => p.RequireRole("Orders.Read")); // app role granted to the worker's identity only
var app = builder.Build();
app.UseAuthentication();
app.UseAuthorization();
app.MapGet("/orders/{id:guid}", (Guid id) => Results.Ok(new { id }))
.RequireAuthorization("OrdersReader");
app.Run();
# Data zone: SQL reachable only through a private endpoint; the runtime identity is a least-privilege DB user.
az sql server update -g rg-prod -n sql-orders --set publicNetworkAccess=Disabled
# In the database (as the Entra admin):
# CREATE USER [orders-api] FROM EXTERNAL PROVIDER;
# ALTER ROLE db_datareader ADD MEMBER [orders-api]; -- no db_owner at runtime
db_owner for every service. Why it is wrong: One SQL injection or leaked string exposes and can destroy all data, turning a single bug into a company-wide notifiable breach. Instead: One identity and least-privilege role per service; a separate identity for migrations.Security boundaries are a design property, not a checklist added before go-live. Seniors draw the zones, attach controls to each crossing, and prioritise by data sensitivity and likelihood — privileged access and identity first, then network. They also accept that every control adds friction (private DNS, firewall rules, role assignments), so they automate it with infrastructure as code and Azure Policy rather than hand-configuring it.
| Control | When it fits | Cost | When not to |
|---|---|---|---|
| Managed identity + Entra tokens | Any Azure-hosted service-to-service or service-to-data call | Some setup, token caching | Calls to third parties that only support keys (store in Key Vault) |
| Private endpoints, public access off | Production data stores and brokers | DNS complexity, per-endpoint cost | Truly public content (use a CDN) |
| Service mesh mTLS | Many services on AKS, need workload-level encryption and policy | Mesh operations | A handful of PaaS services |
| Subscription per environment / domain | Clear blast-radius separation | Governance overhead | Tiny single-team projects |
| Customer-managed keys / Always Encrypted | Highly sensitive data, regulatory need | Key management, query limits | General data where platform encryption suffices |
I treat security and observability as parts of the diagram, not footnotes.
For security I draw trust boundaries, then say how each crossing is protected: users authenticate at the edge with Entra ID / OIDC, services use managed identities, data stores sit behind private endpoints, secrets live in Key Vault, and personal data is classified, minimised and kept in Australia East for Privacy Act obligations.
For observability I add OpenTelemetry traces, metrics and structured logs with one trace id across services, define SLOs for the main user journeys, and alert on burn rate, not CPU.
The trade-off is upfront effort and some cost (private networking, telemetry ingestion) against far cheaper incidents and audits later.
Least privilege means every identity gets only the permissions it needs, at the smallest scope, for the shortest time. For a .NET service in Azure I give each workload its own managed identity and assign data-plane roles at resource scope: Storage Blob Data Reader on one container, Key Vault Secrets User on one vault, never Contributor on the subscription. In Azure SQL the app is a contained user with read/write or object-level grants, not db_owner; migrations run under a separate identity in the pipeline. Humans have no standing admin rights: they elevate through Entra PIM, time-bound and audited. That maps to the Essential Eight's restrict administrative privileges strategy. The trade-off is operational friction: narrow scopes mean more role assignments and more "access denied" during development, so you codify them in Bicep or Terraform rather than clicking in the portal.
A secret is anything that grants access or proves identity: database passwords, API keys and tokens, client secrets, JWT signing keys, SAS tokens. The best secret is no secret at all: in Azure I use managed identity so the app authenticates to Azure SQL, Storage and Service Bus with Entra tokens, not stored credentials. What must remain a secret, typically a third-party API key that doesn't support Entra, goes in Azure Key Vault, read through the AddAzureKeyVault configuration provider using the app's managed identity, with Key Vault RBAC per app and a vault per environment. Locally, developers use dotnet user-secrets or their own Entra sign-in against a dev vault. Nothing goes in appsettings.json or the repo, and secret scanning blocks pushes. The trade-off: Entra and Key Vault become runtime dependencies with network hops and throttling limits, so you load at start-up, cache and reload on an interval, and automate rotation rather than doing it by hand.
How to tell it (STAR)
**S:** A pen test on our [financial services] platform showed that one leaked connection string would open every service's data. **T:** I led the remediation across [12] services. **A:** I mapped the trust zones, gave each service its own managed identity and least-privilege database role, moved every data store behind private endpoints, controlled egress and moved admin access to just-in-time PIM. **R:** Stored credentials dropped from [~40] to [3], the retest closed all [5] high findings, and our secure score rose from [48%] to [82%].
Last updated 23 Nov 2026.