Web Application Security and Secure Coding

Chapter 4
Secure Software Development Life Cycle

Post Graduate Diploma in Full Stack Development
Web Application Security and Secure Coding   •   Post Graduate

4. Secure Software Development Life Cycle

Introduction and Context

Security is no longer a final testing activity performed immediately before deployment. Modern web applications are assembled from cloud services, open-source packages, APIs, containers, databases, identity providers and automated delivery pipelines. A weakness introduced during requirements analysis may therefore become expensive to correct after deployment and may expose customers, employees, business partners and the organisation itself to serious harm.

The Secure Software Development Life Cycle (SSDLC) integrates security into the ordinary life of a product: discovery, planning, design, implementation, testing, release, operation and retirement. Its purpose is not to make development slow or to transfer responsibility to a separate security department. Rather, it distributes security decisions across the teams that are best placed to make them. Product owners clarify security and privacy expectations; architects design protective controls; developers implement them; reviewers challenge assumptions; testers seek exploitable weaknesses; operations teams monitor and respond; and managers ensure that evidence supports release decisions.

For postgraduate full-stack developers, SSDLC is especially important because application security is simultaneously technical, organisational and strategic. A secure authentication mechanism may fail if requirements permit excessive data collection. A well-designed API may remain vulnerable if dependency updates are unmanaged. A successful penetration test may provide little assurance if it examined only a staging environment that differs from production. Security must therefore be treated as a system of decisions, controls and evidence rather than as a single tool or phase.

Learning Objectives

After studying this chapter, students should be able to:

  • explain the purpose, principles and business value of a Secure Software Development Life Cycle;
  • integrate security and privacy requirements into Agile product planning;
  • apply threat modelling and secure architecture techniques to web applications;
  • distinguish preventive, detective and corrective security controls;
  • design secure coding, peer-review, testing and deployment practices;
  • establish security gates and determine when risk-based exceptions are justified;
  • identify assurance evidence suitable for technical, managerial and regulatory review;
  • evaluate the organisational, ethical and governance challenges of SSDLC adoption.

Security as a Product-Lifecycle Responsibility

A conventional software life cycle appears linear: requirements precede design, design precedes coding, and testing precedes release. Agile and DevOps make the cycle iterative. Requirements are refined continuously, software is integrated frequently and operational feedback informs subsequent development. SSDLC must work within this reality. It is better understood as a set of security activities that recur at different levels of granularity: a product, release, feature, user story and code change may each require proportionate security consideration.

A useful principle is that security work should be performed as early as practical, but not only early. Early analysis prevents unsuitable designs; continuous verification detects implementation and configuration errors; production monitoring reveals threats and failures that could not have been predicted. This is sometimes expressed as “shift left,” but a mature programme also shifts security right into operations and incident response.

Security objectives normally include confidentiality, integrity, availability, authenticity, accountability and resilience. Privacy adds requirements concerning lawful processing, purpose limitation, data minimisation, transparency, retention and individual rights. These objectives can conflict. Stronger authentication may increase friction; extensive logging may improve accountability while creating privacy risk; rapid deployment may improve availability of features while increasing change-related risk. SSDLC provides a disciplined way to make such trade-offs explicit.

Important Terminology

A security requirement is a verifiable statement about protection, such as “administrators shall use phishing-resistant multi-factor authentication.” A security control is a measure that reduces risk; encryption, access control and monitoring are examples. An assurance activity provides confidence that controls operate as intended. A security defect is a weakness in code, design, configuration or process that could violate a security requirement. Risk is commonly evaluated through the relationship between the likelihood of an adverse event and its impact, although precise quantitative estimates may not always be possible.

A security champion is a member of a delivery team who helps connect that team with security specialists. A threat is a potential cause of harm, while a vulnerability is a weakness that may be exploited. An abuse case describes an undesired use of a system, such as attempting to reset another user’s password. A security gate is a defined release condition or review point. Evidence is an artefact demonstrating that a decision, control or test occurred—for example, a threat model, review record, scan report or approval.

A Risk-Based SSDLC Framework

A practical SSDLC can be organised into seven connected activities: establish requirements, model threats, design protections, implement securely, verify continuously, release with evidence and operate responsively. These activities are not rigid sequential stages; they form feedback loops.

Establishing Security and Privacy Requirements

Requirements should express business and user needs in testable terms. “The application must be secure” is not actionable. Better requirements specify actors, assets, control behaviour and acceptance criteria: “A user may view invoices only when the invoice belongs to that user’s authorised organisation,” or “Personal data collected for account verification shall be deleted after the approved retention period.”

Requirements are discovered through stakeholder interviews, legal and regulatory analysis, data-flow mapping, previous incidents, threat intelligence and architectural constraints. They should identify protected assets, trust boundaries, privileged operations, availability expectations, recovery objectives and relevant privacy obligations. Product backlogs can represent security as features, constraints, technical debt, defects and acceptance criteria. Security stories should be prioritised according to risk rather than postponed indefinitely as non-functional work.

Privacy by design begins at this stage. Teams should ask whether each data item is necessary, who needs access, where it is stored, how long it is retained, whether it is transferred internationally and how a data subject can exercise applicable rights. Privacy is not achieved merely by adding a consent banner. It requires choices about data architecture, defaults, interfaces and organisational processes.

Threat Modelling and Security Architecture

Threat modelling converts vague concern into structured analysis. The team identifies assets, users, entry points, trust boundaries, data flows and possible abuse paths. Data-flow diagrams are particularly useful for web applications because they reveal movement between browsers, front-end services, APIs, queues, databases, third-party providers and administrative tools.

A common analytical approach considers spoofing, tampering, repudiation, information disclosure, denial of service and elevation of privilege. The value of such a mnemonic lies not in memorisation but in prompting questions: Can an attacker impersonate a user? Can data be altered without detection? Can actions be traced? Can sensitive information leak? Can the service be exhausted? Can an ordinary account reach administrative capability?

Threats should be recorded with assumptions, affected assets, likelihood, impact, existing controls, proposed treatment and residual risk. Treatment may involve avoiding a feature, reducing likelihood, reducing impact, transferring some responsibility to a provider or accepting the risk through an authorised decision. Threat models must be revisited when architecture, dependencies, data use or attack conditions change.

Secure architecture applies defence in depth and least privilege. It separates public and private components, restricts service-to-service communication, validates authorization at the server, protects secrets through dedicated management systems and limits the consequences of compromise. A secure design does not assume that an internal network is trustworthy. It defines explicit identities, authenticated calls, narrowly scoped permissions and auditable administrative actions.

Secure Implementation and Coding Standards

Coding standards translate architecture into repeatable developer behaviour. They should address input validation, output encoding, parameterised database access, safe error handling, secure session management, cryptographic API usage, secret handling, dependency management and authorization checks. Standards are most effective when accompanied by examples, reusable libraries and automated checks.

Validation should be appropriate to the context. Allow-list validation is usually preferable where the expected format is known, but validation does not replace output encoding or server-side authorization. A request may contain syntactically valid input while still attempting to access another customer’s record. Authorization must be checked against the authenticated identity, requested resource and permitted action on the server side.

Cryptography should use established, maintained libraries and sound key-management practices rather than developer-created algorithms. Passwords require slow, adaptive password-hashing functions and should never be stored in reversible form. Secrets must not be committed to source repositories or exposed in logs. Error messages should assist legitimate diagnosis without disclosing stack traces, credentials, internal addresses or sensitive records.

Third-party components create both productivity and supply-chain risk. Teams need an inventory of direct and transitive dependencies, version and license information, vulnerability monitoring, update procedures and a plan for unsupported components. Automated dependency scanning is useful but cannot determine whether a vulnerable function is reachable or whether an update is compatible. Human risk assessment remains necessary.

Peer Review and Continuous Verification

Peer review is a social and technical control. A reviewer examines whether the change meets requirements, respects architectural boundaries, handles failure safely and introduces unintended access or data exposure. Review quality improves when pull requests are small, security-sensitive files receive specialist attention and review checklists focus on risk rather than formatting alone.

Security testing should be layered. Static application security testing analyses source or compiled code; software composition analysis examines dependencies; secret scanning searches for exposed credentials; dynamic testing examines a running application; and penetration testing uses human expertise to explore realistic attack paths. Infrastructure-as-code and container images can also be scanned for insecure configurations. None of these techniques is complete. False positives consume attention, while automated tools may miss business-logic flaws such as insecure object-level authorization.

Tests should be linked to requirements and threats. If a threat model identifies cross-tenant access as a major risk, automated tests should attempt access using identities from different tenants. If privacy analysis identifies excessive retention, a test or operational check should verify deletion behaviour. Security regression tests preserve fixes and prevent reintroduction of known weaknesses.

Security Gates and Release Decisions

A security gate is a decision point with defined evidence and escalation rules. Gates should be proportionate: a low-risk text change need not receive the same treatment as a new payment or identity service. Typical gates include completion of threat modelling for significant changes, review of high-risk code, dependency and secret scans, successful security tests, confirmation that critical vulnerabilities are resolved, and approval of documented residual risk.

Gates should not be designed as arbitrary barriers. A failed scan may reflect a false positive, an unreachable vulnerable path or a compensating control. The appropriate response is triage, not automatic suppression. Exceptions should have a named owner, business justification, scope, expiry date, compensating controls and a remediation plan. Permanent exceptions without review convert governance into unrecorded risk acceptance.

A release decision should consider exploitability, exposure, data sensitivity, control effectiveness, detectability, recovery capability and time to remediation. A critical defect in an isolated internal prototype may have a different decision from the same defect in a public multi-tenant service. Risk-based governance does not mean accepting everything; it means making decisions transparently and consistently.

Assurance Evidence and Traceability

Assurance evidence connects intention with operation. A mature team can trace a significant risk from requirement to design decision, implementation, test, release approval and operational monitoring. Useful evidence includes a data inventory, threat model, architecture decision record, secure-code review, scan results, test reports, dependency inventory, access-control review, deployment record, exception register and incident exercise.

Evidence must be credible, current and protected against unauthorised alteration. Collecting documents merely to satisfy an audit creates paperwork without assurance. Evidence should answer practical questions: What was protected? Which control was expected? Who verified it? When? What result was obtained? What unresolved risk remains? Automated pipelines can generate evidence, but organisations must control retention, access and the possibility that a compromised pipeline could falsify results.

Integrating SSDLC with Agile and DevOps

Agile teams often express work as user stories. Security can be embedded through acceptance criteria, definition-of-ready checks and definition-of-done checks. A feature involving personal data may not be ready until its data purpose and access rules are understood. It may not be done until authorization tests, logging review and privacy documentation are complete.

Security champions provide local support, but they do not replace professional security expertise or management accountability. Communities of practice, reusable patterns, threat-modelling workshops and office hours help teams avoid repeating the same mistakes. Security specialists should be involved early in high-risk initiatives and should focus on enabling teams through tooling and guidance.

DevOps pipelines are powerful enforcement points. A pipeline may build an application, run unit and security tests, scan dependencies and images, sign artefacts, deploy to controlled environments and record results. Policy-as-code can express rules such as prohibiting publicly exposed storage or deployments without approved identity configuration. Nevertheless, pipeline controls themselves require protection: credentials must be short-lived and scoped, runners must be isolated, artefacts must be trusted and changes to pipeline definitions must be reviewed.

Metrics should measure outcomes and learning rather than reward superficial activity. Useful indicators include time to remediate high-risk findings, percentage of critical services with current threat models, age of exceptions, proportion of security tests automated, recurrence of similar defects and coverage of dependency inventories. Counting vulnerabilities alone may encourage teams to manipulate classifications or suppress findings.

Illustrative Case Study: Securing a Multi-Tenant Learning Platform

Background

The fictional organisation LearnSphere operates a cloud-based learning platform used by universities and professional institutes. Each institution manages learners, assessments and certificates. The platform includes a browser application, mobile APIs, an administrative portal, object storage and several external messaging services.

Situation and Problem

A major release introduces collaborative assessment features and a new analytics service. The delivery team plans to release within six weeks. A preliminary review identifies risks: an analytics service receives more learner data than necessary; authorization is implemented inconsistently across APIs; a logging library has a known vulnerability; and a deployment script contains a long-lived cloud credential. Product management is concerned that security activities will delay the release.

Analysis

Threat modelling identifies cross-tenant data exposure as the highest-impact threat. An attacker who obtains a valid learner token might alter an identifier in an API request and retrieve another institution’s assessment. The analytics design also creates privacy risk because raw learner identifiers are unnecessary for the intended reports. The dependency vulnerability is potentially exploitable only through a rarely used feature, but the component is internet-facing. The cloud credential creates broad blast radius if the pipeline is compromised.

Approach and Strategy

The team first defines security and privacy acceptance criteria. Every data-access endpoint must enforce tenant-aware authorization on the server. Analytics is redesigned to use pseudonymous identifiers and aggregated data, with a documented retention period. A shared authorization library is introduced, supported by cross-tenant automated tests.

The vulnerable dependency is upgraded after compatibility testing. The deployment credential is replaced with short-lived workload identity and narrowly scoped permissions. Threat-model findings are recorded in the product backlog. The pipeline adds dependency, secret and infrastructure scans, while a manual review examines business-logic authorization. A release gate requires closure of critical findings and documented approval for any high-risk exception.

Outcome

The release is delayed by four days, primarily to complete authorization testing and redesign the analytics data flow. Testing discovers two endpoints that bypassed the shared authorization library; they are corrected before release. The resulting evidence package includes the threat model, privacy decision, test results, dependency report, deployment configuration review and release approval. Operations adds alerts for unusual cross-tenant access patterns and schedules a post-release review.

Learning Points

The case demonstrates that security is not simply a testing cost added at the end. Early data and architecture decisions reduced privacy exposure, while automated tests and manual analysis addressed different classes of risk. The release gate made risk visible and actionable rather than blocking work without explanation. Most importantly, the team treated the pipeline and operational monitoring as part of the product’s security boundary.

Challenges, Limitations and Common Mistakes

SSDLC programmes often fail when security is framed as the exclusive responsibility of specialists. Security teams become bottlenecks, while developers wait for approval rather than developing capability. The opposite failure occurs when responsibility is delegated entirely to delivery teams without training, standards or architectural support.

Another mistake is excessive reliance on scanning. Tools are valuable for scale, but they do not understand every business rule, design assumption or exploit chain. Teams may also optimise for vulnerability counts, ignore low-frequency high-impact risks or suppress findings without expiry. A further problem is treating compliance evidence as equivalent to security. A completed checklist cannot prove that an access control works in production.

Threat models can become obsolete, especially when infrastructure and third-party services change rapidly. They should therefore be versioned and linked to change management. Security gates can also become ritualistic if criteria are vague or identical for every change. Proportionality and clear escalation are essential.

There are technical limitations as well. Testing environments may not reproduce production identity, network, data or configuration. Privacy-preserving transformations may reduce analytical usefulness. Strong controls can create usability and accessibility problems if designed without user research. Security decisions should therefore consider human factors, operational feasibility and unintended consequences.

Governance, Ethics and Professional Responsibility

Organisations must assign accountability for security risk. Boards and senior managers determine risk appetite and resources; product leaders determine priorities; engineering leaders establish technical practices; and developers have a professional duty to raise material concerns. No individual should be pressured to conceal a serious vulnerability or misrepresent test results.

Privacy and security decisions should respect applicable law and contractual commitments, but legal compliance is a minimum rather than the complete ethical standard. Collecting data merely because it may be useful later can create surveillance and breach risks. Monitoring must be proportionate, transparent and access-controlled. Security research and penetration testing require authorisation, defined scope and responsible handling of discovered data.

Incident readiness is part of SSDLC. Teams should know how to preserve evidence, contain affected services, assess data exposure, communicate accurately and restore secure operation. Lessons from incidents and near misses should feed back into requirements, architecture, training and controls without creating a culture of blame.

Emerging Developments

Software delivery is increasingly influenced by cloud-native architecture, infrastructure-as-code, software bills of materials, signed artefacts and supply-chain security frameworks. These practices improve visibility and provenance but introduce new systems that must themselves be secured. Artificial intelligence is being used to assist code completion, vulnerability triage, test generation and threat analysis. Such tools can accelerate work, but generated code may contain insecure assumptions, reproduce licence-restricted material or expose confidential prompts and source code. Human review, approved tools and data-handling rules remain necessary.

Regulatory expectations are also moving toward demonstrable secure development, vulnerability management and accountability across the software supply chain. Organisations should monitor applicable requirements rather than assume that one certification or framework satisfies every obligation. The enduring trend is toward evidence-based assurance: organisations are expected not merely to claim that software is secure, but to demonstrate how risks were identified, treated and monitored.

Best-Practice Principles

A sustainable SSDLC generally follows these principles:

1. Make security and privacy requirements explicit, testable and traceable.

2. Use threat modelling to guide architecture and prioritisation.

3. Prefer secure defaults, least privilege, defence in depth and fail-safe behaviour.

4. Provide developers with approved libraries, patterns and practical training.

5. Combine automation with expert review and business-logic testing.

6. Protect the software supply chain, build pipeline, artefacts and deployment identities.

7. Use proportionate, evidence-based release gates.

8. Record exceptions with ownership, expiry and compensating controls.

9. Monitor production behaviour and feed incidents back into development.

10. Treat privacy, accessibility, usability and security as connected design responsibilities.

Chapter Summary

The Secure Software Development Life Cycle integrates security and privacy into product planning, architecture, coding, verification, release and operations. Its central idea is shared, continuous and risk-based responsibility. Security requirements must be testable; threat modelling must influence architecture; coding standards and peer review must reduce implementation error; automated and manual testing must complement one another; and release gates must be supported by credible evidence. Agile and DevOps do not eliminate governance: they require security to be embedded in backlogs, pipelines, team practices and operational feedback. Effective SSDLC also depends on ethical data use, accountable risk acceptance, supply-chain protection and continual improvement.

Key Terms

Security requirement: A verifiable statement specifying a security or privacy expectation.

Secure Software Development Life Cycle: A life-cycle approach integrating security activities into software development and operation.

Threat modelling: Structured identification and treatment of threats affecting a system.

Trust boundary: A point at which data or control passes between different assumptions about trust.

Security control: A technical, procedural or organisational measure that reduces risk.

Privacy by design: Integrating privacy protections into products, processes and defaults from the outset.

Least privilege: Giving an identity only the permissions necessary for its legitimate task.

Defence in depth: Using multiple complementary controls so one failure does not cause total compromise.

Security champion: A delivery-team member who facilitates security practice and communication.

Security gate: A defined decision point requiring specified security evidence or approval.

Residual risk: Risk remaining after controls and treatments have been applied.

Exception: An authorised, documented deviation from a security requirement or control.

Static application security testing: Analysis of source or compiled code without executing the application.

Dynamic application security testing: Security examination of a running application.

Software composition analysis: Examination of third-party and open-source dependencies for risk.

Security regression test: A repeatable test preventing a previously fixed weakness from returning.

Assurance evidence: Artefacts demonstrating that security decisions or controls were performed and verified.

Software supply chain: The people, processes, tools and components involved in producing and delivering software.

Policy as code: Machine-enforced expression of organisational rules within automated systems.

Risk appetite: The amount and type of risk an organisation is willing to accept.

Review Questions

Short Answer Questions

1. Why must security be treated as a continuous life-cycle responsibility rather than a final testing phase?

2. What is the relationship between a security requirement and a security control?

3. State two questions that should be asked during privacy-by-design analysis.

4. What information should be included in a documented security exception?

5. Why is peer review necessary even when automated security scanning is used?

Long Answer Questions

1. Explain how threat modelling can influence the architecture and testing of a multi-tenant web application.

2. Discuss how security requirements can be integrated into Agile backlogs and definitions of done.

3. Describe the role of security gates and assurance evidence in risk-based release governance.

4. Compare static testing, dynamic testing, dependency analysis and manual penetration testing.

5. Analyse the organisational and ethical responsibilities involved in implementing SSDLC.

Analytical / Application Questions

1. A team wants to release an API that processes health information but has no data-flow diagram or retention decision. Identify the SSDLC activities that should occur before release and justify their order.

2. A pipeline reports a critical dependency vulnerability, but the affected function is unreachable and a compensating control exists. Recommend a governance response, including evidence and exception requirements.

3. Design a security-gate proposal for a new payment service. Specify the minimum security requirements, threat-modelling outputs, tests, approvals and operational evidence needed for release.

22. Multiple Choice Questions with Answers

Question 1

Which activity best demonstrates privacy by design in the LearnSphere case?

A. Adding a privacy notice after deployment

B. Replacing unnecessary raw learner identifiers with pseudonymous and aggregated data

C. Increasing the number of application logs

D. Allowing every analyst to access the learner database

Correct Answer: B. Replacing unnecessary raw learner identifiers with pseudonymous and aggregated data

Question 2

What is the primary purpose of threat modelling in an SSDLC?

A. To replace all security testing

B. To identify and prioritise threats so that design and controls address them

C. To guarantee that no vulnerability can exist

D. To determine the project’s programming language

Correct Answer: B. To identify and prioritise threats so that design and controls address them

Question 3

Which release decision is most consistent with risk-based governance?

A. Automatically reject every scan finding

B. Ignore findings from internal applications

C. Assess exploitability, exposure, impact, controls and residual risk

D. Release whenever product management requests it

Correct Answer: C. Assess exploitability, exposure, impact, controls and residual risk

Question 4

Which control most directly limits the damage caused by a compromised deployment identity?

A. Short-lived credentials with narrowly scoped permissions

B. Detailed user interface documentation

C. A larger application log file

D. A longer password-expiration period

Correct Answer: A. Short-lived credentials with narrowly scoped permissions

Question 5

Why are automated security tools insufficient on their own?

A. They cannot run in a DevOps pipeline

B. They may miss business-logic flaws and produce false positives

C. They only detect physical security problems

D. They eliminate the need for secure coding standards

Correct Answer: B. They may miss business-logic flaws and produce false positives

Question 6

Which item is essential in a temporary security exception?

A. An absence of an accountable owner

B. A permanent waiver with no review date

C. A business justification, compensating control and expiry date

D. A decision to suppress all future scan results

Correct Answer: C. A business justification, compensating control and expiry date

Question 7

A learner changes an object identifier in an API request and retrieves another institution’s record. What weakness is most directly illustrated?

A. Insecure object-level authorization

B. Insufficient password hashing

C. Inadequate image compression

D. Excessive browser caching only

Correct Answer: A. Insecure object-level authorization

Question 8

Which evidence best supports traceability for a high-risk feature?

A. An unverified claim that the feature is secure

B. A threat model linked to design, implementation, tests and release approval

C. A screenshot of the product homepage

D. A list of developers’ job titles

Correct Answer: B. A threat model linked to design, implementation, tests and release approval

Question 9

What is the most appropriate role of a security champion?

A. To assume all security accountability for the organisation

B. To replace penetration testers in every project

C. To connect the delivery team with security practice and guidance

D. To approve regulatory exceptions without management

Correct Answer: C. To connect the delivery team with security practice and guidance

Question 10

Which metric is more meaningful than simply counting vulnerabilities?

A. Number of colours in the security dashboard

B. Time to remediate high-risk findings and recurrence of similar defects

C. Number of lines of source code

D. Number of meetings held by the security team

Correct Answer: B. Time to remediate high-risk findings and recurrence of similar defects

Web Application Security and Secure Coding
Chapter 4 of 14