Zum Inhalt

🔍 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:

  1. Bekannte Sicherheitslücken (CVEs)
  2. Abgleich mit NIST NVD, GitHub Advisory Database
  3. CVSS Score Bewertung (0.0 - 10.0)

  4. Veraltete Packages

  5. Breaking Changes in neuen Versionen
  6. End-of-Life (EOL) Pakete

  7. Lizenz-Compliance

  8. GPL, MIT, Apache Lizenzen
  9. Kommerzielle Nutzung erlaubt?

  10. Supply Chain Angriffe

  11. Kompromittierte Maintainer Accounts
  12. 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

  1. Akute Vulnerabilities fixen

    cd functions
    npm audit fix              # Safe Fixes
    npm audit                  # Verbleibende prüfen
    

  2. Kritische Packages manuell updaten

  3. axios: Version 1.7.9+ (fix für GHSA-43fc-jf86-j433)
  4. qs: Version 6.14.2+ (fix für GHSA-6rw7-vpxm-498p)
  5. xlsx: ✅ Ersetzt durch exceljs

  6. Testen & Deployen

    npm test
    firebase deploy --only functions
    

Erwartetes Ergebnis: ~20-25 Vulnerabilities behoben

Phase 2: GitHub Actions Setup (Tag 1-2)

Priorität: 🟠 HOCH

  1. Verzeichnis erstellen

    mkdir -p .github/workflows
    

  2. Workflows erstellen

  3. dependency-scan-functions.yml
  4. dependency-scan-flutter.yml

  5. Secrets konfigurieren (optional)

  6. GitHub Settings → Secrets → New repository secret
  7. SNYK_TOKEN (wenn Snyk verwendet wird)

  8. Test Workflow

    git add .github/workflows
    git commit -m "feat: Add dependency scanning workflows"
    git push
    # → Workflows werden automatisch ausgeführt
    

Erwartetes Ergebnis: CI/CD prüft automatisch Dependencies

Phase 3: Dependabot aktivieren (Tag 2)

Priorität: 🟠 HOCH

  1. Dependabot Config erstellen

    # .github/dependabot.yml (siehe oben)
    

  2. GitHub Settings prüfen

  3. Repository → Settings → Code security and analysis
  4. ✅ Dependabot alerts: Enabled
  5. ✅ Dependabot security updates: Enabled
  6. ✅ Dependabot version updates: Enabled

  7. Erstes Dependabot Run triggern

  8. Passiert automatisch nach Config-Merge
  9. Oder: Settings → Insights → Dependency graph → Dependabot

Erwartetes Ergebnis: Auto-PRs für Updates

Phase 4: Monitoring & Prozess (Tag 3)

Priorität: 🟡 MITTEL

  1. Notification Setup
  2. GitHub Settings → Notifications
  3. ✅ Dependabot alerts: Email
  4. ✅ Security alerts: Email

  5. PR Review Process definieren

    ## Dependabot PR Checklist
    
    - [ ] Breaking Changes geprüft (CHANGELOG lesen)
    - [ ] Tests lokal ausgeführt
    - [ ] Firebase Emulator getestet (bei functions)
    - [ ] Flutter Build erfolgreich (bei apps)
    - [ ] Merge & Monitor Errors in Production
    

  6. Dokumentation updaten

  7. Dieses Dokument in README.md verlinken
  8. Security Policy erstellen (SECURITY.md)

Erwartetes Ergebnis: Nachhaltiger Prozess etabliert


Workflow-Beispiele

Szenario 1: Neue kritische Schwachstelle in axios

Was passiert:

  1. GitHub meldet:
  2. Email: "Security alert: axios (GHSA-XXXX)"
  3. Banner im Repository

  4. Dependabot erstellt:

  5. PR: "Bump axios from 1.6.7 to 1.7.9"
  6. Beschreibung mit CVE Details
  7. Changelog Link

  8. GitHub Action läuft:

  9. npm audit im PR
  10. ✅ Shows: "Fixed 1 vulnerability"

  11. Du prüfst & merged:

  12. Review Changelog
  13. Tests laufen automatisch
  14. Merge PR
  15. Deploy zu Production

Zeitaufwand: 5-10 Minuten

Szenario 2: Flutter Package Update verfügbar

Was passiert:

  1. Dependabot erstellt:
  2. PR: "Bump firebase_auth from 6.1.4 to 6.2.0"
  3. Release Notes von firebase_auth

  4. Flutter Workflow läuft:

  5. flutter pub get
  6. flutter analyze
  7. flutter test

  8. Bei Breaking Changes:

  9. Dependabot ignoriert (Major Updates konfiguriert)
  10. Manuelles Update erforderlich
  11. 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

  1. Custom Badge (README.md):

    ![Dependencies](https://img.shields.io/badge/dependencies-up%20to%20date-brightgreen)
    ![Vulnerabilities](https://img.shields.io/snyk/vulnerabilities/github/USERNAME/easySale)
    

  2. Snyk Dashboard:

  3. Vulnerability Trends
  4. Fix Rate
  5. 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:

{
  "overrides": {
    "vulnerable-package": "1.2.3"
  }
}

Wie mit "No fix available" umgehen?

Optionen (Priorität): 1. Alternative Package suchen - Beispiel: xlsxexceljs (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:

# Alternative analysieren
npm info exceljs
npm info xlsx-populate

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
  • [ ] axios manuell auf 1.7.9+ updaten
  • [ ] qs manuell auf 6.14.2+ updaten
  • [ ] Tests laufen lassen
  • [ ] Functions deployen
  • [ ] .github/workflows/ Verzeichnis erstellen
  • [ ] dependency-scan-functions.yml erstellen
  • [ ] dependency-scan-flutter.yml erstellen
  • [ ] .github/dependabot.yml erstellen
  • [ ] 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)