fix(auth): ротация API-токена против token fixation#435
Open
Ibochkarev wants to merge 1 commit into
Open
Conversation
Ibochkarev
force-pushed
the
fix/issue-412-token-fixation-rotation
branch
from
July 23, 2026 16:08
117ef3a to
4c10842
Compare
Rebinding a planted guest cookie to the victim account let an attacker keep the same token after login. Always issue a new API token, migrate the guest draft when safe, revoke the old guest/own token, and regenerate the session id.
Ibochkarev
force-pushed
the
fix/issue-412-token-fixation-rotation
branch
from
July 24, 2026 02:16
4c10842 to
7744bc8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Описание
На login / register (auto-login) / email verify / checkout auto-login больше не делается rebind guest API-токена к аккаунту. Выдаётся новый токен, guest draft мигрирует при безопасном владельце, старый guest/own токен отзывается, вызывается
session_regenerate_id(true).Закрывает классический token fixation: planted
ms3_token=Tпосле входа жертвы больше не даёт доступ по тому жеT.Тип изменений
Связанные Issues
Closes #412
Смежно с #369 (checkout email capture) — здесь ещё и
Customer::autoLoginCustomerпереведён на тот жеestablishApiSession.Как это было протестировано?
Gate E (эта сессия):
php -ltouched PHP — OKphp tests/ApiTokenRotationPolicyTest.php— OK (policy + regression guards)composer ci:php— OK (exit 0)Vue — n/a
Ручное тестирование
Автоматические тесты (
composer ci:php)Тестирование на разных версиях PHP/MODX
Конфигурация тестирования:
fix/issue-412-token-fixation-rotationСкриншоты (если применимо)
n/a
Чеклист
Дополнительные заметки
Поведение для клиентов: после login/register/verify в ответе/cookie приходит новый
token(значение меняется). Guest-корзина сохраняется через migrate draft.Отложено (не блокер): Register при редком fail
createTokenпосле уже созданного customer отдаёт failure (повтор → email занят). Follow-up UX.Review: code-reviewer, thermo-nuclear, security-review, silent-failure-hunter; 1 fix-loop (checkout autoLogin + migrate hardening + HTML verify).