forked from mtusi2026/mtusi2026lab7
feat: harden authentication (Argon2id by measurement, login limits, body limit)
Apply auth-hardening up to the bench_login label: Argon2id parameters from [auth] chosen by driver.py argon2-params (m=64 MiB, t=2, p=1), rehash on login, per-process KDF budget with 429, shared login failure limit in Valkey with a local fallback, X-Forwarded-For from HAProxy, 64 KiB body limit (400) in LB and middleware, bench login profile, tests, threat model and trust matrix rows. Hypotheses H1-H4 are committed here before the baseline label. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -96,6 +96,21 @@ defaults
|
||||
# Файлы — secrets compose в /run/secrets/
|
||||
frontend entry
|
||||
bind :8443 ssl crt /run/secrets/ingress.pem ssl-min-ver TLSv1.2 alpn http/1.1
|
||||
# адрес клиента реплике (change auth-hardening, design, решение 6):
|
||||
# значение клиента перезаписывается адресом соединения, у реплики ровно
|
||||
# один адрес. Реплика верит заголовку только от соединения с identity
|
||||
# haproxy (allowlist после рукопожатия mTLS), в консоли — не верит
|
||||
http-request set-header X-Forwarded-For %[src]
|
||||
# предел размера тела вне загрузки вложения (change auth-hardening,
|
||||
# design, решение 8): Content-Length больше 65536 — 400 в формате
|
||||
# контракта, тело к реплике не идёт. Число — REQUEST_BODY_MAX_BYTES
|
||||
# (src/utils/constants.py), выражение пути — то же, что у set-timeout
|
||||
# backend api (UPLOAD_PATH_PATTERN): на пути загрузки свой предел
|
||||
# сервиса и порядок 404 → 415 → 413. Тело частями без Content-Length
|
||||
# ограничивает реплика
|
||||
acl upload method POST
|
||||
acl upload_path path_reg ^/api/v1/chats/[^/]+/attachments$
|
||||
http-request return status 400 content-type application/json lf-string '{"error":{"code":"invalid_request","message":"Request body is too large","request_id":"%[unique-id]"}}' hdr X-Request-Id "%[unique-id]" if { req.hdr_val(content-length) gt 65536 } !upload || { req.hdr_val(content-length) gt 65536 } !upload_path
|
||||
default_backend api
|
||||
|
||||
backend api
|
||||
|
||||
Reference in New Issue
Block a user