A secure SDLC embeds security into every phase of software development — planning, design, coding, testing, deployment, and operations — instead of bolting on a single security review before release. The practical mechanism is "shift-left": security requirements during planning, threat modeling during design, SAST and dependency scanning during development, DAST and penetration testing before release, and continuous monitoring in production. Finding defects earlier can reduce rework and avoid the coordination needed for a production fix.
The diagram below shows where security activities fit across the lifecycle and illustrates why later fixes can require more coordination. The rest of this guide walks phase by phase — from security user stories to STRIDE threat models to a CI/CD security workflow you can adapt — and offers a sequence for introducing these practices.
Many attacks exploit vulnerabilities that can be addressed during the software development lifecycle (SDLC). SQL injection, cross-site scripting, authentication flaws, insecure configurations—these issues aren't inevitable. They're the result of development processes that don't account for security until it's expensive and disruptive to fix.
This guide covers how to integrate security into every SDLC phase, from requirements gathering through deployment and maintenance. Whether you're implementing DevSecOps for the first time or maturing existing practices, these principles and tools will help you build security in rather than bolt it on.
Threat Modeling Wizard (STRIDE & DREAD)
Build complete threat models with STRIDE decomposition, DREAD scoring, auto-generated threat libraries, and prioritized mitigations. CISSP Domain 1.
Open the full Threat Modeling Wizard (STRIDE & DREAD) →SDLC Phases Overview
The software development lifecycle provides a framework for building software systematically. While methodologies vary (Waterfall, Agile, DevOps), the fundamental phases remain consistent:
Traditional SDLC Phases
- Planning/Requirements: Define what to build and why
- Design: Architect the solution
- Development: Write the code
- Testing: Verify functionality and quality
- Deployment: Release to production
- Maintenance: Operate and improve
Where Security Fits
Traditional approaches add security late in the process—penetration testing before release, security reviews after development. This creates several problems:
- Late discovery: Issues found late are expensive to fix
- Schedule pressure: Security becomes a blocker rather than enabler
- Friction: Developers see security as an obstacle
- Incomplete coverage: Time constraints mean shortcuts
Shift-left security moves security activities earlier in the lifecycle:
| Phase | Traditional Security | Shift-Left Security |
|---|---|---|
| Planning | Minimal | Security requirements, risk assessment |
| Design | None | Threat modeling, secure architecture |
| Development | None | Secure coding, code review, SAST |
| Testing | Penetration testing | SAST, DAST, IAST, security regression |
| Deployment | Manual review | Automated gates, infrastructure scanning |
| Maintenance | Incident response | Continuous monitoring, vulnerability management |
Security in the Planning Phase
Security begins before any code is written.
Security Requirements Gathering
Capture security needs alongside functional requirements:
Authentication requirements:
- Who needs access?
- What authentication methods are appropriate?
- What session management is needed?
Authorization requirements:
- What access control model (RBAC, ABAC)?
- What are the permission levels?
- How granular does access control need to be?
Data protection requirements:
- What data is sensitive?
- What encryption is needed (transit, rest)?
- What are data retention requirements?
Compliance requirements:
- What regulations apply (GDPR, HIPAA, PCI-DSS)?
- What security controls are mandated?
- What audit/logging requirements exist?
Risk Assessment
Evaluate security risk early:
- Asset identification: What are you protecting?
- Threat identification: Who might attack and how?
- Vulnerability assessment: What weaknesses exist?
- Impact analysis: What's the potential damage?
- Risk rating: Prioritize based on likelihood × impact
Risk-based prioritization: Not all features need the same security investment. A public marketing page needs less scrutiny than a payment processing module.
Security User Stories
Express security requirements in Agile terms:
As a user, I want my session to expire after 30 minutes of inactivity
so that my account is protected if I forget to log out.
As an administrator, I want to see audit logs of all data exports
so that I can investigate potential data breaches.
As a developer, I want automated dependency scanning in CI
so that I'm alerted to vulnerable libraries before they reach production.
Acceptance criteria should include security verification:
Given: A user is authenticated
When: They are inactive for 30 minutes
Then: They are automatically logged out
And: Their session token is invalidated
And: They must re-authenticate to continue
Security in the Design Phase
Architecture decisions made during design have the biggest impact on security.
Threat Modeling
Systematically identify threats to your application:
STRIDE methodology:
| Threat | Description | Example |
|---|---|---|
| Spoofing | Impersonating something or someone | Forged authentication |
| Tampering | Modifying data or code | SQL injection |
| Repudiation | Denying actions | Missing audit logs |
| Information disclosure | Exposing information | Data leak |
| Denial of service | Making system unavailable | Resource exhaustion |
| Elevation of privilege | Gaining unauthorized access | Privilege escalation |
Threat modeling process:
- Diagram the system: Data flow diagrams showing components, data stores, trust boundaries
- Identify threats: Use STRIDE against each element
- Document threats: Describe attack scenarios
- Rate threats: DREAD scoring or similar
- Plan mitigations: Controls to address each threat
- Track resolution: Ensure mitigations are implemented
Tools:
- Microsoft Threat Modeling Tool (free)
- OWASP Threat Dragon (open source)
- IriusRisk (commercial)
Secure Architecture Patterns
Design with security built in:
Defense in depth:
[Users] → [WAF] → [Load Balancer] → [App Servers] → [Internal Firewall] → [Database]
↓
[SIEM/Monitoring]
Multiple layers ensure single failures don't compromise everything.
Principle of least privilege:
- Services run with minimum necessary permissions
- Users get minimum access needed for their role
- Network segments are isolated by function
Secure defaults:
- Security features enabled by default
- Explicit opt-out rather than opt-in for security
- Conservative default configurations
Authentication and Authorization Design
Plan authentication architecture early:
Authentication options:
- Session-based (stateful, server stores session)
- Token-based JWT (stateless, client stores token)
- OAuth 2.0/OIDC (delegated authentication)
Authorization models:
- RBAC (Role-Based): Permissions assigned to roles, users assigned to roles
- ABAC (Attribute-Based): Permissions based on user/resource/environment attributes
- ReBAC (Relationship-Based): Permissions based on relationships (used by Google Zanzibar)
Data Flow Analysis
Map how sensitive data moves through your system:
- Where does data enter?
- Where is it stored?
- How is it processed?
- Where does it exit?
- Who can access it at each point?
Identify where encryption, access controls, and logging are needed.
Security in the Development Phase
Developers are your first line of defense.
Secure Coding Standards
Adopt recognized standards:
OWASP guidelines:
- OWASP Top 10: Most critical web application security risks
- OWASP ASVS: Application Security Verification Standard
- OWASP Cheat Sheets: Specific guidance by topic
Language-specific guidance:
- CERT Secure Coding Standards (C, C++, Java)
- PEP 8 + security extensions (Python)
- ESLint security plugins (JavaScript)
Common vulnerability prevention:
// SQL Injection - NEVER concatenate user input
// BAD
const query = `SELECT * FROM users WHERE id = ${userId}`;
// GOOD - Parameterized queries
const query = 'SELECT * FROM users WHERE id = ?';
db.query(query, [userId]);
// XSS - ALWAYS encode output
// BAD
element.innerHTML = userInput;
// GOOD - Use text content or encode
element.textContent = userInput;
// OR
element.innerHTML = encodeHTML(userInput);
Code Review Practices
Security-focused code review checklist:
Authentication/Authorization:
- All endpoints require appropriate authentication
- Authorization checks prevent privilege escalation
- Session management is secure
Input validation:
- All user input is validated
- Validation happens server-side
- Error messages don't reveal sensitive info
Data protection:
- Sensitive data is encrypted
- Secrets aren't hardcoded
- Logs don't contain sensitive data
Common vulnerabilities:
- SQL injection prevented (parameterized queries)
- XSS prevented (output encoding)
- CSRF tokens implemented
- Directory traversal prevented
IDE Security Plugins
Catch issues as you code:
Visual Studio Code:
- Snyk Security
- SonarLint
- ESLint with security plugins
- Semgrep
JetBrains IDEs:
- SonarLint
- Snyk Security
- Find Security Bugs (Java)
Configuration example (ESLint):
{
"plugins": ["security"],
"extends": ["plugin:security/recommended"],
"rules": {
"security/detect-object-injection": "error",
"security/detect-non-literal-regexp": "warn",
"security/detect-unsafe-regex": "error",
"security/detect-buffer-noassert": "error",
"security/detect-eval-with-expression": "error"
}
}
Dependency Scanning (SCA)
Third-party components are a major attack surface:
Software Composition Analysis tools:
- Snyk: SCA with dependency findings and remediation guidance
- Dependabot: GitHub-native, automatic PRs
- OWASP Dependency-Check: Open source scanner
- Mend: SCA for third-party components
CI/CD integration: Run dependency scanning on pull requests and protected branches. Install the scanner, provide its token through the CI secret store, and configure the severity threshold and failure behavior for your project. Pin actions to reviewed releases or commit hashes when you implement the workflow.
For example, with the Snyk CLI installed and SNYK_TOKEN supplied by your CI secret store:
snyk test --severity-threshold=high
Check the current Snyk CLI options before using this command in a pipeline.
Secrets Management
Never commit secrets to version control:
Pre-commit hooks:
# .pre-commit-config.yaml
repos:
- repo: https://github.com/Yelp/detect-secrets
rev: v1.4.0
hooks:
- id: detect-secrets
args: ['--baseline', '.secrets.baseline']
Secrets management solutions:
- HashiCorp Vault
- AWS Secrets Manager
- Azure Key Vault
- Google Secret Manager
- 1Password Secrets Automation
Environment variable pattern:
# Never in code
DATABASE_PASSWORD=secret123 # BAD
# In environment (not committed)
export DATABASE_PASSWORD=$(vault kv get -field=password secret/database)
Security in the Testing Phase
Multiple testing approaches catch different vulnerability classes. No single tool is enough — SAST reads code it cannot run, DAST attacks a running app it cannot see inside, and IAST watches from within. Use this table to decide what runs where in the pipeline.
| Approach | Needs source? | Needs running app? | Catches best | False positives | Pipeline stage | Use when |
|---|---|---|---|---|---|---|
| SAST | Usually | No | Potential code-level flaws such as injection paths and insecure APIs | Varies by tool and rules | Commit / PR | You want code feedback before deployment |
| SCA | Dependency manifests or inventory | No | Known vulnerabilities in third-party components | Varies by inventory and advisories | Commit / PR | Your project uses third-party packages |
| DAST | No | Yes | Externally reachable runtime and configuration flaws | Varies by scan setup and access | Staging deployment / scheduled | You have a test environment and want external coverage |
| IAST | Application instrumentation | Yes | Runtime-observed paths with code context | Varies by instrumentation and test coverage | Functional / QA tests | You can instrument the app and exercise relevant paths |
| Pen test | Optional (gray box) | Yes | Business-logic and chained exploits tools miss | N/A (human) | Pre-release / annual | Major release, compliance requirement, or high-risk feature |
Which should I run first? Start with SCA and SAST where they fit your codebase and CI budget; neither needs a deployed environment. Add DAST once you have a stable staging URL. Consider IAST and expert penetration testing based on risk, test coverage, and available resources. Check vendors' current pages for licensing and supported features.
Static Application Security Testing (SAST)
Analyze source code without execution:
Capabilities:
- Find code-level vulnerabilities (SQL injection, XSS, etc.)
- Identify dangerous function usage
- Detect hardcoded secrets
- Enforce coding standards
Limitations:
- Findings need triage; false positives and false negatives vary by tool and rule configuration
- Can't detect runtime issues
- Limited understanding of data flow across components
Popular SAST tools:
- SonarQube
- Checkmarx
- Veracode
- Semgrep
- CodeQL
CI/CD integration: In a GitHub Actions workflow, check out the repository, initialize CodeQL for the languages you use, build or use its automatic build where supported, and run the analysis step. Follow the current CodeQL setup instructions and pin the action to a reviewed release or commit hash.
Dynamic Application Security Testing (DAST)
Test running applications like an attacker would:
Capabilities:
- Find runtime vulnerabilities
- Test authentication/authorization
- Discover configuration issues
- No source code needed
Limitations:
- Requires running application
- Can't find all code paths
- Slower than SAST
- May miss vulnerabilities without proper coverage
Popular DAST tools:
- OWASP ZAP
- Burp Suite
- Invicti (formerly Netsparker)
- Acunetix
- HCL AppScan
Basic OWASP ZAP automation: Run a baseline scan against a staging URL using the current ZAP container image and baseline script. Save the report as a CI artifact and review findings before making them a release gate.
# Replace the URL with a staging target you are authorized to test.
docker run --rm -v "$PWD:/zap/wrk/:rw" -t ghcr.io/zaproxy/zaproxy:stable \
zap-baseline.py -t https://staging.example.com -r zap-report.html
See the ZAP baseline scan documentation for report options and exit behavior.
Interactive Application Security Testing (IAST)
Instrument running applications for deep visibility:
Capabilities:
- Correlates observed runtime behavior with application code when instrumentation supports it
- Can provide code context for findings on exercised paths
- Findings still need validation; accuracy depends on instrumentation and test coverage
- Works during functional testing
Limitations:
- Requires application instrumentation
- Language/framework specific
- Performance overhead
- More complex setup
Popular IAST tools:
- Contrast Security
- Checkmarx IAST
- Synopsys Seeker
- Veracode IAST
Penetration Testing
Expert-driven security testing:
Types:
- Black box: No knowledge of internals
- White box: Full access to code and architecture
- Gray box: Partial knowledge of the system
When to conduct:
- Before major releases
- After significant changes
- At a frequency based on risk and applicable requirements
- For compliance requirements
Scope definition:
- Target systems and URLs
- Test types allowed
- Timeline and rules of engagement
- Reporting requirements
Security Regression Testing
Use regression tests to check that previously fixed vulnerabilities do not recur. Adapt these test outlines to your application's authentication behavior and rate-limit policy:
// SQL injection regression test outline:
// In an isolated database, seed a known account.
// Attempt login with a SQL-shaped username and an invalid password.
// Assert that no authenticated session or token is issued and that account
// records are unchanged. Check the query implementation for parameter binding;
// a surviving users table alone does not prove injection was prevented.
// Login rate-limit regression test outline:
// Isolate the client/account and reset rate-limit state before the test.
// Send attempts within the configured time window up to the documented limit.
// Assert the documented throttling behavior at the configured threshold,
// then verify recovery after the configured reset interval.
Security in Deployment and Operations
Secure deployment extends security through release and runtime.
Secure CI/CD Pipelines
Protect the software supply chain:
Pipeline security controls: In the deployment workflow, check out and build the application, then run dependency scanning, CodeQL initialization and analysis, container scanning against an image built in that workflow, and IaC scanning. Give each tool its required authentication and configuration. Make deployment depend on successful security checks; use current, reviewed action references in the actual pipeline.
Pipeline hardening:
- Require code review before merge
- Sign commits and artifacts
- Use immutable build environments
- Scan artifacts before deployment
- Implement deployment approvals
Container Security
Secure containerized deployments:
Image scanning:
# Scan image with Trivy
trivy image --severity HIGH,CRITICAL myapp:latest
Dockerfile security:
# Use a supported Node.js LTS image; pin a reviewed digest for production
FROM node:lts-alpine
# Run as non-root user
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
USER appuser
# Don't expose unnecessary ports
EXPOSE 3000
# Use read-only filesystem where possible
# Set at runtime: docker run --read-only myapp
Kubernetes security:
# Pod security context
apiVersion: v1
kind: Pod
metadata:
name: secure-pod
spec:
securityContext:
runAsNonRoot: true
runAsUser: 1000
fsGroup: 2000
containers:
- name: app
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
capabilities:
drop:
- ALL
Infrastructure as Code Security
Scan IaC before deployment:
Tools:
- Checkov (Terraform, CloudFormation, Kubernetes)
- tfsec (Terraform specific)
- KICS (multiple IaC formats)
- Terrascan
Example findings:
- S3 buckets without encryption
- Security groups allowing 0.0.0.0/0
- IAM policies with excessive permissions
- Unencrypted databases
Runtime Protection
Monitor applications in production:
Runtime Application Self-Protection (RASP):
- Instrument application at runtime
- Detect and block attacks in real-time
- Runtime context can help triage alerts, but false positives remain possible
Web Application Firewall (WAF):
- Block common attack patterns
- Virtual patching for known vulnerabilities
- Rate limiting and bot protection
Logging and monitoring:
- Security-relevant events to SIEM
- Real-time alerting on anomalies
- Audit trails for compliance
Conclusion
Integrating security into the SDLC means doing security work when teams can act on it. Finding a vulnerability during code review may avoid the rework and coordination needed after deployment. Threat modeling during design can expose architectural risks while changes are still practical.
Start where you are. If you are starting out, add dependency scanning and SAST to your CI pipeline to get feedback on code and dependencies. If you already have automated scanning, focus on developer training and threat modeling to prevent vulnerabilities rather than just detecting them.
Teams can make security part of their regular development work, including DevOps practices. Security is how they build software—baked into requirements, architecture, code, testing, and deployment. Getting there is a journey, but every step makes your applications more secure and your security program more sustainable.
Related Tools
- JSON Formatter - Format and validate JSON for API security testing
- Regex Tester - Test regular expressions for input validation patterns