docs: Add comprehensive DSI/RSSI security playbook

Complete security documentation for IT Directors and Security Officers:
- Architecture overview with security layers
- Authentication (HMAC-SHA256 tokens, RBAC)
- Data protection (AES-256-CBC encryption)
- Audit logging (JSONL format, SIEM compatible)
- Network controls (IP allowlist, rate limiting)
- Attack protection (SQL/NoSQL injection, XSS, path traversal)
- Secure deployment guide
- Monitoring and alerting
- Emergency procedures (kill-switch, token revocation)
- Regulatory compliance (RGPD, HDS, ISO 27001)
- Validation checklist

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Dom
2026-01-19 09:01:03 +01:00
parent ae1cb72362
commit 4460b63912

740
docs/PLAYBOOK_DSI_RSSI.md Normal file
View File

@@ -0,0 +1,740 @@
# Playbook DSI/RSSI - RPA Vision V3
**Version:** 1.0
**Date:** 19 janvier 2026
**Classification:** Document technique - Usage interne
**Public cible:** Directeurs des Systèmes d'Information, Responsables Sécurité SI
---
## Table des matières
1. [Résumé exécutif](#1-résumé-exécutif)
2. [Architecture de sécurité](#2-architecture-de-sécurité)
3. [Authentification et autorisation](#3-authentification-et-autorisation)
4. [Protection des données](#4-protection-des-données)
5. [Traçabilité et audit](#5-traçabilité-et-audit)
6. [Contrôle d'accès réseau](#6-contrôle-daccès-réseau)
7. [Protection contre les attaques](#7-protection-contre-les-attaques)
8. [Déploiement sécurisé](#8-déploiement-sécurisé)
9. [Monitoring et alertes](#9-monitoring-et-alertes)
10. [Procédures d'urgence](#10-procédures-durgence)
11. [Conformité réglementaire](#11-conformité-réglementaire)
12. [Checklist de validation](#12-checklist-de-validation)
---
## 1. Résumé exécutif
### 1.1 Présentation
RPA Vision V3 est une solution d'automatisation robotisée des processus (RPA) basée sur la vision par ordinateur. Conçue pour les environnements exigeants (santé, finance, administration), elle intègre nativement des mécanismes de sécurité enterprise-grade.
### 1.2 Points clés sécurité
| Domaine | Capacité | Niveau |
|---------|----------|--------|
| Authentification | Tokens HMAC-SHA256 + RBAC | ✅ Enterprise |
| Chiffrement | AES-256-CBC + PBKDF2 | ✅ Enterprise |
| Audit | JSONL rotatif + 8 types d'événements | ✅ Enterprise |
| Protection API | Rate limiting + IP allowlist | ✅ Enterprise |
| Validation entrées | SQL/NoSQL/XSS protection | ✅ Enterprise |
| Déploiement | 100% on-premise, air-gap compatible | ✅ Enterprise |
### 1.3 Certifications visées
- ISO 27001 (Sécurité de l'information)
- HDS (Hébergeur de Données de Santé) - en préparation
- RGPD compliant by design
---
## 2. Architecture de sécurité
### 2.1 Vue d'ensemble
```
┌─────────────────────────────────────────────────────────────┐
│ COUCHE PRÉSENTATION │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
│ │ VWB Frontend│ │ Agent Chat │ │ Dashboard │ │
│ │ (3000) │ │ (5002) │ │ (5004) │ │
│ └──────┬──────┘ └──────┬──────┘ └──────┬──────┘ │
└─────────┼────────────────┼────────────────┼─────────────────┘
│ │ │
┌─────────┼────────────────┼────────────────┼─────────────────┐
│ ▼ ▼ ▼ │
│ ┌──────────────────────────────────────────────────────┐ │
│ │ MIDDLEWARE SÉCURITÉ │ │
│ │ ┌────────┐ ┌────────┐ ┌────────┐ ┌────────┐ │ │
│ │ │IP Allow│ │ Auth │ │ Rate │ │ Audit │ │ │
│ │ │ list │ │ Tokens │ │ Limit │ │ Log │ │ │
│ │ └────────┘ └────────┘ └────────┘ └────────┘ │ │
│ └──────────────────────────────────────────────────────┘ │
│ COUCHE API (5000) │
└─────────────────────────────────────────────────────────────┘
┌─────────┼───────────────────────────────────────────────────┐
│ ▼ │
│ ┌──────────────────────────────────────────────────────┐ │
│ │ VALIDATION ENTRÉES │ │
│ │ • SQL Injection • Path Traversal │ │
│ │ • NoSQL Injection • XSS Prevention │ │
│ └──────────────────────────────────────────────────────┘ │
│ COUCHE MÉTIER │
└─────────────────────────────────────────────────────────────┘
┌─────────┼───────────────────────────────────────────────────┐
│ ▼ │
│ ┌──────────────────────────────────────────────────────┐ │
│ │ STOCKAGE CHIFFRÉ │ │
│ │ • AES-256-CBC • PBKDF2 (100k iterations) │ │
│ │ • Rotation clés • Fichiers permissions 0600 │ │
│ └──────────────────────────────────────────────────────┘ │
│ COUCHE DONNÉES │
└─────────────────────────────────────────────────────────────┘
```
### 2.2 Modules de sécurité
| Module | Fichier | Lignes | Responsabilité |
|--------|---------|--------|----------------|
| Configuration | `core/security/security_config.py` | 312 | Validation config production |
| Tokens | `core/security/api_tokens.py` | 519 | Auth RBAC HMAC-SHA256 |
| Audit | `core/security/audit_log.py` | 408 | Logging JSONL |
| Rate Limit | `core/security/rate_limiter.py` | 400 | Token bucket algorithm |
| IP Allowlist | `core/security/ip_allowlist.py` | 372 | Whitelist CIDR |
| Validation | `core/security/input_validator.py` | 326 | Sanitisation entrées |
| Middleware | `core/security/flask_security.py` | 257 | Intégration Flask |
| Chiffrement | `server/storage_encrypted.py` | 100 | AES-256-CBC |
**Total : 3,318+ lignes de code sécurité**
---
## 3. Authentification et autorisation
### 3.1 Système de tokens
#### Types de tokens
| Type | Rôle | Permissions | Usage |
|------|------|-------------|-------|
| Admin | `ADMIN` | Lecture + Écriture | Opérations complètes |
| Read-Only | `READ_ONLY` | Lecture seule | Consultation, reporting |
| Anonymous | `ANON` | Aucune | Endpoints publics uniquement |
#### Caractéristiques techniques
- **Algorithme signature** : HMAC-SHA256
- **Expiration** : Configurable (défaut 24h)
- **Révocation** : Dynamique, sans redémarrage
- **Stockage** : Mémoire uniquement (pas de persistence tokens)
#### Sources de tokens acceptées
```
1. Header: Authorization: Bearer <token>
2. Header: X-API-Token: <token>
3. Header: X-Admin-Token: <token> (rétrocompatibilité)
4. Cookie: rpa_token=<token>
5. Query: ?token=<token> (converti en cookie httponly)
```
### 3.2 Matrice RBAC
| Endpoint | Anonymous | Read-Only | Admin |
|----------|-----------|-----------|-------|
| `/health`, `/metrics` | ✅ | ✅ | ✅ |
| `GET /api/workflows/*` | ❌ | ✅ | ✅ |
| `POST /api/workflows/*` | ❌ | ❌ | ✅ |
| `GET /api/analytics/*` | ❌ | ✅ | ✅ |
| `POST /api/execute` | ❌ | ❌ | ✅ |
| `/admin/*` | ❌ | ❌ | ✅ |
### 3.3 Configuration
```bash
# Tokens d'authentification
RPA_TOKEN_ADMIN=<token_admin_64_chars_min>
RPA_TOKEN_READONLY=<token_readonly_64_chars_min>
# Clé de signature
TOKEN_SECRET_KEY=<clé_32_chars_min_complexe>
# Expiration
TOKEN_EXPIRY_HOURS=24
# Mode obligatoire
API_KEY_REQUIRED=true
```
---
## 4. Protection des données
### 4.1 Chiffrement au repos
#### Algorithme
| Paramètre | Valeur |
|-----------|--------|
| Algorithme | AES-256-CBC |
| Dérivation clé | PBKDF2-HMAC-SHA256 |
| Itérations | 100,000 |
| Taille clé | 256 bits |
| IV | 16 bytes aléatoires par fichier |
| Padding | PKCS7 |
#### Format fichier chiffré
```
[Salt 16 bytes][IV 16 bytes][Ciphertext PKCS7-padded]
```
#### Configuration
```bash
# Mot de passe de chiffrement (32+ caractères)
ENCRYPTION_PASSWORD=<mot_de_passe_complexe_32_chars_min>
# Ou fichier de clé externe
ENCRYPTION_KEY_FILE=/secure/path/to/keyfile
```
### 4.2 Données chiffrées
- Sessions utilisateur
- Captures d'écran
- Workflows contenant des données sensibles
- Logs d'exécution détaillés
### 4.3 Données NON chiffrées (par design)
- Index FAISS (embeddings anonymisés)
- Métriques agrégées
- Logs d'audit (pour SIEM)
---
## 5. Traçabilité et audit
### 5.1 Format de log
**Format** : JSONL (JSON Lines) - 1 événement par ligne
```json
{
"timestamp": "2026-01-19T10:30:00.123456Z",
"event_type": "API_ACCESS",
"message": "GET /api/workflows successful",
"user_id": "user_12345",
"ip_address": "192.168.1.xxx",
"endpoint": "/api/workflows",
"method": "GET",
"user_agent": "Mozilla/5.0...",
"token_hash": "a1b2c3d4...",
"success": true,
"metadata": {
"response_time_ms": 45,
"response_status": 200
}
}
```
### 5.2 Types d'événements
| Type | Description | Criticité |
|------|-------------|-----------|
| `AUTHENTICATION` | Connexion/déconnexion | Haute |
| `AUTHORIZATION` | Vérification permissions | Haute |
| `API_ACCESS` | Appel API | Moyenne |
| `SECURITY_VIOLATION` | Tentative non autorisée | Critique |
| `RATE_LIMIT_EXCEEDED` | Dépassement quota | Moyenne |
| `IP_BLOCKED` | IP rejetée | Haute |
| `TOKEN_VALIDATION` | Validation token | Moyenne |
| `SYSTEM_EVENT` | Événement système | Variable |
### 5.3 Configuration audit
```bash
# Répertoire des logs
AUDIT_LOG_DIR=/var/log/rpa-vision/audit
# Rotation
AUDIT_LOG_MAX_SIZE=10485760 # 10 MB
AUDIT_LOG_MAX_FILES=10 # Conservation 10 fichiers
# Anonymisation
AUDIT_HASH_SENSITIVE=true # Hash données sensibles
```
### 5.4 Intégration SIEM
Les logs JSONL sont compatibles avec :
- Splunk
- ELK Stack (Elasticsearch, Logstash, Kibana)
- Graylog
- Azure Sentinel
- AWS CloudWatch
**Exemple Logstash** :
```
input {
file {
path => "/var/log/rpa-vision/audit/*.jsonl"
codec => json
}
}
```
---
## 6. Contrôle d'accès réseau
### 6.1 IP Allowlist
#### Fonctionnalités
- Support IPv4 et IPv6
- Notation CIDR (ex: `192.168.1.0/24`)
- Gestion dynamique (ajout/suppression runtime)
- Support reverse proxy (X-Forwarded-For)
#### Configuration
```bash
# Liste blanche IP (séparées par virgules)
ALLOWED_IPS=127.0.0.1/32,192.168.0.0/16,10.0.0.0/8
# Proxies de confiance
TRUSTED_PROXIES=172.16.0.0/12
# Activer headers proxy
ENABLE_PROXY_HEADERS=true
# Logger les IP bloquées
LOG_BLOCKED_IPS=true
```
### 6.2 Rate Limiting
#### Algorithme Token Bucket
| Paramètre | Défaut | Description |
|-----------|--------|-------------|
| RPM | 60 | Requêtes par minute |
| Burst | 10 | Pic autorisé |
#### Configuration par endpoint
```bash
# Défaut global
DEFAULT_RATE_LIMIT_RPM=60
DEFAULT_RATE_LIMIT_BURST=10
# Par endpoint
RATE_LIMIT_ADMIN_API=30:5 # 30/min, burst 5
RATE_LIMIT_WORKFLOWS=120:10 # 120/min, burst 10
RATE_LIMIT_EXECUTE=30:5 # 30/min, burst 5
RATE_LIMIT_UPLOAD=10:2 # 10/min, burst 2
```
#### Headers de réponse
```
X-RateLimit-Limit: 60
X-RateLimit-Remaining: 45
X-RateLimit-Reset: 1705661400
Retry-After: 30 (si 429)
```
---
## 7. Protection contre les attaques
### 7.1 Injection SQL
**Patterns détectés** :
- `SELECT`, `INSERT`, `UPDATE`, `DELETE`, `DROP`, `CREATE`, `ALTER`
- `UNION` based attacks
- Commentaires SQL (`--`, `#`, `/* */`)
- Échappement quotes
**Action** : Requête rejetée avec code 400
### 7.2 Injection NoSQL
**Patterns détectés** :
- Opérateurs MongoDB (`$where`, `$regex`, `$ne`, `$gt`, `$in`)
- Fonctions JavaScript (`function()`, `eval()`)
**Action** : Requête rejetée avec code 400
### 7.3 XSS (Cross-Site Scripting)
**Protection** :
- Échappement HTML automatique
- Suppression caractères de contrôle
- Content-Security-Policy headers
### 7.4 Path Traversal
**Protection** :
- Validation chemins contre répertoires autorisés
- Rejet de `..`, `~`, liens symboliques externes
### 7.5 Validation des entrées
```python
# Configuration
STRICT_INPUT_VALIDATION=true # Mode strict en production
LOG_SENSITIVE_DATA=false # Ne pas logger données sensibles
MAX_JSON_SIZE=10485760 # 10 MB max
MAX_STRING_LENGTH=10000 # 10k caractères max
```
---
## 8. Déploiement sécurisé
### 8.1 Prérequis
| Composant | Version minimale |
|-----------|------------------|
| Python | 3.10+ |
| Node.js | 18+ |
| OS | Ubuntu 22.04+ / RHEL 8+ |
| RAM | 8 GB minimum |
| Stockage | 50 GB SSD |
### 8.2 Variables d'environnement requises
```bash
# ===== OBLIGATOIRES EN PRODUCTION =====
# Environnement
ENVIRONMENT=production
# Authentification
RPA_TOKEN_ADMIN=<64_chars_minimum>
RPA_TOKEN_READONLY=<64_chars_minimum>
TOKEN_SECRET_KEY=<32_chars_complexe>
API_KEY_REQUIRED=true
# Chiffrement
ENCRYPTION_PASSWORD=<32_chars_complexe>
SECRET_KEY=<32_chars_complexe>
# Réseau
ALLOWED_IPS=<liste_ip_autorisées>
# ===== RECOMMANDÉES =====
# Sécurité
STRICT_INPUT_VALIDATION=true
LOG_SENSITIVE_DATA=false
AUDIT_HASH_SENSITIVE=true
# Rate limiting
DEFAULT_RATE_LIMIT_RPM=60
DEFAULT_RATE_LIMIT_BURST=10
# Audit
AUDIT_LOG_DIR=/var/log/rpa-vision/audit
AUDIT_LOG_MAX_SIZE=10485760
AUDIT_LOG_MAX_FILES=10
```
### 8.3 Permissions fichiers
```bash
# Répertoire application
chmod 750 /opt/rpa-vision
chown -R rpa-user:rpa-group /opt/rpa-vision
# Fichiers de configuration
chmod 600 /opt/rpa-vision/.env
chmod 600 /opt/rpa-vision/config/*.json
# Logs
chmod 750 /var/log/rpa-vision
chmod 640 /var/log/rpa-vision/audit/*.jsonl
# Données chiffrées
chmod 700 /opt/rpa-vision/data
```
### 8.4 Reverse Proxy (recommandé)
**Nginx configuration** :
```nginx
server {
listen 443 ssl http2;
server_name rpa.example.com;
ssl_certificate /etc/ssl/certs/rpa.crt;
ssl_certificate_key /etc/ssl/private/rpa.key;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256;
# Headers sécurité
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-Content-Type-Options "nosniff" always;
add_header X-XSS-Protection "1; mode=block" always;
add_header Strict-Transport-Security "max-age=31536000" always;
location / {
proxy_pass http://127.0.0.1:5000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
```
---
## 9. Monitoring et alertes
### 9.1 Métriques Prometheus
**Endpoint** : `GET /metrics`
**Métriques disponibles** :
```prometheus
# Requêtes HTTP
http_requests_total{method="GET",endpoint="/api/workflows",status="200"}
http_request_duration_seconds{endpoint="/api/workflows"}
# Sécurité
security_blocks_total{type="ip_block"}
security_blocks_total{type="auth_fail"}
security_blocks_total{type="rate_limit"}
# Rate limiting
rate_limit_remaining{endpoint="/api/workflows"}
```
### 9.2 Alertes recommandées
| Alerte | Condition | Sévérité |
|--------|-----------|----------|
| Auth failures spike | > 10 échecs/min | Critique |
| IP blocks spike | > 5 blocs/min | Haute |
| Rate limit exceeded | > 20 dépassements/min | Moyenne |
| Security violation | Tout événement | Critique |
| API errors spike | > 5% erreurs 5xx | Haute |
### 9.3 Dashboards Grafana
Import les dashboards depuis `/docs/grafana/` :
- `rpa-security-overview.json`
- `rpa-api-performance.json`
- `rpa-audit-analysis.json`
---
## 10. Procédures d'urgence
### 10.1 Kill-Switch
**Activation immédiate** (bloque tout sauf health/admin) :
```bash
# Via variable d'environnement
export RPA_KILL_SWITCH=1
systemctl restart rpa-vision
# Via fichier (sans redémarrage)
echo '{"enabled": true, "reason": "Security incident", "timestamp": "'$(date -Iseconds)'"}' \
> /opt/rpa-vision/data/runtime/kill_switch.json
```
**Désactivation** :
```bash
export RPA_KILL_SWITCH=0
# ou
rm /opt/rpa-vision/data/runtime/kill_switch.json
```
### 10.2 Demo-Safe Mode
**Mode lecture seule** (bloque toutes les écritures) :
```bash
export DEMO_SAFE=1
systemctl restart rpa-vision
```
### 10.3 Révocation de token
```python
from core.security.api_tokens import revoke_token
# Révoquer un token spécifique
revoke_token("compromised_token_hash")
# Révoquer tous les tokens d'un utilisateur
revoke_all_user_tokens("user_id")
```
### 10.4 Blocage IP d'urgence
```python
from core.security.ip_allowlist import get_allowlist
allowlist = get_allowlist()
# Retirer une IP compromise
allowlist.remove_allowed_ip("compromised.ip.address")
```
### 10.5 Contacts d'urgence
| Rôle | Contact | Escalade |
|------|---------|----------|
| Administrateur système | admin@example.com | Immédiat |
| RSSI | rssi@example.com | < 15 min |
| Support éditeur | support@rpa-vision.com | < 1h |
---
## 11. Conformité réglementaire
### 11.1 RGPD
| Exigence | Implémentation |
|----------|----------------|
| Minimisation données | Seules données nécessaires collectées |
| Droit à l'oubli | API de suppression disponible |
| Portabilité | Export JSON/YAML |
| Consentement | Configurable par workflow |
| Registre traitements | Logs d'audit |
| DPO notification | Alertes configurables |
### 11.2 HDS (Hébergeur Données Santé)
| Exigence | Statut |
|----------|--------|
| Chiffrement données santé | ✅ AES-256 |
| Traçabilité accès | ✅ Audit JSONL |
| Authentification forte | ✅ Tokens HMAC |
| Cloisonnement | ✅ Isolation par workflow |
| Plan de continuité | ⏳ À documenter |
| Audit externe | ⏳ À planifier |
### 11.3 ISO 27001
| Contrôle | Référence | Statut |
|----------|-----------|--------|
| Politique sécurité | A.5 | ✅ |
| Gestion actifs | A.8 | ✅ |
| Contrôle accès | A.9 | ✅ |
| Cryptographie | A.10 | ✅ |
| Sécurité opérations | A.12 | ✅ |
| Sécurité communications | A.13 | ✅ |
| Gestion incidents | A.16 | ⏳ |
| Conformité | A.18 | ⏳ |
---
## 12. Checklist de validation
### 12.1 Pré-déploiement
- [ ] Clés générées avec entropie suffisante (32+ chars)
- [ ] ENCRYPTION_PASSWORD configuré (non-défaut)
- [ ] SECRET_KEY configuré (non-défaut)
- [ ] TOKEN_SECRET_KEY configuré
- [ ] RPA_TOKEN_ADMIN généré
- [ ] RPA_TOKEN_READONLY généré
- [ ] ALLOWED_IPS configuré (pas de 0.0.0.0/0)
- [ ] ENVIRONMENT=production
- [ ] STRICT_INPUT_VALIDATION=true
- [ ] LOG_SENSITIVE_DATA=false
- [ ] Certificats TLS valides
- [ ] Reverse proxy configuré
### 12.2 Post-déploiement
- [ ] Test authentification admin
- [ ] Test authentification read-only
- [ ] Test rejet token invalide
- [ ] Test IP non-autorisée bloquée
- [ ] Test rate limiting actif
- [ ] Test kill-switch fonctionnel
- [ ] Logs audit générés
- [ ] Métriques Prometheus exposées
- [ ] Alertes configurées
- [ ] Backup procédures testées
### 12.3 Vérification automatique
```python
from core.security import check_security_requirements
result = check_security_requirements()
print(result)
# {
# "production_environment": True,
# "encryption_password_set": True,
# "encryption_password_secure": True,
# "secret_key_set": True,
# "secret_key_secure": True,
# "logging_secure": True,
# "input_validation_strict": True
# }
```
### 12.4 Commande de validation
```bash
cd /opt/rpa-vision
./scripts/validate_security.sh
# Output attendu:
# ✅ Environment: production
# ✅ Encryption: configured
# ✅ Authentication: enabled
# ✅ IP Allowlist: active
# ✅ Rate Limiting: active
# ✅ Audit Logging: active
# ✅ All security checks passed
```
---
## Annexes
### A. Glossaire
| Terme | Définition |
|-------|------------|
| RBAC | Role-Based Access Control |
| HMAC | Hash-based Message Authentication Code |
| PBKDF2 | Password-Based Key Derivation Function 2 |
| JSONL | JSON Lines (1 objet JSON par ligne) |
| SIEM | Security Information and Event Management |
| HDS | Hébergeur de Données de Santé |
### B. Références
- [OWASP Top 10](https://owasp.org/Top10/)
- [ANSSI - Guide d'hygiène informatique](https://www.ssi.gouv.fr/guide/guide-dhygiene-informatique/)
- [CNIL - RGPD](https://www.cnil.fr/fr/rgpd-de-quoi-parle-t-on)
- [ISO 27001:2022](https://www.iso.org/standard/27001)
### C. Historique des révisions
| Version | Date | Auteur | Modifications |
|---------|------|--------|---------------|
| 1.0 | 19/01/2026 | Équipe RPA Vision | Version initiale |
---
**Document généré automatiquement - RPA Vision V3**
**Classification : Confidentiel - Usage interne**