Skip to content

security_malware_scanner

GitHub Actions edited this page Jan 2, 2026 · 1 revision

Malware Scanner - ThemisDB Security

Version: v1.3.0
Stand: Dezember 2025
Status: ✅ Implementiert (Audit-Anforderung)
Kategorie: 🔒 Security


📑 Inhaltsverzeichnis


📋 Übersicht

Der ThemisDB Malware Scanner ist eine Sicherheitskomponente in der Content-Ingestion-Pipeline. Er prüft alle eingehenden Dateien auf Schadsoftware, bevor diese in der Datenbank gespeichert werden.

Compliance-Anforderungen

Anforderung Standard Status
Malware Protection BSI C5 (OPS-12) ✅ Implementiert
Controls against malware ISO 27001 A.12.2.1 ✅ Implementiert
Supply chain security NIS2 Art. 21(2)(d) ✅ Implementiert
Security monitoring SOC 2 CC6.8 ✅ Implementiert

🏗️ Architektur

┌─────────────────────────────────────────────────────────────┐
│                    Content Import Request                    │
└─────────────────────────────────────────────────────────────┘
                              │
                              ▼
┌─────────────────────────────────────────────────────────────┐
│                  MalwareFilterManager                        │
│  ┌─────────────┐  ┌─────────────┐  ┌─────────────────────┐ │
│  │ Signature   │  │  ClamAV     │  │  Custom Scanner     │ │
│  │  Scanner    │  │  (Optional) │  │    (Extensible)     │ │
│  │ (Built-in)  │  │             │  │                     │ │
│  └─────────────┘  └─────────────┘  └─────────────────────┘ │
└─────────────────────────────────────────────────────────────┘
                              │
              ┌───────────────┴───────────────┐
              │                               │
              ▼                               ▼
     ┌────────────────┐              ┌────────────────┐
     │   BLOCKED      │              │    ALLOWED     │
     │  (Threat found)│              │ (Content clean)│
     └────────────────┘              └────────────────┘
              │                               │
              ▼                               ▼
     ┌────────────────┐              ┌────────────────┐
     │  Audit Log     │              │  Store Content │
     │  (SECURITY)    │              │  + Audit Log   │
     └────────────────┘              └────────────────┘

🔧 Konfiguration

YAML-Konfiguration

# config/security.yaml
malware_scan:
  enabled: true                      # Master-Schalter
  block_on_threat: true              # Uploads bei Bedrohung blockieren
  block_threshold: MEDIUM            # Minimum-Level für Blockierung (CLEAN, LOW, MEDIUM, HIGH, CRITICAL)
  scan_all_files: true               # Alle Dateien scannen (nicht nur ausführbare)
  max_scan_size_mb: 100              # Maximale Dateigröße für Scan (MB)
  scan_timeout_seconds: 30           # Timeout pro Scanner
  require_all_scanners: false        # Alle Scanner müssen bestehen
  audit_logging: true                # Scan-Ergebnisse loggen
  
  # MIME-Types, die übersprungen werden
  skip_mime_types: []
  
  # Aktivierte Scanner (leer = alle)
  enabled_scanners:
    - SignatureScanner
    - ClamAV                         # Optional, falls ClamAV installiert

# ClamAV-Konfiguration (optional)
clamav:
  host: "127.0.0.1"
  port: 3310

JSON-Konfiguration

{
  "malware_scan": {
    "enabled": true,
    "block_on_threat": true,
    "block_threshold": "MEDIUM",
    "scan_all_files": true,
    "max_scan_size_mb": 100,
    "scan_timeout_seconds": 30,
    "require_all_scanners": false,
    "audit_logging": true,
    "skip_mime_types": [],
    "enabled_scanners": ["SignatureScanner", "ClamAV"]
  }
}

📊 Threat Levels

Level Beschreibung Standardaktion
CLEAN Keine Bedrohung erkannt Zulassen
LOW Potenziell unerwünscht (PUA) Zulassen + Warnung
MEDIUM Verdächtig (Signatur-Match) Blockieren (Standard)
HIGH Malware erkannt Blockieren
CRITICAL Bekannte gefährliche Malware Blockieren

🔍 Scanner-Backends

1. SignatureScanner (Built-in)

Der integrierte Signatur-Scanner erkennt:

  • Ausführbare in Dokumenten: PE (Windows), ELF (Linux), Mach-O (macOS) Header in nicht-ausführbaren MIME-Types
  • Doppelte Dateiendungen: z.B. report.pdf.exe
  • Archivbomben: Verdächtige verschachtelte Archive (ZIP-Bomben)
  • Bekannte Malware-Signaturen: EICAR Test, Ransomware-Muster
  • Verdächtige Muster: PowerShell-Encoded, Office-Makros

Eigene Signaturen hinzufügen

// C++ API
auto scanner = std::make_unique<SignatureScanner>();
scanner->addSignature(
    "Custom_Malware",           // Name
    "4D616C776172655369676E",   // Hex-Pattern
    0,                          // Offset (0 = Start, -1 = überall)
    ThreatLevel::HIGH           // Threat Level
);
malware_filter->registerScanner(std::move(scanner));

2. ClamAV Scanner (Optional)

Verbindet sich mit einem ClamAV-Daemon für professionelles AV-Scanning.

Installation (Ubuntu/Debian)

# ClamAV installieren
sudo apt-get install clamav clamav-daemon

# Signaturen aktualisieren
sudo freshclam

# Daemon starten
sudo systemctl start clamav-daemon
sudo systemctl enable clamav-daemon

# Status prüfen
clamdscan --ping

Installation (Docker)

# docker-compose.yml
services:
  clamav:
    image: clamav/clamav:latest
    ports:
      - "3310:3310"
    volumes:
      - clamav-data:/var/lib/clamav
    restart: unless-stopped

volumes:
  clamav-data:

3. Custom Scanner

Eigene Scanner können durch Implementierung des IMalwareScanner-Interfaces hinzugefügt werden:

class MyCustomScanner : public IMalwareScanner {
public:
    std::string getName() const override { return "MyScanner"; }
    bool isAvailable() const override { return true; }
    
    ScanResult scan(
        const std::string& data,
        const std::string& filename,
        const std::string& mime_type
    ) override {
        ScanResult result;
        result.scanner_name = getName();
        // Eigene Scan-Logik hier
        return result;
    }
    
    std::string getVersion() const override { return "1.0"; }
    std::optional<std::chrono::system_clock::time_point> getLastUpdate() const override {
        return std::nullopt;
    }
};

📈 Metriken (Prometheus)

# HELP themis_malware_scans_total Total number of malware scans
# TYPE themis_malware_scans_total counter
themis_malware_scans_total 12345

# HELP themis_malware_clean_scans_total Number of clean scans
# TYPE themis_malware_clean_scans_total counter
themis_malware_clean_scans_total 12340

# HELP themis_malware_threats_detected_total Number of threats detected
# TYPE themis_malware_threats_detected_total counter
themis_malware_threats_detected_total 5

# HELP themis_malware_blocked_uploads_total Number of blocked uploads
# TYPE themis_malware_blocked_uploads_total counter
themis_malware_blocked_uploads_total 3

# HELP themis_malware_scan_errors_total Number of scan errors
# TYPE themis_malware_scan_errors_total counter
themis_malware_scan_errors_total 2

# HELP themis_malware_bytes_scanned_total Total bytes scanned
# TYPE themis_malware_bytes_scanned_total counter
themis_malware_bytes_scanned_total 1073741824

# HELP themis_malware_scan_duration_ms_total Total scan time in milliseconds
# TYPE themis_malware_scan_duration_ms_total counter
themis_malware_scan_duration_ms_total 45678

📝 Audit-Logging

Alle Scan-Ergebnisse werden im Audit-Log erfasst:

{
  "timestamp": "2025-12-02T20:45:00Z",
  "event_type": "MALWARE_SCAN",
  "severity": "HIGH",
  "content_id": "abc123",
  "filename": "document.pdf",
  "file_size": 1048576,
  "file_hash": "sha256:abc...",
  "scan_result": {
    "clean": false,
    "highest_threat": "HIGH",
    "scanners_used": 2,
    "scanners_detected": 1,
    "total_duration_ms": 150,
    "scanner_results": [
      {
        "scanner_name": "SignatureScanner",
        "clean": true,
        "threat_level": "CLEAN"
      },
      {
        "scanner_name": "ClamAV",
        "clean": false,
        "threat_level": "HIGH",
        "threat_name": "Win.Trojan.Generic",
        "threat_category": "virus"
      }
    ]
  },
  "action": "BLOCKED"
}

🔒 Best Practices

1. Defense in Depth

# Mehrere Scanner kombinieren
enabled_scanners:
  - SignatureScanner    # Schnell, eingebaut
  - ClamAV              # Umfassende Signaturen

2. Regelmäßige Updates

# ClamAV Signaturen täglich aktualisieren
0 3 * * * /usr/bin/freshclam --quiet

3. Monitoring

# Alerting bei hoher Erkennungsrate
alert: MalwareDetectionSpike
expr: rate(themis_malware_threats_detected_total[5m]) > 0.1
for: 5m
labels:
  severity: critical
annotations:
  summary: "Ungewöhnlich viele Malware-Erkennungen"

4. Quarantäne (Optional)

Blockierte Dateien können für weitere Analyse aufbewahrt werden:

quarantine:
  enabled: true
  path: /var/themis/quarantine
  max_age_days: 30

🧪 Testing

EICAR Testdatei

Der EICAR-Test ist ein standardisierter, harmloser Malware-Test:

# EICAR-Testdatei erstellen
echo 'X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*' > eicar.txt

# Upload testen (sollte blockiert werden)
curl -X POST http://localhost:8765/content/import \
  -H "Content-Type: application/json" \
  -d '{
    "content": {
      "id": "test-eicar",
      "mime_type": "text/plain",
      "filename": "eicar.txt"
    }
  }' \
  --data-binary @eicar.txt

Erwartete Antwort:

{
  "status": "error",
  "message": "Content blocked: EICAR_Test (SignatureScanner)"
}

🔗 Referenzen


Letzte Aktualisierung: Dezember 2025
Dokumentverantwortlicher: ThemisDB Security Team

ThemisDB Dokumentation

Version: 1.3.0 | Stand: Dezember 2025


📋 Schnellstart


🏗️ Architektur


🗄️ Basismodell


💾 Storage & MVCC


📇 Indexe & Statistiken


🔍 Query & AQL


💰 Caching


📦 Content Pipeline


🔎 Suche


⚡ Performance & Benchmarks


🏢 Enterprise Features


✅ Qualitätssicherung


🧮 Vektor & GNN


🌍 Geo Features


🛡️ Sicherheit & Governance

Authentication

Schlüsselverwaltung

Verschlüsselung

TLS & Certificates

PKI & Signatures

PII Detection

Vault & HSM

Audit & Compliance

Security Audits

Gap Analysis


🚀 Deployment & Betrieb

Docker

Observability

Change Data Capture

Operations


💻 Entwicklung

API Implementations

Changefeed

Security Development

Development Overviews


📄 Publikation & Ablage


🔧 Admin-Tools


🔌 APIs


📚 Client SDKs


📊 Implementierungs-Zusammenfassungen


📅 Planung & Reports


📖 Dokumentation


📝 Release Notes


📖 Styleguide & Glossar


🗺️ Roadmap & Changelog


💾 Source Code Documentation

Main Programs

Source Code Module


🗄️ Archive


🤝 Community & Support


Vollständige Dokumentation: https://makr-code.github.io/ThemisDB/

Clone this wiki locally