DevSecOps - Sicherheit von Anfang an im Software-Entwicklungsprozess
DevSecOps integriert Sicherheit in den DevOps-Zyklus von der ersten Code-Zeile bis zum Deployment. Kernprinzip: Shift Left Security. Wichtige Toolchain: SAST (Semgrep, SonarQube), DAST (OWASP ZAP), SCA (Snyk, Trivy), Secrets-Detection (GitLeaks, TruffleHog), IaC-Scanning (Checkov, tfsec) und Security Gates in CI/CD-Pipelines. NIS2 und ISO 27001 fordern explizit Sicherheit im SDLC.
DevSecOps ist keine neue Rolle - es ist die Kultur, Sicherheit als gemeinsame Verantwortung aller im Entwicklungsprozess zu verankern. Der klassische Ansatz - Sicherheit erst kurz vor dem Go-Live als Audit - erzeugt technische Schulden, teures Nachbessern und blinde Flecken.
Shift Left: Warum früh billiger ist
Je später Sicherheitslücken gefunden werden, desto teurer wird das Beheben:
| Phase | Entdeckungskosten (relativ) |
|---|---|
| Requirements | x1 - Konzept ändern ist kostenlos |
| Design | x5 - Architektur anpassen |
| Coding | x10 - Code umschreiben |
| Test | x25 - QA-Zyklus wiederholen |
| Produktion | x100+ - Incident Response, DSGVO-Bußgeld! |
Shift-Left-Maßnahmen nach Phase
Requirements-Phase:
- Threat Modeling: welche Bedrohungen hat dieses Feature?
- STRIDE: Spoofing, Tampering, Repudiation, Information Disclosure, DoS, Elevation of Privilege
Coding-Phase:
- Pre-commit Hooks: Secrets-Scanner, SAST (lokal)
- Secure Coding Guidelines (OWASP Top 10)
- Code Reviews mit Security-Fokus
CI/CD-Pipeline:
- Automatische Security-Gates (SAST, DAST, SCA, IaC)
- “Fail Fast”: Build bricht bei Critical-Findings ab
SAST: Static Application Security Testing
Quellcode wird ohne Ausführung analysiert.
Semgrep (kostenlos + sehr effektiv)
# .github/workflows/semgrep.yml:
semgrep-scan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: semgrep --config "p/owasp-top-ten" --config "p/secrets" --error .
# p/owasp-top-ten: SQL-Injection, XSS, SSRF, Path Traversal
# p/secrets: API-Keys, Tokens im Code
SonarQube (SAST + Code-Qualität)
# Community Edition = kostenlos (Self-Hosted)
- name: SonarQube Scan
uses: sonarsource/sonarqube-scan-action@master
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
CodeQL (GitHub Advanced Security)
# .github/workflows/codeql.yml:
- uses: github/codeql-action/init@v3
with:
languages: javascript, python, java
- uses: github/codeql-action/analyze@v3
# Ergebnisse kostenlos im GitHub Security Tab!
DAST: Dynamic Application Security Testing
OWASP ZAP (kostenlos)
# Full Scan:
docker run -t owasp/zap2docker-stable zap-full-scan.py \
-t https://staging.app.example.com \
-r zap-report.html
# API Scan:
docker run -t owasp/zap2docker-stable zap-api-scan.py \
-t https://api.example.com/openapi.json \
-f openapi
Nuclei
nuclei -u https://staging.app.example.com \
-severity critical,high \
-exit-code 1
DAST-Einschränkungen:
- Nur für laufende Applikationen
- Staging-Umgebung verwenden (nie Produktion!)
- Authentifizierte Scans: komplexer zu konfigurieren
SCA: Software Composition Analysis
Snyk
# GitHub Action:
- name: Snyk Security Scan
uses: snyk/actions/node@master
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
with:
args: --severity-threshold=high
Trivy (Container + Filesystem + SBOM)
# Filesystem-Scan:
trivy fs --exit-code 1 --severity CRITICAL,HIGH .
# SBOM generieren (CycloneDX):
trivy sbom --format cyclonedx -o sbom.json .
GitHub Dependabot
# .github/dependabot.yml:
updates:
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "weekly"
# Erstellt automatisch PRs für Security-Updates!
Secrets-Detection
GitLeaks (Pre-commit + CI)
# .github/workflows/gitleaks.yml:
- name: Detect secrets
uses: gitleaks/gitleaks-action@v2
# .pre-commit-config.yaml:
repos:
- repo: https://github.com/gitleaks/gitleaks
hooks:
- id: gitleaks
TruffleHog (Git-History-Suche)
trufflehog git https://github.com/company/repo.git \
--only-verified --json > secrets-found.json
Häufig gefundene Secrets:
- AWS Access Keys
- Stripe/PayPal API Keys
- Database Connection Strings
- Private SSH Keys
- JWT-Signing-Secrets
Secret-Management Best Practice:
- Produktions-Secrets: Vault (HashiCorp) oder Cloud KMS
- CI/CD: GitHub Secrets, GitLab CI Variables
- Lokal: .env-Dateien NIEMALS in Git commiten
IaC-Scanning
Checkov
- name: Checkov IaC Scan
uses: bridgecrewio/checkov-action@master
with:
directory: infrastructure/
framework: terraform
# Typische Findings:
# CKV_AWS_20: S3 Bucket ohne Verschlüsselung
# CKV_AWS_18: S3 Access Logging deaktiviert
# CKV_AZURE_13: Subnetz ohne NSG
tfsec (Terraform)
tfsec . --format sarif --out tfsec.sarif
# SARIF importierbar in GitHub Security Tab
OPA/Rego (Policy as Code)
# Kein privilegierter Container erlaubt:
package kubernetes.admission
deny[msg] {
input.request.kind.kind == "Pod"
container := input.request.object.spec.containers[_]
container.securityContext.privileged == true
msg := "Privilegierter Container nicht erlaubt!"
}
DevSecOps-Reifegradmodell
Stufe 1 (Monat 1-2)
- Secrets-Detection (GitLeaks Pre-commit)
- SCA (Dependabot oder Snyk kostenlos)
- Dependency Updates automatisch
Stufe 2 (Monat 3-4)
- SAST in CI/CD (Semgrep)
- OWASP ZAP gegen Staging
- Findings im Ticket-System tracken
Stufe 3 (Monat 5-6)
- IaC-Scanning (Checkov/tfsec)
- Container-Images (Trivy)
- SBOM für alle Releases
Stufe 4 (Monat 7-12)
- Threat Modeling für neue Features
- DAST mit Authentifizierung
- Security KPIs: MTTR für Schwachstellen
Compliance-Mapping
| Framework | Anforderung |
|---|---|
| ISO 27001 | A-8.25 (Secure Development), A-8.26 (App-Security) |
| NIS2 | Art. 21 (Sicherheit in der Lieferkette) |
| DSGVO | Art. 25 (Privacy by Design and by Default) |