Be Software Architecture Wise
Be Wise Apps

Leer en español · Lire en français · Auf Deutsch lesen

Section 8.1 of 8.8 · Intermediate · 20 min read

Security principles for architects

Video lesson

5 min · narrated, with captions
Listen only (audio)
Read the transcript

Most serious breaches don't come from clever attacks on cryptography. They come from design decisions about trust that nobody made explicitly. This lesson gives you the principles for making them deliberately.

Think about how a bank branch is protected. There's a locked front door, and staff only have keys to the rooms they need. The vault needs two people to open it. There are cameras, and an alarm that calls the police. And it was all designed in from the start. Software security works the same way: architects decide early where the locked doors are, who gets which keys, and what happens when one lock fails.

The starting vocabulary is the CIA triad. On the food delivery platform, confidentiality covers customers' addresses, couriers' live locations and restaurants' payout bank details. Integrity covers prices, refunds and payouts. An attacker who changes the price of a meal to zero hasn't read anything secret, but has done real harm. Availability matters most during the evening peak. Name the properties that matter for each asset, because they conflict. Failing closed protects data but costs availability. A public menu can fail open to a cached copy, while a refund must fail closed.

In 1975, Jerome Saltzer and Michael Schroeder published eight design principles that are still the foundation of secure design, because they're about structure, not technology. Here are five. Economy of mechanism: keep security small and simple. One shared, well reviewed authorisation library, not checks written differently in every service. Fail safe defaults: when in doubt, or when something fails, the answer is no. An unreachable policy engine means deny. Complete mediation: check every access, every time. The ordering service checks that this customer owns this order on every request. Separation of privilege: require two independent conditions, like two keys. A large refund needs a second approver. And least privilege: only the privileges needed, for as long as needed. The menu service's database account can't read the payments data.

Defence in depth layers independent controls, so that one failure doesn't expose the asset. Here are the layers on the platform's order path. The customer app is outside the trust boundary. It talks to the platform only over HTTPS, and nothing on the device is trusted. Inside, the edge absorbs floods of traffic and applies rate limits. The API gateway checks each token's signature, expiry, audience and scope. The orders service checks that this customer may see this order. So even if the gateway has a bug, one customer can't read another's order. The database uses a least privilege account and is encrypted at rest, with backups under separate keys. Logging and alerting across every layer should catch what gets through. The key word is independent: two layers that fail for the same reason are one layer drawn twice.

Secure by default means weakening protection takes a deliberate act. If the shared service template already includes token validation and security logging, every new service starts secure. Some call this a paved road. The attack surface is everything an attacker can reach. Removing an unused endpoint reduces risk more cheaply than any added control. A trust boundary is where trust changes, and that's where authentication, authorisation and input validation belong. Anything on the customer's device is under the attacker's control, so hiding a button is not authorisation.

Let's apply the principles. A first design for support refunds lets any agent refund any order, for any amount. With least privilege, agents may refund only orders in their own market, and the tool can never read card data. With fail safe defaults, if a check fails or times out, the refund is refused. No fallback skips the checks. With complete mediation, Payments checks every refund against the original charge itself, instead of trusting the tool. With separation of privilege, refunds above a hundred pounds, or a third refund to one customer in a week, need a supervisor's approval. And every refund goes into an audit log that can only be added to. Now a dishonest agent, or someone who has taken over an agent's account, is limited to small, logged refunds in one market.

Architects own decisions that cross teams and are expensive to change: trust boundaries, the identity and authorisation model, and which data is encrypted with which keys. Teams own the correct application: authorisation at every endpoint and object, input validation, and current dependencies. And the OWASP Top 10, the Open Worldwide Application Security Project's list of web application risks, is an awareness list, not a standard. It helps you check that nothing big is missing.

The full section has all eight principles, the OWASP Top 10 table and the secure development lifecycle. Next, in Section eight point two, you'll learn how to threat model a design. See you there.

What you need to know

Security as a quality of the structure

Chapter 2 introduced security as a quality attribute: the system's ability to protect data and functions from unauthorised use while serving those who are authorised, expressed through testable security scenarios that name an attacker, an attack, a target and a measurable response. This chapter takes the next step and asks how architecture produces that quality. The answer is that most security properties are decided by structure: which components exist, which of them trust which others, where data is stored and copied, and through which few points every request must pass.

Consider how real breaches happen. An attacker changes the order number in a URL and sees another customer's address, because the service checked that the user was logged in but not that the order was theirs. A storage bucket holding database exports is readable from the internet because a default was changed years ago. An internal reporting service accepts any request from inside the network, so one compromised laptop reaches every customer record. None of these needs clever cryptography to exploit; each is a design decision about trust that nobody made explicitly. Security by design means making those decisions deliberately, early and in writing, and then making them hard to violate by accident.

Security architecture therefore sits alongside the other cross-cutting concerns of arc42's section 8: an identity model, an authorisation model, a data protection concept and a logging concept that every team follows. The rest of this section sets out the vocabulary and principles on which the remaining sections of the chapter build.

Confidentiality, integrity and availability in a real system

The CIA triad is the starting point. On the food-delivery platform, confidentiality covers customers' names, addresses, phone numbers and order histories, couriers' live locations and identity documents, restaurants' payout bank details and the platform's own secrets. Integrity covers prices, basket totals, refunds, courier payouts and the menu a customer sees: an attacker who can change the price of a meal to zero, or redirect a restaurant's payouts to their own bank account, has not read anything secret but has done serious harm. Availability matters most during the evening peak, when a denial-of-service attack or a ransomware infection costs revenue by the minute.

ISO/IEC 25010:2023 adds authenticity (identities can be proved), accountability (actions can be traced to whoever performed them), non-repudiation (actions can be proved to have happened) and resistance (the product keeps working as intended under attack). Architects should name which properties matter for each asset, because they pull in different directions. Failing closed protects confidentiality and integrity but costs availability: if the authorisation service is down, a fail-closed ordering service refuses orders. Failing open preserves availability and gambles with everything else. The right choice differs per operation: viewing a public menu can fail open to a cached copy, while issuing a refund must fail closed.

Saltzer and Schroeder's design principles

In 1975 Jerome Saltzer and Michael Schroeder, drawing on their experience with the Multics operating system at MIT, published eight design principles for protection mechanisms in The Protection of Information in Computer Systems. Half a century later they remain the most cited foundation of secure design, because they are about structure rather than technology. The table restates each one and gives a modern example from the food-delivery platform.

The eight design principles with modern examples

PrincipleWhat it asksModern example
Economy of mechanismKeep the security design as small and simple as possible, so that it can be inspected and tested thoroughly.One shared, well-reviewed authorisation library or policy engine instead of permission checks hand-written differently in every service.
Fail-safe defaultsBase access on explicit permission; when in doubt, or when something fails, the answer is no.A new API endpoint is denied until a policy grants access to it; an unreachable policy engine means deny, not allow.
Complete mediationCheck every access to every object every time, not just the first time.The ordering service checks ownership on every GET /orders/{id} rather than trusting any ID from a logged-in user; cached decisions expire quickly.
Open designSecurity must not depend on the design being secret; only keys and passwords should be secret.Published algorithms (AES, TLS 1.3) and standard protocols (OAuth 2.0) that stay secure even if attackers read the source code.
Separation of privilegeWhere possible, require two independent conditions (two keys) before granting access.Refunds above a threshold need a second approver; a production release needs both a code review and a passing pipeline; multi-factor login.
Least privilegeGive every program and user only the privileges needed for the job, for as long as needed.The menu service's database account cannot read the payments schema; a build job's cloud role can push images but not delete clusters.
Least common mechanismMinimise mechanisms shared between users, because each shared mechanism is a path for information to leak.Separate caches, queues or connection pools per tenant or trust level; a shared cache keyed carelessly serves one user's data to another.
Psychological acceptabilityProtection must be easy to use correctly, or people will work around it.Passkeys instead of complex password rules; secure defaults in the platform; warnings that are rare and therefore read.

Defence in depth

Defence in depth means layering several independent controls, so that the failure or bypass of one does not expose the asset. The idea comes from military fortification and is standard practice in safety engineering as well as security. Its value depends entirely on the word independent: two layers that fail for the same reason, such as two services that both trust a forged header, are one layer drawn twice.

The diagram shows the layers on the food-delivery platform's order path. If the gateway's token validation has a bug, the ordering service's object-level check still prevents one customer reading another's order. If an attacker steals the database's disk snapshots, encryption at rest with keys held elsewhere protects them. If all of that fails, monitoring should notice the unusual pattern of requests and someone should respond. Defence in depth is also the honest answer to the question "what if this control fails?", which every threat model asks.

Defence in depth on the food-delivery order path: a request from the customer app crosses a trust boundary and passes the edge, the API gateway, the ordering service and the orders database, each applying its own independent controls, with monitoring across all layersCustomer appHTTPS only (TLS 1.2 or 1.3); passkey, or password plus MFAnothing on the device is trusted by the platformEdge: CDN and WAFabsorbs volumetric DDoS; rate limits per account and IPfirewall rules block known attack patternsAPI gatewayvalidates token signature, expiry, audience and scoperejects requests that do not match the API schemaOrders servicechecks this customer may see this order (object level)validates input; uses parameterised queriesOrders databaseservice-specific account with least privilegeencrypted at rest; backups encrypted with separate keysTrust boundarySecurity logging, detection and alerting across every layer
Each layer applies its own controls; a single bypassed control does not expose the data.

Secure by default and secure by design

A product is secure by default when its out-of-the-box configuration is the safe one, so that weakening protection requires a deliberate act. Many large breaches came from insecure defaults left in place: databases listening on the internet without a password, administrator consoles with factory credentials, storage buckets that could be made public with one setting. Vendors have moved: since April 2023, for example, new Amazon S3 buckets are created with Block Public Access switched on and access control lists disabled. In 2023 the US Cybersecurity and Infrastructure Security Agency (CISA) and partner agencies from several countries published joint guidance urging manufacturers to make products secure by design and by default, and in 2024 CISA launched a voluntary Secure by Design pledge for software makers.

For architects, secure by default applies to the platform as much as to products. If the shared service template already includes token validation, structured security logging, a non-root container user and a least-privilege database account, every new service starts secure and teams have to opt out explicitly, which is visible in review. This is what some organisations call a paved road: the easiest path is also the secure one.

Closely related is how a system behaves when something goes wrong. The OWASP Top 10:2025 added a category for mishandling exceptional conditions, which includes failing open: an error in a permission check that is caught and ignored, a timeout that defaults to "allowed", a parsing failure that skips validation. Fail-safe defaults, applied in code, mean that every exception path in a security decision ends in denial.

Attack surface and trust boundaries

The attack surface is everything an attacker can reach and influence: public endpoints and their parameters, open ports, file uploads, message queues that accept input from partners, webhooks, administrator consoles, mobile apps that can be decompiled, and the third-party code and people the system trusts. Michael Howard at Microsoft popularised the idea of measuring it in the early 2000s; the practical rule is to make it as small as possible and to know exactly what is on it. Removing an unused endpoint, closing an administrator port to the internet, or turning off a feature nobody uses reduces risk more cheaply than any added control. Every architectural style choice in Chapter 6 has a security cost here: each new network-reachable service adds endpoints, credentials and traffic to protect.

A trust boundary is where data or control passes between parts with different levels of trust or privilege. The most obvious is between the internet and the platform, but there are many more: between the customer app and the API, between a restaurant's tablet and the menu service, between services owned by different teams, between the platform and a payment provider, between application code and the database, and between ordinary users and administrators. Trust boundaries matter because they are where checks belong: authentication, authorisation, input validation and output encoding happen when data crosses a boundary, never on the assumption that the other side has already done it. Drawing the trust boundaries on a data-flow diagram is the first step of threat modelling.

The OWASP Top 10 as an awareness list

The OWASP Top 10 is the Open Worldwide Application Security Project's ranked list of the most critical web application security risks, compiled from contributed vulnerability data and a community survey. The current edition, the OWASP Top 10:2025, is the eighth. Compared with the 2021 edition, broken access control stays first and now includes server-side request forgery, security misconfiguration rises to second, the old vulnerable and outdated components category widens into software supply chain failures, and a new category covers mishandling of exceptional conditions.

OWASP Top 10:2025 and the architectural levers

CategoryWhat goes wrongArchitectural lever
A01 Broken Access ControlUsers act outside their permissions, such as reading another customer's order by changing an ID; includes server-side request forgery.One authorisation model, deny by default, object-level checks in every service, restricted outbound network access.
A02 Security MisconfigurationInsecure defaults, open storage, verbose error pages, unnecessary features left on.Infrastructure as code, hardened templates, automated policy checks in the pipeline.
A03 Software Supply Chain FailuresVulnerable or compromised dependencies, build tools and distribution channels.Dependency inventory (SBOM), pinning, signed provenance; see supply-chain security.
A04 Cryptographic FailuresSensitive data unencrypted, weak algorithms, poor key handling.Data classification, TLS everywhere, a KMS and envelope encryption.
A05 InjectionUntrusted data interpreted as code: SQL, operating-system commands, cross-site scripting.Parameterised queries, context-aware output encoding, safe framework APIs.
A06 Insecure DesignMissing or ineffective controls that no amount of correct coding can fix.Threat modelling, secure design patterns, abuse cases alongside user stories.
A07 Authentication FailuresCredential stuffing, weak recovery flows, session handling flaws.A central identity provider, MFA or passkeys, rate limits on login.
A08 Software or Data Integrity FailuresTrusting code, updates or data without verifying integrity, such as unsigned updates or unsafe deserialisation.Signature verification, integrity checks on data crossing boundaries.
A09 Security Logging and Alerting FailuresAttacks are not recorded, or recorded but never noticed or acted on.A security logging standard, alerting, incident runbooks.
A10 Mishandling of Exceptional ConditionsErrors handled inconsistently, systems failing open, error messages leaking details.Fail closed, central error handling, resource limits.

Treat the list as what OWASP says it is: an awareness document, not a standard. It is useful for training, for checking that a threat model has not missed a whole class of problem and for talking to stakeholders. It is not a complete set of requirements, and "we are OWASP Top 10 compliant" means little. For verifiable requirements, OWASP's Application Security Verification Standard (ASVS) lists testable controls at three levels of rigour, and the separate OWASP API Security Top 10 covers risks specific to APIs, such as broken object-level authorisation.

A secure development lifecycle and shifting left

A secure development lifecycle builds security activities into every stage of delivery rather than relying on a test just before release. Microsoft made its Security Development Lifecycle mandatory in 2004, after Bill Gates's 2002 Trustworthy Computing memo, and the idea spread across the industry. The current reference is NIST's Secure Software Development Framework (SSDF), SP 800-218, version 1.1 of which was published in February 2022; NIST released a draft revision (version 1.2) for comment in December 2025, which had not been finalised at the time of writing. The SSDF groups practices into four families: prepare the organisation (roles, training, toolchains, security requirements), protect the software (protect code and build integrity, keep provenance), produce well-secured software (design to meet security requirements, threat-model, review and test, configure securely by default) and respond to vulnerabilities (identify, fix, and analyse root causes so the same class does not recur). It describes outcomes rather than prescribing tools, which makes it a good checklist for an architect assessing a delivery process.

To shift left is to move security work earlier: security requirements and abuse cases with the user stories, threat modelling in design, static analysis and secret scanning on every commit, dependency checks in the pipeline. The economic argument is familiar from Chapter 1: a missing authorisation check found in a design review costs an hour; the same flaw found after a breach costs a notification to regulators. Practitioners disagree about how far to push it. Advocates say developers who understand security write fewer vulnerabilities. Critics point out that simply moving security tools in front of developers floods them with low-quality findings and turns security into everyone's part-time job and nobody's expertise; they argue for secure defaults built into the platform (the paved road), so that the secure path needs no extra effort, and for security specialists embedded where the risk is highest. Most mature organisations do both, and also keep testing and monitoring in production, which is why some now speak of shifting security everywhere.

What architects own and what developers own

Security work is shared, and confusion about who owns what is itself a vulnerability. The architect owns decisions that cross team boundaries and are expensive to change; teams own their correct application. A common pattern is a small central security team that sets standards and runs the platform's security services, security champions in each product team who lead threat modelling and reviews, and architects who make sure the structural decisions are made and recorded.

Dividing security responsibilities

ConcernArchitect (and security architecture)Development teams
Trust boundaries and data flowsDefine them, document them, lead threat models for significant changes.Keep the code consistent with them; raise changes that move a boundary.
Identity and accessChoose the identity provider, token model, authorisation model and where policy is decided.Enforce authorisation at every endpoint and object; test it.
Data protectionClassify data; decide what is encrypted where, with which keys; choose the KMS and secrets vault.Use the approved libraries; never log secrets or personal data unnecessarily.
Input and output handlingSet validation and encoding strategy at boundaries; provide shared libraries.Validate, encode and parameterise in every handler.
Dependencies and buildSet pipeline controls, approved sources and SBOM policy.Keep dependencies current; act on alerts within agreed times.
Detection and responseDefine security logging, audit events and incident roles.Emit the agreed events; fix vulnerabilities within the agreed service levels.

Worked example

Worked example: applying the principles to a support refund feature

Support agents on the food-delivery platform need to refund customers for failed deliveries from the back-office tool. A first design lets any agent call the Payments service's refund endpoint with any order number and amount. The table shows how the principles reshape it.

Least privilegeAgents get a refund:create permission only for orders in their own market; the back-office tool's service identity may call the refund API but never read card data.
Fail-safe defaultsIf the policy check or the order lookup fails or times out, the refund is refused with a "try again" message; there is no fallback path that skips checks.
Complete mediationPayments itself re-checks every refund against the original charge (the refund cannot exceed the captured amount minus earlier refunds), rather than trusting the back-office tool.
Separation of privilegeRefunds above £100, or a third refund to the same customer in a week, need a supervisor's approval in the same tool.
Economy of mechanismUses the platform's existing policy engine and audit library; no special-case permission code is written for refunds.
Psychological acceptabilityApproval is requested with one click; reasons are chosen from a short list, so the control does not slow honest agents down.
AccountabilityEvery refund is written to an append-only audit log with agent, approver, order, amount and reason.
Defence in depthThe back-office tool is reachable only through single sign-on with phishing-resistant MFA from managed devices.

Both a dishonest agent and an attacker who has taken over an agent's account are now limited to small, logged refunds in one market.

The cost is a short delay for large refunds and some extra design work, which is far cheaper than retrofitting these controls after fraud is discovered.

Check your understanding

Why does defence in depth depend on the layers being independent?

If two layers fail for the same reason, such as both trusting the same forged header, one attack defeats both, so they give no more protection than a single layer.

Which Saltzer and Schroeder principle is violated when a service checks that a user is logged in but not that the requested order belongs to them?

Complete mediation: every access to every object must be checked for authority, not just the fact that the user has authenticated.

A team says its application is "OWASP Top 10 compliant". What is wrong with that claim?

The Top 10 is an awareness list of risk categories, not a standard with testable requirements; verification needs something like OWASP ASVS and a threat model of the actual system.

Give one example of failing open and explain why it is dangerous.

A permission check that treats a timeout from the policy engine as "allowed". An attacker who can slow or break the policy engine then gets access to everything it protects.

Next · 8.2Threat modellingShostack's four questions, data-flow diagrams with trust boundaries, STRIDE and attack trees, rating risk without false precision, and a worked threat model of a food-delivery checkout.Continue →

Sources and further reading

Have a question about this section? ArchitectBot, the course’s AI study assistant, answers from the course first.

Ask: “Which security decisions in our food-delivery design should an architect make centrally, and which should each team make for itself?”