forked from mtusi2026/mtusi2026lab7
Проверка rehash, login DoS и общего rate limit
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
|
||||
| Связь | Endpoint / порт | Протокол и server trust | Client identity и минимальные права | Lifecycle | Проверяемый отказ / доказательство | Статус |
|
||||
| --- | --- | --- | --- | --- | --- | --- |
|
||||
| Клиент → nginx | `https://localhost:8443` | TLS 1.2/1.3; `secrets/pki/public-ca/ca.crt`; SAN `localhost`; hostname verification | Public registration/health, Basic login, Bearer business API; `X-User-Id` не identity | Session 3600 s, максимум 3 активных; logout/replacement/expiry revoke access; leaf 30 d | `make test-security`, `make test-session-expiry`; пустой trust store → certificate error; revoked/expired token → 401; login burst → 429 + Retry-After | **PASS** для внешнего TLS/auth/session/rate-limit контракта |
|
||||
| Клиент → nginx | `https://localhost:8443` | TLS 1.2/1.3; `secrets/pki/public-ca/ca.crt`; SAN `localhost`; hostname verification | Public registration/health, Basic login, Bearer business API; `X-User-Id` не identity | Session 3600 s, максимум 3 активных; logout/replacement/expiry revoke access; leaf 30 d | `make test-security`, `make test-session-expiry`, `scripts/measure-login-dos.ps1 -SourceBudget`; пустой trust store → certificate error; revoked/expired token → 401; login burst → 429 + Retry-After; rehash и dummy hash — unit tests | **PASS** для внешнего TLS/auth/session/rate-limit контракта |
|
||||
| nginx → API replicas | `https://api:8443` | mTLS; service CA + SAN `spiffe://hla-lab7/api`; API доверяет отдельному LB client CA | nginx SAN `spiffe://hla-lab7/lb`; точный URI SAN до auth проверяет `TrustedClientCertificateFilter`; API port не публикуется | Leaf 30 d, local regeneration/restart | `scripts/test-mtls.ps1` обращается к каждой реплике отдельно: no cert и foreign CA отклоняются handshake; trusted cert SAN `.../worker` получает 403; LB cert → health 200; прямой published port отсутствует | **PASS** |
|
||||
| API → PostgreSQL | `postgres:5432` | TLS `verify-full`; service CA + SAN `DNS:postgres`; plaintext rejected by `pg_hba.conf` | `messenger_api`: runtime CRUD без superuser/DDL/role management | Static stand secret, rotate/reconnect; dynamic credentials remain extension | Wrong CA/hostname fails; DDL/role management denied | **PASS (уровень 3)** |
|
||||
| Worker → PostgreSQL | `postgres:5432` | TLS `verify-full` | `messenger_worker`: jobs/attachments/variants; нет users password/session/membership | Отдельный secret | `SELECT password_hash`, update membership denied; job transitions allowed | **PASS (уровень 3)** |
|
||||
@@ -33,6 +33,23 @@
|
||||
| Operator → MinIO admin | Не публикуется; bootstrap внутри сети | TLS verify | Root/operator отдельно; API/worker его не получают | Rotate after bootstrap/exposure | API/worker `mc admin info` denied | **PARTIAL:** port закрыт/policy test есть; HTTP и root env у init |
|
||||
| Replication channels | N/A: все stateful services single-node | N/A | N/A | N/A | При добавлении replicas матрица пересматривается | **N/A** |
|
||||
|
||||
### Пароли, сессии и login DoS
|
||||
|
||||
| Контроль | Реализация | Проверка | Статус |
|
||||
| --- | --- | --- | --- |
|
||||
| Password storage | Argon2id PHC 32768 KiB/t=2/p=1, уникальная 16-byte salt; параметры проверяются при старте | `PasswordConfigTest`; `benchmark-argon2.ps1`; `credential_storage.py` проверяет префикс PHC и отсутствие plaintext | **PASS** |
|
||||
| Rehash при успешном login | `upgradeEncoding` + CAS `replacePasswordHash(userId, expectedHash, newHash)`; неверный пароль/unknown/current hash не переписываются | `DatabaseAuthenticationProviderTest` (5 тестов) | **PASS** |
|
||||
| Session token storage | 32 random bytes, base64url; в БД только 32-byte SHA-256 `token_hash`; TTL и максимум 3 активных сессии | `AuthenticationServiceTest`; `credential_storage.py` сверяет SHA-256 и отсутствие token в БД/логах | **PASS** |
|
||||
| Error non-disclosure | Единые `401 unauthorized`, `429 rate_limited`, `503 unavailable`; known/unknown user не различаются; тела ошибок без credentials | `login_dos.py`; `credential_storage.py`; redaction `authorization`/body в telemetry | **PASS** |
|
||||
| Shared login limit | Redis Lua atomic fixed window: 5/username/60 s и 100/source/60 s; ключи — SHA-256 digests; обе реплики используют один Redis | `LoginRateLimiterTest`; `measure-login-dos.ps1 -SourceBudget` (обе реплики в `X-Instance-Id`) | **PASS** |
|
||||
| Redis outage | Fail-closed `AuthenticationServiceException` → `503`, дорогой Argon2 не запускается | `LoginRateLimiterTest`; runtime можно проверить остановкой Redis | **PASS** |
|
||||
| Measured DoS budget | p95 verify 165.5 мс при 0.75 CPU/768 MiB; 5 × p95 ≈ 0.83 s CPU на username/окно; 100 × p95 ≈ 16.55 s CPU на source/окно (≈0.276 CPU в среднем); 429 ≈ 19 мс без Argon2 | `benchmark-argon2.ps1`; `measure-login-dos.ps1 -SourceBudget`; `evidence/login-dos.txt` | **PASS** |
|
||||
|
||||
Ограничение: source-ключ строится по `request.getRemoteAddr()`, то есть по
|
||||
адресу nginx/LB. Это общий cap для всех клиентов за LB, не per-client;
|
||||
username-лимит остаётся основной защитой аккаунта. Fixed window допускает
|
||||
burst на границе окна; лимитер ограничивает rate, но не concurrency.
|
||||
|
||||
## Health, scrape и bootstrap
|
||||
|
||||
| Канал | Разрешение | Запрет / тест | Статус |
|
||||
|
||||
Reference in New Issue
Block a user