Sécurité backend — référence IWEY API
Checklist OWASP / NestJS alignée sur .cursor/rules/backend-security.mdc.
Statut : appliqué | partiel | prévu.
| # | Domaine | Statut | Implémentation |
|---|---|---|---|
| 1 | Validation entrées | appliqué | ValidationPipe global (main.ts) + DTOs |
| 2 | Auth / sessions | partiel | JWT + refresh + bcrypt ≥12 ; MFA / captcha prévu |
| 3 | Autorisation | appliqué | JwtAuthGuard + PermissionsGuard globaux ; ownership métier à renforcer au fil des services |
| 4 | Base de données | appliqué | TypeORM synchronize: false ; pas de SQL concaténé |
| 5 | Config / secrets | appliqué | @nestjs/config + validation Joi au boot |
| 6 | Headers / CORS | appliqué | helmet + CORS_ORIGINS |
| 7 | Abus / rate limit | appliqué | @nestjs/throttler global + login/refresh strict |
| 8 | Erreurs | appliqué | HttpExceptionFilter sans stack en prod |
| 9 | Uploads | partiel | stubs ; limites à brancher avec Multer réel |
| 10 | Stockage objet | prévu | buckets privés / presigned |
| 11 | APIs externes | partiel | à systématiser (timeouts) |
| 12 | Supply chain | partiel | pnpm audit script ; Dependabot prévu |
| 13 | Logging sécu | partiel | pas de mdp en logs ; événements login à enrichir |
Variables d’environnement liées
CORS_ORIGINS— liste séparée par des virgules (obligatoire en production)BODY_LIMIT— ex.1mb(défaut)THROTTLE_TTL_MS/THROTTLE_LIMIT— globalTHROTTLE_AUTH_LIMIT— login / refreshBCRYPT_ROUNDS— défaut12JWT_SECRET/JWT_REFRESH_SECRET— requis, min 32 caractères