Information Security

Chapter 6
Secure Software Engineering and DevSecOps

Post Graduate Program in IT Engineering
Information Security   •   Post Graduate

Secure Software Engineering and DevSecOps

Introduction

Modern information systems are assembled from application code, cloud services, open-source libraries, application programming interfaces (APIs), infrastructure-as-code, containers, and automated deployment pipelines. A weakness in any one of these components may compromise confidentiality, integrity, availability, privacy, or safety. Secure software engineering therefore treats security as a lifecycle property rather than a final inspection activity.

DevSecOps extends DevOps by integrating security responsibilities, evidence, controls, and automated feedback into planning, development, testing, deployment, and operations. Its purpose is not simply to add more security tools to a pipeline. It is to create a socio-technical system in which developers, security specialists, operations teams, architects, product owners, and management jointly reduce software risk while preserving delivery capability.

This chapter examines threat modeling, secure coding, code review, application testing, API security, software supply-chain protection, and automated security gates. It also evaluates limitations, governance questions, and the organizational conditions required for effective implementation.

Learning Objectives

After studying this chapter, students should be able to:

1. Explain the principles of secure software engineering and DevSecOps.

2. Apply threat-modeling methods to identify assets, trust boundaries, threats, and mitigations.

3. Select appropriate secure-coding and code-review practices.

4. Distinguish SAST, DAST, IAST, SCA, fuzzing, and penetration testing.

5. Design controls for secure APIs and software supply chains.

6. Construct risk-based security gates for a CI/CD pipeline.

7. Evaluate organizational, ethical, regulatory, and operational limitations of DevSecOps.

1. Security as a Software Quality Attribute

Traditional development often places security testing near the end of a project. This creates a “bolt-on” model: vulnerabilities are discovered after architecture, interfaces, and deployment decisions have become expensive to change. Secure software engineering instead embeds security into requirements, design, implementation, verification, release, and maintenance.

Security is related to, but different from, other quality attributes. Reliability concerns whether a system performs consistently; safety concerns preventing unacceptable harm; privacy concerns appropriate handling of personal information; and security concerns resistance to unauthorized action and misuse. These properties overlap. For example, an insecure authorization decision can cause both a privacy breach and an integrity failure.

A useful lifecycle is:

  • Governance and planning: define security objectives, regulatory obligations, risk appetite, and ownership.
  • Requirements: express abuse cases, privacy requirements, authentication needs, audit requirements, and availability expectations.
  • Architecture and design: identify trust boundaries, choose security patterns, and model threats.
  • Implementation: apply secure coding standards, dependency controls, secrets management, and peer review.
  • Verification: perform automated and manual testing, including negative and adversarial tests.
  • Release and deployment: verify provenance, approvals, configuration, and rollback capability.
  • Operations: monitor, respond to vulnerabilities, rotate credentials, patch dependencies, and learn from incidents.

The central principle is that security ownership is shared, but accountability must remain explicit. A pipeline that reports vulnerabilities without assigning responsibility merely produces information, not risk reduction.

2. Threat Modeling and Security Design

Threat modeling is a structured process for identifying how a system might be attacked or misused and deciding how to reduce the resulting risk. It is most valuable before implementation, although it should be updated when architecture, dependencies, interfaces, or threats change.

2.1 Core elements

A practical threat model identifies:

  • Assets: information, credentials, transactions, intellectual property, services, and safety-critical functions.
  • Actors: legitimate users, administrators, service accounts, suppliers, attackers, and accidental insiders.
  • Entry points: web forms, APIs, queues, file uploads, administrative interfaces, and deployment systems.
  • Trust boundaries: locations where privilege, authority, or data-handling assumptions change.
  • Data flows: movement of data between users, processes, services, databases, and external providers.
  • Security objectives: confidentiality, integrity, availability, authenticity, accountability, and privacy.

Data-flow diagrams are particularly useful. A process, data store, external entity, and data-flow notation helps reveal where validation, authentication, authorization, encryption, and logging are required.

2.2 STRIDE and abuse-oriented analysis

STRIDE is a commonly used classification model:

  • Spoofing: pretending to be another identity.
  • Tampering: unauthorized modification of data or code.
  • Repudiation: denying an action when evidence is inadequate.
  • Information disclosure: exposing protected information.
  • Denial of service: reducing availability.
  • Elevation of privilege: obtaining authority beyond what is permitted.

STRIDE is a prompt for analysis, not a complete risk method. Privacy threats, supply-chain compromise, business-logic abuse, and safety consequences may require additional analysis. Abuse cases describe harmful goals, such as “a customer changes another customer’s delivery address,” and complement functional use cases.

2.3 Risk prioritization

Threats should be prioritized rather than treated as equally urgent. A qualitative model may consider likelihood, impact, exploitability, exposure, and existing controls. A simple risk-ranking expression is:

Risk priority = likelihood × impact

This is a prioritization heuristic, not a universal law or a precise probability calculation. Likelihood and impact must be defined consistently, and the result should be supplemented by expert judgment. In quantitative analysis, expected annual loss can be estimated as:

ALE = SLE × ARO

where ALE is annualized loss expectancy, SLE is single-loss expectancy in currency, and ARO is annual rate of occurrence. The model assumes that loss events and estimates are sufficiently defined; it is unsuitable when probabilities and impacts are highly uncertain or when catastrophic outcomes cannot be meaningfully averaged.

2.4 Mitigation strategies

A threat may be addressed by avoiding the risky function, reducing likelihood or impact, transferring selected consequences, accepting residual risk, or designing compensating controls. Examples include server-side authorization, parameterized queries, rate limiting, isolation, encryption, secure defaults, transaction integrity controls, and incident detection.

Threat models should produce actionable artifacts: security requirements, design decisions, test cases, residual-risk statements, and owners. A diagram without decisions is documentation, not engineering.

3. Secure Architecture and Coding

Secure architecture establishes constraints that make insecure behavior difficult. Important principles include least privilege, complete mediation, defense in depth, fail-safe defaults, economy of mechanism, separation of duties, minimizing attack surface, and secure-by-default configuration.

3.1 Input, output, and interpreter safety

All externally controlled input should be treated as untrusted. Validation should occur on the server and should use allowlists where practical. Validation checks syntax, type, length, range, and business rules. It does not replace authorization.

Output encoding must be appropriate to the interpreter or context, such as HTML, JavaScript, URL, SQL, or operating-system command contexts. SQL injection is best prevented with parameterized queries or safe query APIs, not by string concatenation or ad hoc escaping. Operating-system commands should preferably be avoided; where unavoidable, use safe process APIs, fixed argument structures, and strict validation.

3.2 Authentication and authorization

Authentication establishes identity; authorization determines permitted action. Authorization should be checked on every protected operation and enforced on the server. Object-level authorization is especially important for APIs: possessing a valid token does not imply permission to access every object identifier.

Passwords should be processed using an adaptive password-hashing function with a unique salt and an appropriately configured work factor. Secrets should not be embedded in source code, images, logs, or client-side bundles. They should be obtained from managed secret stores, scoped narrowly, rotated, and monitored.

3.3 Error handling, logging, and data protection

Errors shown to users should be useful but should not disclose stack traces, credentials, internal paths, or sensitive query details. Logs should support investigation while minimizing personal and confidential data. Important events include authentication failures, privilege changes, administrative actions, suspicious access patterns, and security-control failures. Logs require integrity protection, access control, time synchronization, retention rules, and monitoring.

Encryption in transit and at rest is valuable, but it does not correct authorization errors or compromised endpoints. Key management, algorithm selection, certificate validation, rotation, backup, and recovery are part of the security design.

4. Code Review and Secure Development Practices

Automated scanners are useful, but they cannot reliably understand every business rule, authorization relationship, or dangerous design assumption. Peer review provides contextual reasoning. A security-focused review asks:

1. What inputs are controlled by an attacker?

2. Where are identity and authorization decisions made?

3. Can one tenant access another tenant’s data?

4. Are sensitive data and secrets exposed in memory, logs, errors, or telemetry?

5. Are concurrency, replay, race-condition, and transaction failures addressed?

6. Are dependencies, cryptographic operations, and configurations used safely?

7. Do tests cover denial, malformed input, boundary conditions, and abuse cases?

Review should occur through small, understandable changes, supported by checklists and repository protections. Two-person approval may be appropriate for authentication, payment, cryptography, privilege, and deployment code. Reviewers need training and sufficient time; otherwise “security review” becomes ceremonial.

Secure coding standards should be language-specific. They should address memory safety where relevant, deserialization, path traversal, cross-site scripting, cross-site request forgery, injection, insecure randomness, race conditions, resource exhaustion, and dependency use. Static analyzers should be tuned to reduce false positives and accompanied by a documented triage process.

5. Application Security Testing

No single test detects all vulnerabilities. Effective programs combine complementary methods.

5.1 Testing methods

  • SAST: analyzes source, bytecode, or binaries without executing the application. It can identify insecure data flows early but may produce false positives and miss runtime configuration or business-logic flaws.
  • DAST: tests a running application from an external perspective. It observes runtime behavior but may not reach hidden paths or understand intended authorization.
  • IAST: instruments an application during execution and combines runtime context with code information. It may require framework support and can affect performance.
  • SCA: inventories third-party components, versions, licenses, and known vulnerabilities. It does not prove that a vulnerable component is exploitable in a particular deployment.
  • Fuzz testing: supplies malformed, unexpected, or high-volume inputs. It is valuable for parsers, protocols, file handling, and memory-safety issues, but requires suitable oracles to recognize failures.
  • Penetration testing: uses human-led adversarial analysis. It is valuable for attack chains and business logic but is periodic, scoped, and not a substitute for engineering controls.
  • Unit and integration security tests: verify authorization rules, validation, secure error behavior, tenant isolation, and abuse cases as part of normal development.

Testing should be risk-based. A public payment API deserves stronger controls than an isolated internal prototype, although “internal” is not synonymous with safe. Test results must be reproducible, assigned, remediated, and retested.

5.2 Security gates and risk-based exceptions

A security gate is a release decision rule. Examples include blocking a build when a confirmed critical vulnerability is introduced, a secret is detected, a signed artifact is missing, or required tests fail. Gates should distinguish new findings from accepted historical debt, prevent arbitrary suppression, and define expiry for exceptions.

A practical decision policy may include severity, exploitability, exposure, compensating controls, business criticality, and remediation time. Exceptions require an accountable owner, rationale, expiration date, and monitoring. A gate that blocks every theoretical warning will be bypassed; a gate that blocks nothing is decorative. The objective is timely, explainable risk reduction.

6. API Security

APIs expose data and business actions to browsers, mobile applications, partners, and internal services. Their security must be designed at the object, function, transport, and business-process levels.

Important controls include:

  • strong authentication appropriate to the client and risk;
  • short-lived, narrowly scoped tokens and secure token storage;
  • server-side object-level and function-level authorization;
  • strict schema and content-type validation;
  • limits on request size, pagination, query complexity, and upload types;
  • rate limiting and abuse detection;
  • replay protection for sensitive operations;
  • safe error responses and consistent security headers;
  • TLS with correct certificate validation;
  • audit records for high-risk actions;
  • versioning and controlled deprecation.

OAuth 2.0 is an authorization framework, not by itself an authentication protocol or a guarantee of secure implementation. OpenID Connect adds an identity layer. Token validation should include issuer, audience, signature, algorithm policy, expiry, and required scopes or claims. Developers must avoid accepting tokens merely because they are syntactically well formed.

Business-logic testing is essential. For example, a transfer endpoint may correctly authenticate a user yet permit negative amounts, repeated requests, unauthorized payees, or race-condition exploitation. Security tests must therefore examine workflows, state transitions, and invariants, not only individual endpoints.

7. Software Supply-Chain Security

Applications increasingly depend on packages, base images, build plugins, hosted actions, compilers, registries, and external services. Supply-chain attacks may involve malicious packages, compromised maintainers, dependency confusion, typosquatting, vulnerable components, poisoned build environments, or stolen signing credentials.

A mature supply-chain program includes:

  • a software bill of materials (SBOM) recording components and versions;
  • approved repositories and controlled dependency sources;
  • lockfiles and reproducible or repeatable builds where feasible;
  • dependency pinning with a managed update process;
  • vulnerability and license analysis;
  • artifact signing and verification;
  • isolated, ephemeral build workers;
  • least-privilege CI credentials;
  • protected branches and reviewed pipeline changes;
  • provenance records showing how an artifact was built;
  • rapid revocation, rollback, and emergency patching.

Pinning reduces unexpected change but may delay security fixes; automated updates improve responsiveness but require testing and review. Neither strategy is sufficient alone. An SBOM is an inventory, not proof that components are safe. Provenance improves traceability, but trustworthy provenance depends on protecting the build system and signing keys.

8. DevSecOps Pipeline Design

A DevSecOps pipeline should provide fast feedback for low-cost controls and deeper analysis at appropriate stages:

1. Plan: define security requirements, abuse cases, data classification, and risk ownership.

2. Code: enforce branch protection, secret detection, secure coding rules, and peer review.

3. Build: use isolated workers, trusted tools, dependency checks, and reproducible processes.

4. Test: run unit, integration, SAST, SCA, API, DAST, and selected fuzz tests.

5. Release: verify artifact integrity, approvals, configuration, and deployment identity.

6. Deploy: use infrastructure-as-code review, least privilege, progressive delivery, and rollback.

7. Operate: monitor telemetry, detect abuse, manage vulnerabilities, and feed lessons back into planning.

Security champions can connect product teams with specialists, but they do not replace expert security engineering. Metrics should measure outcomes rather than tool activity. Useful indicators include time to remediate exploitable vulnerabilities, percentage of critical assets with current threat models, dependency freshness, escaped vulnerability rate, mean time to revoke compromised credentials, and the proportion of releases with verified provenance. Metrics can be gamed; they should be interpreted with qualitative evidence.

Automation should be designed for clarity and recovery. A pipeline must protect its own secrets, prevent untrusted code from modifying release decisions, separate build and deployment privileges, and preserve auditable evidence. Security controls that can be disabled by the same person whose code they assess require additional approval or independent monitoring.

9. Illustrative Case: Securing a Digital Payments Platform

Background

A fictional financial-technology company operates a cloud-based payment platform. Customers use a mobile application and partner APIs to initiate transfers. The platform consists of microservices, managed databases, open-source libraries, container images, and a continuous delivery pipeline.

Problem

An internal review found that authorization checks were inconsistent across services. A transfer endpoint accepted a customer-supplied account identifier, dependency versions were not centrally inventoried, and production releases could be initiated using a broadly privileged pipeline token. Security testing occurred only before major releases, causing frequent delays.

Analysis

Threat modeling identified account takeover, broken object-level authorization, replayed transfers, dependency compromise, and pipeline credential theft as high-priority threats. The payment service was placed behind a trust boundary, but the team incorrectly assumed that authenticated service-to-service calls were automatically authorized. The impact of an unauthorized transfer was high, while the likelihood of exploitation was increased by public API exposure and weak transaction controls.

Approach

The company introduced a common authorization service and required each transaction to evaluate the authenticated subject, permitted account relationship, transaction scope, and current state. Transfer requests received unique idempotency keys and were rejected when reused inconsistently. Rate limits and anomaly detection were added.

The organization created an SBOM for every release, restricted dependencies to approved registries, and required signed container images. CI workers became ephemeral, deployment credentials were short-lived and environment-specific, and production deployment required an independent approval. SAST, SCA, secret detection, API contract tests, and authorization integration tests ran on every change. DAST and targeted penetration tests ran for high-risk services. Findings were prioritized by exploitability and business impact, with documented exceptions.

Outcome

The platform reduced unauthorized-access findings in subsequent testing and improved its ability to identify affected releases when a library vulnerability was disclosed. Pipeline duration increased modestly, but most fast checks completed during pull requests. The main improvement was not a particular scanner; it was the combination of threat modeling, consistent authorization design, supply-chain visibility, and accountable release decisions.

Learning points

First, authentication does not establish object-level authorization. Second, dependency inventories are operational controls, not merely compliance documents. Third, security gates must be risk-based and integrated early. Finally, pipeline security is part of application security because compromise of the build process can compromise every deployed application.

10. Governance, Ethics, and Limitations

DevSecOps may expose sensitive source code, logs, developer behavior, and vulnerability information. Organizations should limit collection, define access rights, protect test data, and avoid using production personal data unnecessarily. Security monitoring must be proportionate and transparent; employee surveillance should not be disguised as engineering measurement.

Regulatory obligations may include breach notification, privacy protection, secure development expectations, software-product security requirements, payment controls, and contractual assurance. Compliance frameworks help establish evidence but do not guarantee security. Legal review is important when penetration testing, vulnerability disclosure, monitoring, or cross-border data transfer is involved.

Important limitations include false positives, false negatives, incomplete threat models, tool blind spots, outdated vulnerability databases, insecure test environments, alert fatigue, and dependence on scarce expertise. Artificial intelligence can assist code explanation, test generation, pattern detection, and vulnerability triage, but generated code may contain insecure assumptions, hallucinated APIs, licensing concerns, or leaked confidential context. AI output requires human review, controlled data handling, provenance, and testing against security requirements.

The most serious organizational failure is treating security as the responsibility of a specialized team while giving delivery teams no authority, training, or time to address findings. Conversely, assigning security entirely to developers without specialist support can miss architectural and adversarial concerns. Effective practice combines shared ownership with independent challenge, clear risk acceptance, and continuous learning.

Contemporary Developments and Best Practices

Current practice is moving toward software supply-chain levels of assurance, signed provenance, memory-safe languages for suitable components, policy-as-code, confidential computing for selected workloads, continuous authorization analysis, and platform engineering that provides secure reusable paths. Zero-trust principles increasingly influence service identity and authorization, but zero trust is an architectural approach rather than a product purchase.

Best practices include:

  • threat-model high-risk changes before coding;
  • make secure defaults part of frameworks and templates;
  • test authorization and business logic, not only input syntax;
  • maintain an accurate SBOM and dependency ownership;
  • protect CI/CD as production infrastructure;
  • use automated gates with explicit, expiring exceptions;
  • combine automated analysis with skilled human review;
  • minimize and protect sensitive test data;
  • rehearse vulnerability response, credential revocation, and rollback;
  • measure remediation and resilience outcomes rather than scanner counts.

Chapter Summary

Secure software engineering integrates security into requirements, architecture, coding, testing, release, and operations. Threat modeling identifies assets, actors, trust boundaries, attack paths, and mitigations; STRIDE provides a useful but incomplete classification aid. Secure coding depends on validation, context-appropriate encoding, parameterized interfaces, robust authentication and authorization, protected secrets, safe error handling, and defensible logging.

Code review and testing are complementary. SAST, DAST, IAST, SCA, fuzzing, penetration testing, and security-focused unit and integration tests address different visibility and coverage problems. APIs require object-level authorization, strong token validation, rate limiting, replay resistance, schema controls, and business-logic testing. Supply-chain security requires inventories, trusted sources, controlled builds, provenance, signing, least privilege, and response capability.

DevSecOps succeeds when automated security gates provide fast, risk-based feedback and when people remain accountable for decisions. Governance, privacy, ethics, regulatory obligations, human expertise, and operational recovery are as important as tools. The goal is not perfect software, but demonstrably reduced risk, resilient delivery, and the capacity to detect, correct, and learn from failure.

Key Terms

Threat modeling: Structured identification and treatment of threats during system development.

Trust boundary: A location where authority, privilege, or trust assumptions change.

STRIDE: A threat classification model covering spoofing, tampering, repudiation, information disclosure, denial of service, and elevation of privilege.

Abuse case: A description of harmful or unauthorized use of a system.

Secure by default: A design condition in which the safest practical configuration is the initial configuration.

Least privilege: Granting only the permissions required for an actor or process.

SAST: Static analysis of code or compiled representations without executing the application.

DAST: Security testing of a running application from an external perspective.

IAST: Runtime analysis using instrumentation and application context.

SCA: Software composition analysis of third-party components, vulnerabilities, and licenses.

Fuzzing: Automated testing using unexpected, malformed, or high-volume inputs.

API: A defined interface through which software components communicate.

Object-level authorization: Checking whether a subject may access a particular data object.

SBOM: A machine-readable inventory of software components in an artifact.

Software provenance: Evidence describing an artifact’s origin and build process.

Security gate: A release rule that permits or blocks progression according to security conditions.

DevSecOps: Integration of security practices and accountability throughout DevOps.

Idempotency: A property whereby repeating an operation does not create an unintended additional effect.

Residual risk: Risk remaining after controls are applied.

Policy as code: Machine-enforced representation of organizational or security policy.

Review Questions

Short Answer Questions

1. What is the purpose of threat modeling?

2. Distinguish authentication from authorization.

3. What does SCA examine?

4. Why is an SBOM useful?

5. Define a security gate.

Long Answer Questions

1. Explain how secure software engineering differs from a bolt-on security model.

2. Compare SAST, DAST, IAST, fuzzing, and penetration testing, including the limitations of each.

3. Discuss the security principles required for a public payment API.

4. Explain how a CI/CD pipeline can be protected against supply-chain compromise.

5. Evaluate the organizational and governance conditions needed for effective DevSecOps.

Analytical / Application Questions

1. Design a threat model for a multi-tenant document-sharing API. Identify assets, trust boundaries, threats, mitigations, and residual risks.

2. A build contains one critical dependency vulnerability, two medium findings, and a missing signature. Propose a risk-based release decision and justify any exception process.

3. An authenticated user can alter another user’s order by changing an order identifier in a request. Analyze the failure and propose code, testing, API, monitoring, and governance controls.

Multiple Choice Questions with Answers

Question 1

Which activity is most appropriate during threat modeling?

A. Identifying assets, trust boundaries, and attack paths

B. Replacing all manual testing with a scanner

C. Encrypting every field regardless of its use

D. Measuring developer productivity only by deployment count

Correct Answer: A. Identifying assets, trust boundaries, and attack paths

Question 2

Which control is the strongest general defense against SQL injection?

A. Longer error messages

B. Parameterized queries

C. Client-side input validation alone

D. Base64 encoding of user input

Correct Answer: B. Parameterized queries

Question 3

What does DAST primarily analyze?

A. A running application from an external perspective

B. Only the software license inventory

C. The organization’s hiring process

D. Source code without execution

Correct Answer: A. A running application from an external perspective

Question 4

Which statement about OAuth 2.0 is correct?

A. It automatically guarantees secure authorization implementation

B. It is an authorization framework and requires correct implementation

C. It replaces TLS for API communication

D. It makes object-level authorization unnecessary

Correct Answer: B. It is an authorization framework and requires correct implementation

Question 5

What is the main purpose of an SBOM?

A. To list software components and their versions

B. To encrypt database backups

C. To replace penetration testing

D. To authenticate end users

Correct Answer: A. To list software components and their versions

Question 6

Which practice best reduces CI/CD credential exposure?

A. Using one permanent administrator token everywhere

B. Embedding credentials in source code

C. Using short-lived, least-privileged credentials

D. Printing credentials in build logs

Correct Answer: C. Using short-lived, least-privileged credentials

Question 7

A valid access token is presented with another customer’s object identifier. Which control is specifically required?

A. Object-level authorization

B. Source-code minification

C. Dependency pinning only

D. Longer session duration

Correct Answer: A. Object-level authorization

Question 8

Why are security gates made risk-based?

A. To ensure every warning blocks every release

B. To balance exploitability, impact, exposure, and delivery consequences

C. To eliminate the need for security ownership

D. To guarantee that no vulnerability exists

Correct Answer: B. To balance exploitability, impact, exposure, and delivery consequences

Question 9

Which statement best describes a limitation of SCA?

A. It cannot inventory any dependencies

B. It proves that every listed vulnerability is exploitable

C. It may identify a vulnerable component without proving exploitability in context

D. It only tests user-interface color schemes

Correct Answer: C. It may identify a vulnerable component without proving exploitability in context

Question 10

What is an important property of an idempotency key in a payment operation?

A. It permits an identical request to create unlimited transfers

B. It helps prevent unintended repeated effects from retries

C. It replaces authentication and authorization

D. It disables audit logging

Correct Answer: B. It helps prevent unintended repeated effects from retries

Information Security
Chapter 6 of 15