fix(security): раунд-2 SMTP-01 — отвергать управляющие символы в email

email с внутренним \r\n/табом/пробелом → header/SMTP-инъекция в письмо подтверждения.
Отвергаем (краевые пробелы .strip() и так чистит). Тест на внутренние control-chars.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
anor
2026-07-19 21:24:59 +10:00
co-authored by Claude Opus 4.8
parent 706037379b
commit b17443609a
3 changed files with 13 additions and 2 deletions
+3 -1
View File
@@ -182,7 +182,9 @@ def register_user(email: str, password: str, invite_token: str) -> dict:
from db import get_user_by_email, create_user, use_invite, set_verify_code
email = email.lower().strip()
if not email or "@" not in email or "/" in email or "\\" in email:
# Управляющие символы/пробелы → header/SMTP-инъекция в письмо подтверждения (пентест
# SMTP-01); '/'/'\\' → path-компонент в work_dir. Отвергаем.
if not email or "@" not in email or any(c in email for c in "/\\\r\n\t "):
return {"ok": False, "error": "Некорректный email"}
if len(password) < 6:
return {"ok": False, "error": "Пароль минимум 6 символов"}