Security Contract

Wenn Du Dein Haus verlässt, schließt Du ab. Du weißt: Türschloss, Fenster zu, vielleicht Alarmanlage. Ein Security Contract ist die gleiche Vereinbarung für Software - er definiert, welche Sicherheitsmaßnahmen eingehalten werden müssen.

Sicherheit braucht Verbindlichkeit

Sicherheitsanforderungen werden oft vage formuliert: "Das System soll sicher sein." Aber was heißt das konkret? Welche Verschlüsselung? Welche Authentifizierung? Welche Daten dürfen wo gespeichert werden? Ohne klare Vereinbarung bleibt Sicherheit dem Zufall überlassen.

Die Lösung: Der Security Contract

Ein Security Contract macht Sicherheitsanforderungen prüfbar:

Vollständiges Beispiel

Ein Security Contract für einen Zahlungsservice:

# Security Contract: Payment Service
# Version: 1.2.0
# Compliance: PCI-DSS Level 1

contract:
  id: "sec-payment-v1"
  name: "Payment Service Security Contract"
  version: "1.2.0"
  owner: "team-security"
  classification: "critical"

  # Authentifizierung
  authentication:
    type: "oauth2"
    flows:
      - "client_credentials"
      - "authorization_code"
    token_lifetime_seconds: 3600
    refresh_enabled: true

    requirements:
      - "mfa_required_for_admin"
      - "token_must_be_jwt"
      - "signature_algorithm: RS256"

  # Autorisierung
  authorization:
    model: "rbac"  # Role-Based Access Control
    roles:
      - name: "payment_reader"
        permissions: ["read:transactions"]
      - name: "payment_processor"
        permissions: ["read:transactions", "create:payment"]
      - name: "payment_admin"
        permissions: ["*"]

    enforcement:
      - "all_endpoints_require_auth"
      - "principle_of_least_privilege"

  # Verschlüsselung
  encryption:
    transport:
      protocol: "TLS"
      min_version: "1.3"
      cipher_suites:
        - "TLS_AES_256_GCM_SHA384"
        - "TLS_CHACHA20_POLY1305_SHA256"

    at_rest:
      algorithm: "AES-256-GCM"
      key_management: "AWS KMS"
      rotation_days: 90

    sensitive_fields:
      - field: "card_number"
        mask: "****-****-****-{last4}"
        storage: "tokenized"
      - field: "cvv"
        storage: "never_stored"

  # Input Validation
  input_validation:
    - "all_inputs_sanitized"
    - "sql_injection_prevention"
    - "xss_prevention"
    - "max_request_size: 1MB"

  # Audit & Logging
  audit:
    events:
      - "authentication_success"
      - "authentication_failure"
      - "authorization_denied"
      - "payment_created"
      - "payment_failed"
      - "data_exported"

    retention_days: 2555  # 7 Jahre (PCI-DSS)
    immutable: true
    format: "structured_json"

  # Prädikate für Gate-Prüfung
  predicates:
    - id: "has_auth"
      check: "authentication_implemented"
      severity: "critical"

    - id: "has_encryption"
      check: "tls_1_3_enforced"
      severity: "critical"

    - id: "has_input_validation"
      check: "owasp_top10_mitigated"
      severity: "critical"

    - id: "has_audit_logging"
      check: "security_events_logged"
      severity: "high"

    - id: "no_sensitive_data_in_logs"
      check: "pii_masked_in_logs"
      severity: "critical"

Security Gate-Prüfung

Am Release Gate wird der Security Contract besonders streng geprüft:

# Security Gate Check
gate_check:
  gate_id: "G6_RELEASE"
  contract_id: "sec-payment-v1"
  change_class: "critical"

  results:
    - predicate: "has_auth"
      passed: true
      evidence:
        - "OAuth2 implemented"
        - "JWT validation active"
        - "MFA enforced for admin"

    - predicate: "has_encryption"
      passed: true
      evidence:
        - "TLS 1.3 only"
        - "AES-256-GCM for storage"
        - "Card data tokenized"

    - predicate: "has_input_validation"
      passed: true
      evidence:
        - "Parameterized queries"
        - "Content-Security-Policy set"
        - "Input sanitization active"

    - predicate: "no_sensitive_data_in_logs"
      passed: true
      evidence:
        - "PII regex scanner: 0 findings"
        - "Card numbers masked"

  verdict: "PASS"
  approved_by: "security-team"
  timestamp: "2024-01-15T16:00:00Z"

Warum ist das wichtig?

Security Contracts machen Sicherheit messbar und nachweisbar. Statt vager Aussagen gibt es klare Prüfkriterien. Im Mensch + KI-Code Prozess ist der Security Contract bei allen kritischen Änderungen Pflicht - und er wird automatisch gegen den Code verifiziert.

Im Mensch + KI-Code Prozess: Security Contracts sind bei Change Class "Critical" obligatorisch. Sie werden am Gate G6 (Release) durch das Security-Team geprüft und sind Teil des Evidence Packs für Compliance-Audits.