Ce document décrit les principes et pratiques de sécurité implémentés dans WaouW v2.0 pour assurer la protection des données, des systèmes et des communications sur Raspberry Pi.
graph TB
subgraph "Host System (RPi)"
subgraph "Docker Networks"
TraefikNet[Traefik Network<br/>Frontend access]
BackendNet[Backend Network<br/>Internal only]
SiteNet1[Site1 Network<br/>Isolated]
SiteNet2[Site2 Network<br/>Isolated]
end
subgraph "System Services"
Agent[WaouW Agent<br/>systemd service]
Firewall[UFW Firewall]
SSH[SSH Service]
end
end
Internet --> Firewall
Firewall --> TraefikNet
TraefikNet --> BackendNet
SiteNet1 -.->|No access| SiteNet2
# Structure des secrets
/etc/waouw/
├── .env # Variables d'environnement principales
├── secrets/
│ ├── db_password # Mot de passe base de données
│ ├── jwt_secret # Clé signature JWT
│ ├── hmac_secret # Secret HMAC devices
│ └── acme_email # Email Let's Encrypt
└── keys/
├── backup_ssh_key # Clé SSH pour backups
├── device_cert.pem # Certificat device (optionnel)
└── ca_cert.pem # CA personnalisée (optionnel)
interface JWTPayload {
sub: string; // User ID
email: string; // User email
roles: string[]; // User roles ["admin", "user"]
device_ids: string[]; // Accessible devices
exp: number; // Expiration timestamp
iat: number; // Issued at timestamp
}
# Signature des communications device
payload = {
"device_id": "uuid",
"timestamp": 1234567890,
"metrics": {...}
}
signature = hmac.new(
DEVICE_HMAC_SECRET.encode(),
json.dumps(payload, sort_keys=True).encode(),
hashlib.sha256
).hexdigest()
# traefik.yml
tls:
options:
default:
minVersion: "VersionTLS12"
maxVersion: "VersionTLS13"
cipherSuites:
- "TLS_AES_256_GCM_SHA384"
- "TLS_CHACHA20_POLY1305_SHA256"
- "TLS_AES_128_GCM_SHA256"
curvePreferences:
- "CurveP521"
- "CurveP384"
# Middleware Traefik
security-headers:
headers:
frameDeny: true
browserXssFilter: true
contentTypeNosniff: true
forceSTSHeader: true
stsIncludeSubdomains: true
stsPreload: true
stsSeconds: 31536000
referrerPolicy: "strict-origin-when-cross-origin"
# docker-compose.yml
services:
app:
user: "1000:1000" # Non-root user
read_only: true # Filesystem read-only
cap_drop:
- ALL
cap_add:
- CHOWN
- DAC_OVERRIDE
security_opt:
- no-new-privileges:true
tmpfs:
- /tmp:rw,noexec,nosuid,size=100m
# Scan des images Docker
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock \
aquasec/trivy image waouw/backend:latest
# Scan des dépendances Python
pip-audit --requirement requirements.txt
# Règles par défaut
ufw default deny incoming
ufw default allow outgoing
# Ports autorisés
ufw allow 22/tcp # SSH
ufw allow 80/tcp # HTTP
ufw allow 443/tcp # HTTPS
ufw allow 7165/tcp # WaouW Interface
# Limitation des connexions SSH
ufw limit 22/tcp
# Activation
ufw --force enable
# /etc/ssh/sshd_config
Protocol 2
PermitRootLogin no
PasswordAuthentication no
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
X11Forwarding no
AllowTcpForwarding no
ClientAliveInterval 300
ClientAliveCountMax 2
MaxAuthTries 3
LoginGraceTime 30
# Utilisateur WaouW (non-privilégié)
sudo useradd -r -m -d /opt/waouw -s /bin/bash waouw
sudo usermod -aG docker waouw
# Utilisateur agent (minimal)
sudo useradd -r -s /bin/false waouw-agent
sudo mkdir -p /var/log/waouw
sudo chown waouw-agent:waouw-agent /var/log/waouw
# rclone avec chiffrement
rclone config create backup-encrypted crypt \
remote=backup-s3:waouw-backups \
password=$(rclone obscure "strong-encryption-password") \
password2=$(rclone obscure "salt-password")
# Backup chiffré
rclone sync /var/www/ backup-encrypted:sites/ \
--transfers 4 \
--checkers 8 \
--checksum
# Génération clé backup
ssh-keygen -t ed25519 -b 4096 -f /etc/waouw/keys/backup_ssh_key -N ""
# Restriction côté serveur backup
command="rsync --server -vlogDtpre.iLsfxCIvu --delete . /backups/waouw/",
no-agent-forwarding,no-port-forwarding,no-pty,no-X11-forwarding
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5... waouw-backup
{
"timestamp": "2024-01-15T10:30:00Z",
"level": "SECURITY",
"event": "failed_login",
"source_ip": "192.168.1.100",
"user_agent": "Mozilla/5.0...",
"details": {
"username": "admin",
"failure_reason": "invalid_password",
"attempt_count": 3
}
}
# Seuils d'alerte
SECURITY_THRESHOLDS = {
"failed_logins_per_hour": 10,
"invalid_device_signatures": 5,
"high_cpu_usage": 95,
"disk_space_critical": 95,
"memory_usage_critical": 95
}
# Notifications
async def send_security_alert(event_type: str, details: dict):
"""Envoyer alerte sécurité par email/webhook"""
pass
# /etc/fail2ban/jail.local
[waouw-api]
enabled = true
port = 8000
filter = waouw-api
logpath = /var/log/waouw/api.log
maxretry = 5
bantime = 3600
#!/bin/bash
# update-waouw.sh
# 1. Backup configuration
sudo tar czf /tmp/waouw-config-$(date +%Y%m%d).tar.gz /etc/waouw/
# 2. Download and verify updates
wget https://releases.waouw.tech/v2.0.1/checksums.sha256
sha256sum -c checksums.sha256
# 3. Stop services
sudo systemctl stop waouw-agent
cd /opt/waouw/DEPLOY && docker compose down
# 4. Update and restart
docker compose pull
docker compose up -d
# 5. Verify health
./scripts/health-check.sh
#!/bin/bash
# rotate-secrets.sh
# JWT secret
NEW_JWT_SECRET=$(openssl rand -base64 64)
sed -i "s/JWT_SECRET_KEY=.*/JWT_SECRET_KEY=$NEW_JWT_SECRET/" /etc/waouw/.env
# HMAC secret
NEW_HMAC_SECRET=$(openssl rand -base64 32)
sed -i "s/DEVICE_HMAC_SECRET=.*/DEVICE_HMAC_SECRET=$NEW_HMAC_SECRET/" /etc/waouw/.env
# Restart services
docker compose restart backend worker
# Journalisation système
sudo journalctl -u waouw-agent -f --output=json
# Logs Docker
docker compose logs -f --tail=100 backend
# Logs système
tail -f /var/log/auth.log
tail -f /var/log/ufw.log
# Scan réseau
nmap -sS -O -p 1-65535 raspberry-pi-ip
# Test TLS
testssl.sh https://waouw.domain.com
# Audit Docker
docker run --rm -it -v /var/run/docker.sock:/var/run/docker.sock \
docker/docker-bench-security
En cas de découverte de vulnérabilité :
Important : Ce document doit être mis à jour à chaque modification de l'architecture de sécurité. La sécurité est une responsabilité partagée entre l'équipe WaouW et les administrateurs des installations.
Dernière mise à jour : $(date)