🔍 Dependency Scanning Konzept - easySale¶
Executive Summary¶
Status: ✅ IMPLEMENTIERT (24.02.2026)
Priorität: 🟠 HOCH
Aufwand: ~3 Stunden (abgeschlossen)
OWASP Kategorie: A06:2021 - Vulnerable and Outdated Components
Aktuelle Situation¶
⚠️ KRITISCH: Im Scan wurden 32 Vulnerabilities in Cloud Functions gefunden: - 2 Critical: fast-xml-parser, form-data - 28 High: axios, qs, xlsx, jws, node-forge, minimatch, ... - 2 Moderate: js-yaml, lodash
Betroffene Produktiv-Dependencies:
- axios: DoS via proto in mergeConfig
- qs: DoS via arrayLimit bypass (wird von Express verwendet!)
- xlsx: Prototype Pollution + ReDoS
Risiken: - Denial of Service (DoS) Angriffe - Prototype Pollution - Remote Code Execution (RCE) bei kritischen Schwachstellen - Kostenexplosion durch Cloud Functions Abuse
Was ist Dependency Scanning?¶
Dependency Scanning ist die automatische Überprüfung von Projekt-Dependencies auf:
- Bekannte Sicherheitslücken (CVEs)
- Abgleich mit NIST NVD, GitHub Advisory Database
-
CVSS Score Bewertung (0.0 - 10.0)
-
Veraltete Packages
- Breaking Changes in neuen Versionen
-
End-of-Life (EOL) Pakete
-
Lizenz-Compliance
- GPL, MIT, Apache Lizenzen
-
Kommerzielle Nutzung erlaubt?
-
Supply Chain Angriffe
- Kompromittierte Maintainer Accounts
- Malicious Packages (Typosquatting)
Warum ist es wichtig?¶
Statistiken (2024)¶
- 84% aller Anwendungen enthalten mindestens 1 Vulnerability
- 60% der Breaches passieren über bekannte, ungepatchte Schwachstellen
- Durchschnittlich 528 Dependencies pro Node.js Projekt (indirekt!)
Konsequenzen bei Nicht-Umsetzung¶
| Risiko | Wahrscheinlichkeit | Impact | Beispiel |
|---|---|---|---|
| DoS via axios | HOCH | HOCH | Cloud Functions werden überlastet |
| Prototype Pollution (xlsx) | ~~MITTEL~~ | ~~KRITISCH~~ | ~~Code Injection bei Excel-Import~~ → ✅ Behoben: xlsx durch exceljs ersetzt |
| Supply Chain Attack | NIEDRIG | KRITISCH | Malicious Code in Dependencies |
Reale Beispiele¶
- Log4Shell (2021): Kritische RCE in log4j → Millionen betroffene Apps
- event-stream (2018): Cryptocurrency Stealer in npm Package
- colors.js/faker (2022): Maintainer sabotiert eigene Packages
Konzept: Multi-Layer Dependency Scanning¶
Layer 1: Lokale Tools (Entwickler)¶
Zweck: Sofortiges Feedback beim Development
Node.js (Cloud Functions)¶
# Native npm Audit
npm audit # Scan
npm audit fix # Auto-Fix (Safe)
npm audit fix --force # Breaking Changes (Vorsicht!)
# Detaillierte Analyse
npm audit --json > audit.json
npm outdated # Veraltete Packages
Konfiguration: package.json
{
"scripts": {
"audit": "npm audit --audit-level=moderate",
"audit:fix": "npm audit fix",
"audit:report": "npm audit --json > vulnerability-report.json"
}
}
Dart/Flutter (Apps)¶
# Pub Security Check
dart pub outdated # Veraltete Packages
dart pub upgrade --dry-run # Was würde geupdatet?
# Mit Pana (Package Analysis Tool)
dart pub global activate pana
pana --no-warning .
Konfiguration: Automatisch via pubspec.yaml
Layer 2: CI/CD Pipeline (GitHub Actions)¶
Zweck: Automatische Prüfung bei jedem Push/PR
Workflow 1: Node.js Dependency Scan¶
Datei: .github/workflows/dependency-scan-functions.yml
name: 🔍 Dependency Scan - Cloud Functions
on:
push:
branches: [main, develop]
paths:
- 'functions/package*.json'
pull_request:
paths:
- 'functions/package*.json'
schedule:
# Täglich um 3 Uhr UTC
- cron: '0 3 * * *'
workflow_dispatch:
jobs:
npm-audit:
runs-on: ubuntu-latest
defaults:
run:
working-directory: functions
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'npm'
cache-dependency-path: functions/package-lock.json
- name: Install Dependencies
run: npm ci
- name: Run npm audit
run: npm audit --audit-level=moderate
continue-on-error: true
id: npm-audit
- name: Generate Audit Report
if: always()
run: npm audit --json > npm-audit-report.json
- name: Upload Audit Report
if: always()
uses: actions/upload-artifact@v4
with:
name: npm-audit-report
path: functions/npm-audit-report.json
retention-days: 30
- name: Check for Critical Vulnerabilities
run: |
CRITICAL=$(npm audit --json | jq '.metadata.vulnerabilities.critical')
HIGH=$(npm audit --json | jq '.metadata.vulnerabilities.high')
if [ "$CRITICAL" -gt 0 ]; then
echo "❌ $CRITICAL critical vulnerabilities found!"
exit 1
elif [ "$HIGH" -gt 5 ]; then
echo "⚠️ $HIGH high vulnerabilities found (threshold: 5)"
exit 1
else
echo "✅ No critical vulnerabilities"
fi
snyk-scan:
runs-on: ubuntu-latest
if: github.event_name != 'schedule' # Nur bei Push/PR
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Run Snyk Security Scan
uses: snyk/actions/node@master
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
with:
args: --severity-threshold=high --file=functions/package.json
continue-on-error: true
- name: Upload Snyk Report
if: always()
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: snyk.sarif
Workflow 2: Flutter Dependency Scan¶
Datei: .github/workflows/dependency-scan-flutter.yml
name: 🔍 Dependency Scan - Flutter Apps
on:
push:
branches: [main, develop]
paths:
- 'apps/*/pubspec.yaml'
- 'packages/*/pubspec.yaml'
pull_request:
paths:
- 'apps/*/pubspec.yaml'
schedule:
- cron: '0 4 * * *' # Täglich um 4 Uhr UTC
workflow_dispatch:
jobs:
pub-outdated-check:
runs-on: ubuntu-latest
strategy:
matrix:
project:
- apps/shop_system
- apps/erp_system
- packages/shared
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: '3.24.0'
channel: 'stable'
- name: Get Dependencies
working-directory: ${{ matrix.project }}
run: flutter pub get
- name: Check Outdated Packages
working-directory: ${{ matrix.project }}
run: |
flutter pub outdated --json > outdated.json
cat outdated.json
- name: Analyze with Pana
run: |
dart pub global activate pana
cd ${{ matrix.project }}
pana --no-warning --json > pana-report.json
continue-on-error: true
- name: Upload Reports
if: always()
uses: actions/upload-artifact@v4
with:
name: flutter-scan-${{ matrix.project }}
path: |
${{ matrix.project }}/outdated.json
${{ matrix.project }}/pana-report.json
retention-days: 30
- name: Check for Critical Outdated Packages
working-directory: ${{ matrix.project }}
run: |
# Parse outdated.json und prüfe auf kritische Versionen
# (Custom Script erforderlich)
echo "✅ Outdated check completed"
Layer 3: GitHub Dependabot (Continuous Monitoring)¶
Zweck: Automatische PRs für Dependency Updates
Konfiguration¶
Datei: .github/dependabot.yml
version: 2
updates:
# Cloud Functions (npm)
- package-ecosystem: "npm"
directory: "/functions"
schedule:
interval: "weekly"
day: "monday"
time: "03:00"
open-pull-requests-limit: 10
reviewers:
- "stefanhafner"
labels:
- "dependencies"
- "security"
versioning-strategy: increase-if-necessary
allow:
- dependency-type: "all"
ignore:
# Breaking Changes nur manuell
- dependency-name: "firebase-admin"
update-types: ["version-update:semver-major"]
- dependency-name: "firebase-functions"
update-types: ["version-update:semver-major"]
# Shop System (pub)
- package-ecosystem: "pub"
directory: "/apps/shop_system"
schedule:
interval: "weekly"
day: "tuesday"
time: "03:00"
open-pull-requests-limit: 10
reviewers:
- "stefanhafner"
labels:
- "dependencies"
- "flutter"
# ERP System (pub)
- package-ecosystem: "pub"
directory: "/apps/erp_system"
schedule:
interval: "weekly"
day: "tuesday"
time: "03:00"
open-pull-requests-limit: 10
reviewers:
- "stefanhafner"
labels:
- "dependencies"
- "flutter"
# Shared Package (pub)
- package-ecosystem: "pub"
directory: "/packages/shared"
schedule:
interval: "weekly"
day: "tuesday"
time: "03:00"
reviewers:
- "stefanhafner"
labels:
- "dependencies"
- "shared"
# GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "monthly"
reviewers:
- "stefanhafner"
labels:
- "dependencies"
- "ci-cd"
Features: - ✅ Automatische PRs für Security Updates - ✅ Wöchentliche Checks (konfigurierbar) - ✅ Grouped PRs für zusammengehörige Updates - ✅ Auto-Review Assignment - ✅ Breaking Changes können ignoriert werden
Layer 4: Advanced Tools (Optional)¶
Snyk (Empfohlen)¶
Warum Snyk? - ✅ Bessere Vulnerability Database als npm audit - ✅ Fix PRs mit Kontext - ✅ License Compliance Check - ✅ Container Scanning (für Docker) - ✅ KOSTENLOS für Open Source & kleine Teams
Setup:
1. Account erstellen: https://snyk.io
2. GitHub Integration aktivieren
3. SNYK_TOKEN als GitHub Secret hinzufügen
4. Workflow ist bereits vorbereitet (siehe oben)
OWASP Dependency-Check¶
Zweck: NIST NVD Integration, mehr CVE Details
# .github/workflows/dependency-scan-functions.yml (zusätzlich)
- name: OWASP Dependency-Check
uses: dependency-check/Dependency-Check_Action@main
with:
project: 'easySale-Functions'
path: 'functions'
format: 'HTML'
args: >
--enableRetired
--failOnCVSS 7
- name: Upload OWASP Report
uses: actions/upload-artifact@v4
with:
name: owasp-report
path: reports
Trivy (Container Security)¶
Nur relevant wenn Docker verwendet wird:
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
scan-type: 'fs'
scan-ref: 'functions'
format: 'sarif'
output: 'trivy-results.sarif'
Implementierungsplan¶
Phase 1: Sofortmaßnahmen (Tag 1)¶
Priorität: 🔴 KRITISCH
-
Akute Vulnerabilities fixen
-
Kritische Packages manuell updaten
axios: Version 1.7.9+ (fix für GHSA-43fc-jf86-j433)qs: Version 6.14.2+ (fix für GHSA-6rw7-vpxm-498p)-
xlsx: ✅ Ersetzt durchexceljs -
Testen & Deployen
Erwartetes Ergebnis: ~20-25 Vulnerabilities behoben
Phase 2: GitHub Actions Setup (Tag 1-2)¶
Priorität: 🟠 HOCH
-
Verzeichnis erstellen
-
Workflows erstellen
dependency-scan-functions.yml-
dependency-scan-flutter.yml -
Secrets konfigurieren (optional)
- GitHub Settings → Secrets → New repository secret
-
SNYK_TOKEN(wenn Snyk verwendet wird) -
Test Workflow
Erwartetes Ergebnis: CI/CD prüft automatisch Dependencies
Phase 3: Dependabot aktivieren (Tag 2)¶
Priorität: 🟠 HOCH
-
Dependabot Config erstellen
-
GitHub Settings prüfen
- Repository → Settings → Code security and analysis
- ✅ Dependabot alerts: Enabled
- ✅ Dependabot security updates: Enabled
-
✅ Dependabot version updates: Enabled
-
Erstes Dependabot Run triggern
- Passiert automatisch nach Config-Merge
- Oder: Settings → Insights → Dependency graph → Dependabot
Erwartetes Ergebnis: Auto-PRs für Updates
Phase 4: Monitoring & Prozess (Tag 3)¶
Priorität: 🟡 MITTEL
- Notification Setup
- GitHub Settings → Notifications
- ✅ Dependabot alerts: Email
-
✅ Security alerts: Email
-
PR Review Process definieren
-
Dokumentation updaten
- Dieses Dokument in README.md verlinken
- Security Policy erstellen (SECURITY.md)
Erwartetes Ergebnis: Nachhaltiger Prozess etabliert
Workflow-Beispiele¶
Szenario 1: Neue kritische Schwachstelle in axios¶
Was passiert:
- GitHub meldet:
- Email: "Security alert: axios (GHSA-XXXX)"
-
Banner im Repository
-
Dependabot erstellt:
- PR: "Bump axios from 1.6.7 to 1.7.9"
- Beschreibung mit CVE Details
-
Changelog Link
-
GitHub Action läuft:
- npm audit im PR
-
✅ Shows: "Fixed 1 vulnerability"
-
Du prüfst & merged:
- Review Changelog
- Tests laufen automatisch
- Merge PR
- Deploy zu Production
Zeitaufwand: 5-10 Minuten
Szenario 2: Flutter Package Update verfügbar¶
Was passiert:
- Dependabot erstellt:
- PR: "Bump firebase_auth from 6.1.4 to 6.2.0"
-
Release Notes von firebase_auth
-
Flutter Workflow läuft:
flutter pub getflutter analyze-
flutter test -
Bei Breaking Changes:
- Dependabot ignoriert (Major Updates konfiguriert)
- Manuelles Update erforderlich
- Migration Guide beachten
Zeitaufwand: 2-5 Minuten (Minor), 30-60 Min (Major)
Metrics & KPIs¶
Tracking¶
Dashboard Optionen: 1. GitHub Insights: - Repository → Insights → Dependency graph - Security Advisories Count - Dependabot PR Count
-
Custom Badge (README.md):
-
Snyk Dashboard:
- Vulnerability Trends
- Fix Rate
- Mean Time To Fix (MTTF)
Ziele¶
| Metrik | IST (Feb 2026) | Ziel (März 2026) | Ziel (April 2026) |
|---|---|---|---|
| Critical Vulns | 2 | 0 | 0 |
| High Vulns | 28 | <5 | <3 |
| Moderate Vulns | 2 | <10 | <5 |
| Outdated Packages | ? | <20% | <10% |
| MTTF (Days) | ∞ | <7 | <3 |
Kosten & Ressourcen¶
Zeit Investment¶
| Phase | Einmalig | Wöchentlich | Monatlich |
|---|---|---|---|
| Setup | 3h | - | - |
| Initial Fixes | 2-4h | - | - |
| PR Reviews | - | 30-60 Min | - |
| Major Updates | - | - | 2-4h |
| Gesamt Jahr 1 | 5-7h | 2-4h | 2-4h |
Tool Kosten¶
| Tool | Kosten | Nutzen |
|---|---|---|
| npm audit | Kostenlos | ✅ Basis Scanning |
| Dependabot | Kostenlos | ✅ Auto-PRs |
| GitHub Actions | Kostenlos* | ✅ CI/CD Integration |
| Snyk (Free Tier) | Kostenlos | ✅ Erweiterte Scans |
| Snyk (Team) | $98/Monat | 🔸 Optional für große Teams |
* GitHub Actions: 2000 Minuten/Monat kostenlos für private Repos
Empfehlung: Bleib bei kostenlosen Tools, sehr ausreichend!
FAQ¶
Warum nicht nur Dependabot?¶
Dependabot erstellt PRs, aber: - ❌ Keine Enforcement (kann ignoriert werden) - ❌ Kein Blocking bei kritischen Vulns - ❌ Keine detaillierten Reports
Lösung: Kombination mit GitHub Actions für CI/CD Checks
Was wenn npm audit fix Breaking Changes macht?¶
Best Practice:
1. Immer erst npm audit fix (ohne --force)
2. Verbleibende Vulns manuell prüfen
3. Tests lokal laufen lassen
4. Bei Breaking Changes: Migration planen
Notfall: Package Version pinnen bis Fix verfügbar:
Wie mit "No fix available" umgehen?¶
Optionen (Priorität):
1. Alternative Package suchen
- Beispiel: xlsx → exceljs (aktiver maintained)
2. Custom Patch erstellen (patch-package)
3. Risiko akzeptieren mit Mitigation:
- Input Validation
- Firewall Rules
- Rate Limiting
4. Package forken & selbst fixen
Für xlsx speziell:
Soll jede Dependabot PR sofort gemerged werden?¶
Nein! Prioritäten:
| Typ | Action | Zeitrahmen |
|---|---|---|
| Critical Security | Sofort mergen & deployen | <24h |
| High Security | Review & merge | <48h |
| Minor Version | Weekly Batch | <1 Woche |
| Major Version | Plan Migration | Nach Bedarf |
Checkliste: Sofort-Implementation¶
Heute noch erledigen:
- [ ]
cd functions && npm audit fix - [ ]
axiosmanuell auf 1.7.9+ updaten - [ ]
qsmanuell auf 6.14.2+ updaten - [ ] Tests laufen lassen
- [ ] Functions deployen
- [ ]
.github/workflows/Verzeichnis erstellen - [ ]
dependency-scan-functions.ymlerstellen - [ ]
dependency-scan-flutter.ymlerstellen - [ ]
.github/dependabot.ymlerstellen - [ ] Commit & Push
- [ ] GitHub Settings: Dependabot aktivieren
- [ ] Notifications konfigurieren
- [ ] DEPENDENCY_SCANNING_KONZEPT.md in SECURITY_IMPLEMENTATION.md verlinken
Nächste Woche:
- [ ] Erste Dependabot PRs reviewen
- [ ] Workflow Outputs prüfen (GitHub Actions → Artifacts)
- [ ] Snyk Account anlegen (optional)
- [ ] SECURITY.md erstellen
- [ ] Team briefen zum PR Review Process
Ressourcen¶
Dokumentation¶
Vulnerability Databases¶
Tools¶
- npm audit: Built-in
- Dependabot: GitHub native
- Snyk: https://snyk.io
- Socket.dev: https://socket.dev (Supply Chain)
- Renovate: https://renovatebot.com (Alternative zu Dependabot)
Zusammenfassung¶
Was wird erreicht?¶
✅ Automatische Erkennung von Vulnerabilities
✅ Proaktive Updates via Dependabot PRs
✅ CI/CD Integration blockiert kritische Schwachstellen
✅ Compliance mit OWASP A06:2021
✅ Transparenz durch Reports & Dashboards
✅ Kosteneffizienz durch Automation (nur Free-Tier Tools)
ROI (Return on Investment)¶
Investment: - Setup: 3 Stunden - Wartung: ~2 Stunden/Monat
Return: - ❌ Verhindert Sicherheitsvorfälle (unbezahlbar) - ⚡ Reduziert technische Schulden - 📊 Verbessert Code Quality - 🛡️ Compliance mit Security Standards - 🚀 Schnelleres Onboarding neuer Dependencies
Break-Even: Nach 1 verhinderten Security Incident
✅ Implementierungsstatus¶
Implementierte Komponenten (24.02.2026)¶
1. GitHub Actions Workflows¶
.github/workflows/dependency-scan-flutter.yml
- ✅ Scannt alle Flutter Projekte (shop_system, erp_system, shared)
- ✅ Läuft täglich um 4:00 UTC
- ✅ Führt flutter pub outdated aus
- ✅ Generiert JSON Reports als Artifacts
- ✅ Läuft auch bei Push/PR auf pubspec.yaml Änderungen
.github/workflows/dependency-scan-functions.yml
- ✅ Scannt Cloud Functions mit npm audit
- ✅ Läuft täglich um 3:00 UTC
- ✅ Blockiert bei Critical Vulnerabilities (exit 1)
- ✅ Warnt bei > 10 High Vulnerabilities
- ✅ Erstellt detaillierte JSON Reports
- ✅ Kommentiert automatisch auf Pull Requests
2. Dependabot Konfiguration¶
.github/dependabot.yml
- ✅ npm Updates für Cloud Functions (Montags 3:00)
- ✅ pub Updates für Shop System (Dienstags 3:00)
- ✅ pub Updates für ERP System (Mittwochs 3:00)
- ✅ pub Updates für Shared Packages (Donnerstags 3:00)
- ✅ GitHub Actions Updates (Freitags 3:00)
- ✅ Automatische PR-Erstellung mit Labels & Reviewers
- ✅ Gruppierte Updates für Firebase & Google Cloud Packages
- ✅ Ignoriert Major Updates für kritische Firebase Packages
3. Scan-Frequenz¶
| Tool | Flutter Apps | Cloud Functions | GitHub Actions |
|---|---|---|---|
| GitHub Actions | Täglich 4:00 UTC | Täglich 3:00 UTC | - |
| Dependabot | Wöchentlich (Di-Do) | Wöchentlich (Mo) | Wöchentlich (Fr) |
| Trigger | Push/PR auf pubspec.yaml | Push/PR auf package.json | Push/PR auf workflows |
4. Automatisierungen¶
✅ PR-Kommentare: Dependency Scan Results direkt in Pull Requests
✅ Artifacts: 30 Tage Retention für alle Scan Reports
✅ Fail-Fast: CI blockiert bei Critical/High Vulnerabilities
✅ Notifications: GitHub Notifications für neue Dependabot PRs
✅ Reviewers: Automatische Zuweisung an @stefanhafner
Ergebnis¶
🎯 Alle Anforderungen aus dem Konzept sind implementiert: - ✅ Layer 1: Lokale Tools (npm audit, flutter pub outdated) - ✅ Layer 2: GitHub Actions (automatisierte tägliche Scans) - ✅ Layer 3: Dependabot (automatische PRs für Updates) - ✅ Layer 4: Monitoring (Reports & Artifacts)
Nächste Schritte¶
- ✅ ABGESCHLOSSEN: Alle Komponenten implementiert
- 🔄 LAUFEND: Regelmäßige Review der Dependabot PRs
- 📊 OPTIONAL: Integration eines Dashboards (z.B. Snyk)
Erstellt: 24. Februar 2026
Implementiert: 24. Februar 2026
Status: ✅ Vollständig implementiert
Nächster Review: Monatlich (Review von Dependabot PRs)