Catalog My learning Blog
Full-Stack Developer Course: React, .NET and SQL Server · Phase 14 · Lesson 137 · 7 min read

Secure SDLC: SAST, DAST and Penetration Testing

On this page
  1. Learning Objective
  2. Concept Explanation
  3. Worked Example: A Security Workflow, a Review Checklist and a Triage Policy
  4. Real-World Examples
  5. Review Questions & Answers

Learning Objective

Build security into each stage of development, review code for the classes of bugs that matter, run static and dynamic analysis and dependency scanning in the pipeline, commission and use penetration tests and disclosure programs well, and triage vulnerabilities by real risk with agreed timelines.

Concept Explanation

Security added at the end is expensive, and security spread through the lifecycle is routine. A secure software development lifecycle puts a small number of practices at each stage, and the NIST Secure Software Development Framework, SP 800-218, is a good reference for the categories. At design, threat model new features as in Day 41 and record security requirements. During coding, follow written standards and use framework defaults. At review, check for security explicitly. In the pipeline, run automated analysis. Before release, test the running system. After release, watch, respond, and learn. No single tool covers everything, and each layer catches a different class of problem.

Code review is the highest-value activity because a reviewer can see intent. Give reviewers a short checklist tied to the bugs that recur: is every endpoint authenticated and does it authorize the specific resource; is every input validated and every query parameterized; are secrets absent from code and logs; is user data encoded on output; is cryptography a standard library used correctly, with no home-made schemes; do error messages avoid leaking detail; do new dependencies deserve trust; and do the tests cover the negative cases, such as a user requesting another's data. Mark sensitive areas in CODEOWNERS so that authentication, authorization, and cryptography changes always get a knowledgeable reviewer.

Automated tools each have a role. Static application security testing, such as CodeQL, analyzes the source for patterns like injection and unsafe deserialization. Software composition analysis checks dependencies against known vulnerability databases, with Dependabot and package audit tools, and dependency review on pull requests stops a vulnerable package from being added. Secret scanning with push protection blocks committed credentials. Dynamic testing, such as the OWASP ZAP baseline scan, exercises a running staging environment and finds misconfigured headers and exposed endpoints. Fuzzing sends unexpected input to parsers. All of them produce noise, so tune them, fail builds on high-confidence serious findings, and track the rest as work. Generating a software bill of materials, in CycloneDX or SPDX format, records exactly what is in each release, so when a new vulnerability such as Log4Shell appears you can answer whether you are affected in minutes.

People find what tools cannot. A penetration test by skilled testers, scoped in writing, run against a staging environment with realistic data, and repeated after significant changes, finds logic and authorization flaws. Give the testers context, accounts with different roles, and documentation, and treat the report as a backlog. Publish a vulnerability disclosure policy and a security.txt file, defined in RFC 9116, so researchers know how to report, and consider a bug bounty once you can triage the volume. Then run vulnerability management with rules: rate issues by severity, exploitability, and exposure, using CVSS with signals such as the Known Exploited Vulnerabilities catalog from CISA and the Exploit Prediction Scoring System, and agree deadlines, for example a few days for critical and exploited issues and a month or two for medium ones. Track them, report on them, and after incidents run blameless postmortems that lead to changes in the process.

StagePracticeCatches
DesignThreat model, security requirementsFlaws in the design itself
CodingStandards, secure defaults, IDE analyzersCommon mistakes early
ReviewSecurity checklist, CODEOWNERS for sensitive pathsAuthorization, logic, design errors
PipelineSAST, dependency review, secret scanning, SBOMKnown patterns, vulnerable packages, leaked keys
Pre-releaseDAST baseline scan, fuzzing, penetration testRuntime misconfiguration, logic and access flaws
OperationsDisclosure policy, triage SLAs, postmortemsIssues found in the wild, process gaps

Worked Example: A Security Workflow, a Review Checklist and a Triage Policy

The workflow runs analysis and scanning on pull requests. The checklist and the policy make human practice explicit.

YAML
# .github/workflows/security.yml
name: security
on:
  pull_request:
  schedule: [{ cron: '0 3 * * 1' }]          # weekly, to catch newly disclosed issues in unchanged code
permissions:
  contents: read
  security-events: write
jobs:
  codeql:
    runs-on: ubuntu-latest
    strategy: { matrix: { language: [csharp, javascript-typescript] } }
    steps:
      - uses: actions/checkout@<full-commit-sha>
      - uses: github/codeql-action/init@<full-commit-sha>
        with: { languages: '${{ matrix.language }}', queries: security-extended }
      - uses: github/codeql-action/autobuild@<full-commit-sha>
      - uses: github/codeql-action/analyze@<full-commit-sha>

  dependencies:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@<full-commit-sha>
      - uses: actions/dependency-review-action@<full-commit-sha>       # blocks pull requests that add vulnerable packages
        with: { fail-on-severity: high }
      - run: dotnet list package --vulnerable --include-transitive 2>&1 | tee vuln.txt; ! grep -q "Severity" vuln.txt
      - run: npm audit --omit=dev --audit-level=high

  sbom:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@<full-commit-sha>
      - run: dotnet tool install --global CycloneDX && dotnet CycloneDX ./src/Api -o sbom -j
      - uses: actions/upload-artifact@<full-commit-sha>
        with: { name: sbom, path: sbom/ }

  dast-baseline:
    if: github.event_name == 'schedule'
    runs-on: ubuntu-latest
    steps:
      - uses: zaproxy/action-baseline@<full-commit-sha>
        with: { target: 'https://staging.example.com', fail_action: true }
Code
## Security review checklist (pull request template section)
- [ ] Every new endpoint requires authentication, and authorizes the specific resource, not only the role.
- [ ] Inputs are validated with bounds. Queries are parameterized. No string-built SQL, paths or shell commands.
- [ ] No secrets in code, config files, logs or test fixtures. New secrets come from Key Vault.
- [ ] Output is encoded for its context. No new dangerouslySetInnerHTML or raw HTML rendering.
- [ ] Cryptography uses platform libraries with current algorithms. Nothing home-made.
- [ ] Error responses and logs do not leak internals or personal data.
- [ ] New dependencies were reviewed for maintenance, licence, and install scripts.
- [ ] Tests include a negative case: another user's resource, missing token, malformed input.
Code
security.txt (served at /.well-known/security.txt, RFC 9116)
Contact: mailto:security@example.com
Expires: 2027-06-30T00:00:00.000Z
Policy: https://example.com/security/disclosure
Preferred-Languages: en

Vulnerability triage policy
  Priority   Definition                                                        Fix or mitigate within
  P0         Actively exploited, or trivially exploitable with severe impact   24 hours
  P1         High severity, exposed to the internet                            7 days
  P2         Medium severity, or high severity in an internal system          30 days
  P3         Low severity or hardening                                        Next planned release
  Inputs: CVSS score, whether the vulnerable code is reachable, presence in the CISA KEV catalog, EPSS score, and compensating controls.

Track the time from disclosure to fix as a metric, and review it monthly. The number tells you more about your security posture than the count of tools in the pipeline.

Threat model at design, follow standards while coding, review with a security checklist and CODEOWNERS, and let the pipeline run static analysis, dependency review, secret scanning and an SBOM. Dynamic scans and penetration tests test the running system, and disclosure, triage deadlines and postmortems close the loop.
Threat model at design, follow standards while coding, review with a security checklist and CODEOWNERS, and let the pipeline run static analysis, dependency review, secret scanning and an SBOM. Dynamic scans and penetration tests test the running system, and disclosure, triage deadlines and postmortems close the loop.

Real-World Examples

  • Log4Shell, CVE-2021-44228, disclosed in December 2021, was a remote code execution flaw in the widely used Log4j logging library, and organizations scrambled to find out where the library was in their systems. Those with a software bill of materials and dependency inventory answered in hours, while others took weeks, and it made SBOMs a mainstream expectation.
  • The 2020 SolarWinds compromise inserted malicious code into the company's build process so that legitimate signed updates delivered a backdoor to thousands of customers, and the 2024 XZ Utils backdoor showed a patient attacker gaining maintainer trust in an open-source project. Both drove attention to build integrity, review of dependencies, and frameworks such as SLSA for provenance.
Key TakeawaysPut a few security practices at every stage of delivery, from design to production, rather than one big review at the end. That means threat modeling at design, a targeted review checklist with CODEOWNERS on sensitive paths, and automated static analysis, dependency review, secret scanning, SBOMs, and dynamic scans in the pipeline. Add penetration tests and a disclosure policy for what tools miss, and manage vulnerabilities with severity based triage, deadlines, and measurement.

Review Questions & Answers

Tools find known patterns, but a reviewer can see intent and catch missing authorization checks, flawed business logic, and design problems. A checklist and CODEOWNERS on sensitive paths make reviews consistently look for these.

It lists exactly which components and versions each release contains, so you can determine within minutes whether you are affected and which services to patch. Without it you must search manually.

A high score in unreachable code or an internal system is less urgent than a medium issue that is actively exploited and exposed. Reachability, exposure, exploitation evidence, and compensating controls determine real risk and the deadline.

It tells researchers where and how to report a vulnerability, and it signals that you accept reports. Without a clear channel, findings may go unreported or become public.