EDUCATION · SECURE · DEVELOPMENT

🔐 Safe software development

Six topics on how to develop secure software - from Secure by Design principles to CI/CD security gates and supply chain integrity - by international practice (CISA, NIST SSDF, OWASP, SLSA). Examples are general, intended for training.

Safety as design requirement

Secure by Design and Secure by Default

Trūkuma novēršanas izmaksas pa dzīves cikla fāzēm Stabiņu diagramma - jo vēlāk fāzē (prasības → projektēšana → izstrāde → testēšana → ražošana) atrod trūkumu, jo augstākas relatīvās novēršanas izmaksas. Drošība iebūvēta, ne uzlīmēta Jo vēlāk atrod trūkumu, jo dārgāk to novērst (relatīvās izmaksas, ilustratīvi) Shift-left: atrodi un novērsi pēc iespējas agrāk ×1 Prasības ×5 Projektēšana ×10 Izstrāde ×15 Testēšana ×30+ Ražošana CISA Secure by Design (2023) · NIST SSDF SP 800-218 · Saltzer & Schroeder principi

Secure by Design means security as a requirement from day one; Secure by Default means secure defaults (e.g. MFA enabled, ports closed) so that the user does not have to activate anything manually.

Application

Safety is a business requirement, not an additional function. Key principles: minimum attack surface, minimum privileges, protection at depth, secure failure (fail safely) and safe defaults.

Reference

CISA "Secure by Design" (2023) · NIST SSDF (SP 800-218) · OWASP · Saltzer & Schroeder (1975) safety design principles.

Safety Note

The responsibility for safety belongs to the manufacturer and not to the user. The safety to be manually activated in practice remains excluded - therefore the default must be safe.

Safe Development Life Cycle (SDLC)

Safety performance in each phase

Droša izstrādes dzīves cikla fāzes Sešas fāzes ar iebūvētu drošības darbību - prasības, projektēšana, izstrāde, testēšana, izvietošana, uzturēšana. Drošs izstrādes dzīves cikls Drošība nav atsevišķs posms beigās - tā caurvij visu ciklu 1 · Prasības · Drošības prasības · Ļaunprātīgas lietošanas gadījumi · Atbilstības prasības 2 · Projektēšana · Draudu modelēšana (STRIDE) · Drošības arhitektūra · Uzbrukuma virsmas analīze 3 · Izstrāde · Drošs kods + koda pārskats · SAST (statiskā analīze) · SCA (atkarību pārbaude) 4 · Testēšana · DAST (dinamiskā analīze) · Penetrācijas tests · Fuzzing 5 · Izvietošana · Droša konfigurācija · Noslēpumu pārvaldība · SBOM + parakstīšana 6 · Uzturēšana · Ielāpu pārvaldība · Monitorings un žurnāli · Incidentu reaģēšana Iteratīvs cikls - uzturēšanas atziņas baro jaunas prasības Microsoft SDL · NIST SSDF SP 800-218 · OWASP SAMM · BSIMM · ISO/IEC 27034

Application

For each phase your security action and responsible. Map on recognised frameworks - Microsoft SDL, NIST SSDF practices (PO, PS, PW, RV) and OWASP SAMM mature domains.

Reference

NIST SSDF SP 800-218 · Microsoft Security Development Lifecycle · OWASP SAMM · BSIMM · ISO/IEC 27034 (application security).

Safety Note

Danger modelling during the design phase finds architectural flaws that no code scanner sees - they are most expensive to repair later.

Safe coding practices

The most common risks (OWASP Top 10) and protection

OWASP Top 10 riski un to aizsardzība Tabula ar izplatītākajiem tīmekļa lietojumu riskiem kreisajā pusē un attiecīgo drošas kodēšanas aizsardzību labajā pusē. Risks → aizsardzība Drošs kods novērš izplatītākos vājumus jau rakstīšanas laikā RISKS (OWASP Top 10) AIZSARDZĪBA Bojāta piekļuves kontrole Servera-puses autorizācija katram pieprasījumam Kriptogrāfijas kļūdas TLS 1.3, spēcīga krypto (ne pašizgatavota) Injekcija (SQL/komandu) Parametrizēti vaicājumi, ievades validācija, izvades kodēšana Nedrošs dizains Draudu modelēšana, drošības prasības projektā Nedroša konfigurācija Droši noklusējumi, hardening, minimāla virsma Novecojušas komponentes SCA, regulāra atkarību atjaunināšana Autentifikācijas kļūdas MFA, droša sesiju pārvaldība, rate-limit Datu integritātes kļūdas Parakstīti artefakti, uzticami atkarību avoti Nepietiekama žurnalēšana Drošības notikumu reģistrēšana un brīdinājumi OWASP Top 10:2021 · OWASP ASVS · OWASP Cheat Sheets · CWE Top 25 · SEI CERT

Application

Practical checklist for the developer and code review. OWASP USS gives verifiable requirements at three levels (L1-L3) depending on the application's decline.

Reference

OWASP Top 10:2021 · OWASP Application Security Verification Standard (USAS) · OWASP Cheat Sheet Series · CWE Top 25 · SEI CERT Coding Standards.

Safety Note

Never trust the input and write your own cryptography. Valide input to server (not only browser) and uses proven libraries.

DevSecOps - Safety on conveyor

Automated safety gates at each stage

CI/CD konveijers ar drošības vārtiem Seši konveijera posmi no pirms-commit līdz izpildlaikam, katrs ar automatizētu drošības vārtu; shift-left bulta norāda drošību pēc iespējas agrāk. CI/CD konveijers ar drošības vārtiem Katrs vārts automatizēts un bloķējošs - drošība neatkarīga no cilvēka atmiņas Shift-left: drošība pēc iespējas agrāk Pirms-commit Commit / PR Būve Tests Izvietošana Izpildlaiks noslēpumu skenēšana lint SAST · SCA koda pārskats SBOM parakstīšana DAST · IAST integrācijas testi IaC skenēšana konfig audits monitorings WAF / RASP Vārts, kas neizdodas → konveijers apstājas (build fails) OWASP Top 10 CI/CD Security Risks · NIST SSDF · SLSA · DevSecOps prakse

Application

Each security tool becomes an automatic conveyor gate. Its security is scaled up by design rather than relying on manual testing under time pressure.

Reference

OWASP Top 10 CI/CD Security Risks · NIST SSDF SP 800-218 · SLSA · DevSecOps (culture + automation).

Safety Note

The conveyor itself is the goal - to protect the secrets of the building, to limit employee permits and to check third party activities (GitHub Actions etc.) so that the conveyor is not compromised.

Automated safety testing

SAST, SCA, DAST, IAST - who finds anything

Drošības testēšanas metožu salīdzinājums Sešas automatizētas drošības testēšanas metodes ar to, ko katra analizē un kad konveijerā tā darbojas. Testēšanas metodes salīdzinājums Neviena metode viena pati neatrod visu - tās papildina cita citu SAST Statiskā pirmkoda analīze Kad: commit / būve Baltā kaste (white-box) Daudz viltus-pozitīvu SCA Atkarības un bibliotēkas Kad: commit / būve Zināmās CVE + licences Balstās uz SBOM Noslēpumu skenēšana Noslēpumi kodā un vēsturē Kad: pirms-commit API atslēgas, paroles Novērš noplūdi git vēsturē DAST Darbojošos lietotni Kad: tests / staging Melnā kaste (black-box) Izpildlaika vājības IAST Instrumentēts izpildlaiks Kad: funkcionālie testi Pelēkā kaste (grey-box) Precīzāk, mazāk viltus Konteineru / IaC Attēli + infrastruktūras kods Kad: būve / izvietošana Nedroši attēli, konfig CIS benchmarks OWASP · NIST SSDF SP 800-218 (RV grupa) · fuzzing (OSS-Fuzz) papildina dinamisko testēšanu

Application

Combine methods according to conveyor section: static (SAST/SCA/secret) early, dynamic (DAST/IAST) tests, infrastructure scanning before deployment.

Reference

OWASP (test tools - ZAP, Dependency-Check) · NIST SSDF SP 800-218 · CIS Benchmarks · OSS-Fuzz (continuous fuzzing).

Safety Note

Tools find known templates, not business logic errors. Automated testing does not check whether access control is logically correct - it is found in a manual review and penetration test.

Software supply chain integrity

SBOM, signature and SLSA levels

Piegādes ķēdes integritātes kontroles un SLSA līmeņi Augšā piegādes ķēdes plūsma no avota līdz izvietošanai ar integritātes kontroli katrā solī; zem tās SLSA būves līmeņi no L0 līdz L3. Piegādes ķēde: integritāte no avota līdz izvietošanai Pierādi, KO tu palaid un NO KURIENES tas nāk Avots versiju kontrole 2-personu pārskats Būve (build) izolēta, atkārtojama izcelsme (provenance) Artefakts SBOM (CycloneDX/SPDX) paraksts (Sigstore) Izvietošana verificē parakstu pārbauda izcelsmi SLSA būves līmeņi - pieaugoša būves integritāte L0 Nav garantiju nav izcelsmes pieraksta sākumpunkts L1 Izcelsme (provenance) pieejama un dokumentēta automatizēta būve L2 Parakstīta izcelsme pārvaldīta būves platforma grūtāk viltot L3 Neviltojama izolēta būve augstākā garantija SLSA v1.0 · NIST SSDF SP 800-218 · US EO 14028 · EU CRA · in-toto attestations SBOM = sastāvdaļas · izcelsme (provenance) = kā tas uzbūvēts · paraksts = kas to izlaida

Application

SBOM allows a quick answer "do we are affected by this CVE?"; origin (provenance) and signature proves that the artefact (the final file of the building) comes from a reliable, genuine construction process. Together they protect the supply chain.

Reference

SLSA v1.0 · NIST SSDF SP 800-218 · SPDX / CycloneDX (SBOM formats) · Sigstore/cosign · in-toto · US EO 14028 · EU Cyber Resilience Act (CRA).

Safety Note

Most code is third party addiction. SolarWinds and similar incidents show - compromised construction or addiction to circumvent all other protections. Verify before launch.

Abbreviations

All abbreviations used in the guide (original and meaning).

SDLC
Software Development Life Cycle - software development life cycle.
SSDLC
Safe SDLC - life cycle with built-in safety.
SDL
Security Development Lifecycle - Microsoft secure development process.
SSDF
Secure Software Development Framework - NIST SP 800-218.
SAMM
Software Assurance Integrity Model - OWASP maturity model.
BSIMM
Building Security In Matrity Model - real practice measurement.
SAST
Static Application Security Testing - Statistical Source Analysis.
DAST
Dynamic Application Security Testing - Test of the running application.
IAST
Interactive Application Security Testing - instrumented performance test.
SCA
Software Composition Analysis - addiction/component analysis.
RASP
Runtime Application Self-Protection - self-defence of execution time.
WAF
Web Application Firewall for web applications.
DevSecOps
security embedded in DevOps culture and automation.
CI/CD
continuous integration/delivery (conveyor).
IaC
Infrastructure as Code - infrastructure as code.
SBOM
Software Bill of Materials - a list of software components.
SLSA
Supply-chain Levels for Software Artifacts - supply chain levels.
CWE
Common Weakness Enumeration - software weakness classification.
CVE
Common Vulnerabilities and Exposures - a public vulnerability register.
ASVS
OWASP Application Security Verification Standard.
STRIDE
threat modelling categories (Microsoft).
MFA
Multi-Factor Authentication - Multifactor Authentication.
TLS
Transport Layer Security - transport layer encryption.
CRA
EU Cyber Resilience Act - EU cyber resilience regulation.
provenance
origin record - how and from which the artefact was built (SLSA).
artefakts
the final result of the construction - executable, package or container image.
build
construction - conversion of source to a launchable artefact.