Overview

1 Why design matters for security

This chapter argues that teams can achieve stronger, more sustainable security by centering their work on good design rather than treating security as a separate checklist or a set of bolt-on features. In typical projects, security work drifts down the backlog, developers feel ill-equipped to be security experts, and last-minute audits or incidents expose costly gaps. Reframing security as a cross-cutting concern—and embedding it into everyday design decisions—creates systems that better withstand real-world threats without constant, explicit “think security” effort.

The authors define design as every deliberate decision from code-level choices to architectural structure, then show why the traditional approach falls short: it competes with business priorities, assumes universal security expertise, and can only guard against known vulnerabilities. Instead, focusing on domain precision naturally reduces risk. Treat security as concerns like confidentiality, integrity, availability, and traceability (CIA-T), and model the domain with exact types and invariants. For example, representing a username as a dedicated value object with strict rules both reflects true business meaning and blocks classes of attacks (such as XSS) by construction. This design-centric mindset aligns business and security priorities, enables non-experts to write safer code, and solves many “security bugs” as ordinary correctness issues.

The chapter also illustrates practical design tactics for input handling and parsing. Favor precise domain types over generic strings and validate in the right order (length, lexical content, then syntax). In a deeper example, it tackles XML entity expansion (the Billion Laughs attack) with layered defenses: configure parsers to constrain dangerous features, run a fast lexical scan to reject inputs lacking required elements or containing entities, and apply operational limits to isolate and cap resource usage. Combined, these measures provide defense in depth. The guidance concludes by encouraging an eclectic stance: keep the design focus while complementing it with traditional practices (such as penetration testing and secure output encoding) to achieve robust, secure-by-design software.

Figure 1.1. Having only a login page doesn’t help much.
ch01 no good login
Figure 1.2. Traditionally, software security is viewed as explicit activities and concepts.
ch01 traditional approach to security small
Figure 1.3. A focus on design rather than on security avoids issues with the traditional approach to security.
ch01 shift in focus small
Figure 1.4. Exploring concepts with domain experts to gain deeper insight into the domain
ch01 meeting with domain experts small

 Summary

  • It’s better to view security as a concern to be met than to view it as a set of features to implement.
  • It’s impractical to achieve security by keeping it at the top of your mind all the time while developing. A better way is to find design practices that guide you to more secure solutions.
  • Any activity involving active decision making should be considered part of the software design process and can thus be referred to as design.
  • Design is the guiding principle for how a system is built and is applicable on all levels, from code to architecture.
  • The traditional approach to software security struggles because it relies on the developer to explicitly think about security vulnerabilities while at the same time trying to focus on implementing business functionality. It requires every developer to be a security expert and assumes that the person writing the code can think of every potential vulnerability that can occur now or in the future.
  • By shifting the focus to design, you’re able to achieve a high degree of software security without the need to constantly and explicitly think about security.
  • A strong design focus lets you create code that’s more secure compared to the traditional approach to software security.
  • Every XML parser is implicitly vulnerable to entity attacks because entities are part of the XML language.
  • Using generic types to represent specific data is a potential door opener for security weaknesses.
  • Choosing XML parser configuration is difficult without understanding the underlying parser implementation.
  • Secure by design promotes security in-depth by adding several layers of security.

FAQ

What does “security is a concern, not a feature” actually mean?It means security must cut across the whole system rather than be delivered by isolated features. A single security feature (like a lock or a login page) does not satisfy the broader concern (protecting assets or confidentiality) unless every path and weak spot is addressed.
How should we phrase security in user stories: as features or concerns?As concerns. Instead of “As a user, I want a login page…,” express the intent: “Only the owner can access their photos.” This shifts focus from implementing a page to enforcing a rule across all entry points.
What is CIA-T and how does it guide security decisions?CIA-T categorizes security concerns into confidentiality, integrity, availability, and traceability. Using CIA-T helps identify what’s at stake, prioritize protections, and define acceptance criteria aligned with the data’s risk profile.
Why does the traditional approach to software security often fall short?It relies on developers constantly thinking about security, assumes everyone is a security expert, and requires predicting unknown attack vectors. In practice, business work wins backlog priority, and gaps remain.
How does focusing on design make software more secure?Good design drives precise domain models and strong invariants. By encoding business rules in types and boundaries (for example, a Username value object), many classes of input-based vulnerabilities are prevented by construction.
How does a design-first mindset change prioritization and team dynamics?Design is a natural developer focus, so security becomes part of normal work rather than a bolt-on task. Business and security concerns share priority, cognitive load drops, and non-experts can produce secure code through safe constructs.
What is the Billion Laughs attack and why is it dangerous?It’s an XML entity expansion attack where tiny input expands exponentially during parsing, exhausting memory or CPU. The danger is the amplified resource consumption, not just the presence of entities.
What layered defenses help process XML safely?Combine three layers: configure the parser to restrict or disable dangerous features, perform a lexical scan to reject entities and ensure required elements exist before parsing, and apply operational constraints (quotas/isolation) to limit blast radius.
What is a lexical content scan and how is it used here?It’s a token-level inspection that ignores order and meaning. Use it to detect and reject XML with entities and to verify all required elements are present before parsing, following a tolerant-reader, business-first validation approach.
What does “stay eclectic” mean for secure-by-design?Keep the design focus but also use traditional security practices: output encoding, penetration testing, secure configuration, and threat awareness. The combination yields stronger, defense-in-depth security.

pro $24.99 per month

  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose one free eBook per month to keep
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime

lite $19.99 per month

  • access to all Manning books, including MEAPs!

team

5, 10 or 20 seats+ for your team - learn more


choose your plan

team

monthly
annual
$49.99
$399.99
only $33.33 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Secure by Design ebook for free
choose your plan

team

monthly
annual
$49.99
$399.99
only $33.33 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Secure by Design ebook for free