Was ist 等保 2.0 (MLPS 2.0) Stufe 3?

Die Multi-Level Protection Scheme (MLPS) 2.0 – auf Chinesisch 等保 2.0 – ist die chinesische Cybersecurity-Pflichtnorm. Für Level 3 (Stufe 3) gelten strenge Anforderungen an die Speicherung von Audit-Logs, insbesondere wenn KI-API-Gateways personenbezogene oder geschäftskritische Daten verarbeiten. Die zentralen Vorgaben:

Architektur: AI API Gateway mit Compliance-konformem Logging

Eine typische Architektur nutzt einen Reverse-Proxy (z. B. Kong, APISIX oder Nginx) vor dem KI-Backend. Anfrage und Antwort werden parallel an einen Log-Collector (Filebeat → Elasticsearch oder direkt WORM-Storage) geschrieben. Wir verwenden in unserem Setup HolySheep AI als Backend, da die API https://api.holysheep.ai/v1 deterministische Latenzen unter 50 ms liefert und sich ideal für zeitkritische Audit-Pipelines eignet.

Code 1: Nginx-Konfiguration mit Audit-Log-Pipeline

# /etc/nginx/conf.d/ai-gateway-audit.conf

Audit-Logging nach 等保 2.0 Stufe 3

log_format mlps_audit escape=json '{"ts":"$time_iso8601",' '"remote_addr":"$remote_addr","user":"$http_x_user_id",' '"method":"$request_method","uri":"$request_uri",' '"status":$status,"bytes":$body_bytes_sent,' '"upstream":"$upstream_addr","latency_ms":$request_time,' '"trace_id":"$request_id"}'; server { listen 443 ssl http2; server_name ai-gateway.example.cn; ssl_certificate /etc/ssl/certs/gateway.crt; ssl_certificate_key /etc/ssl/private/gateway.key; # Audit-Log → WORM-Storage access_log /var/log/mlps/audit.log mlps_audit buffer=32k flush=5s; error_log /var/log/mlps/error.log warn; location /v1/ { # API-Key an HolySheep weiterleiten proxy_pass https://api.holysheep.ai/v1/; proxy_set_header Authorization "Bearer YOUR_HOLYSHEEP_API_KEY"; proxy_set_header X-User-ID $http_x_user_id; proxy_http_version 1.1; proxy_read_timeout 60s; } }

Code 2: Python-Audit-Collector (tamper-proof Hash-Kette)

# audit_collector.py
import hashlib, json, time, os, sys
from datetime import datetime, timezone, timedelta

LOG_FILE   = "/var/log/mlps/audit.log"
WORM_DIR   = "/opt/worm/mlps"
RETENTION  = 180  # Tage Online-Aufbewahrung

CST = timezone(timedelta(hours=8))

def sha256_file(path):
    h = hashlib.sha256()
    with open(path, "rb") as f:
        for chunk in iter(lambda: f.read(8192), b""):
            h.update(chunk)
    return h.hexdigest()

def rotate_and_seal():
    """Tägliche Rotation + Hash-Chain