Study guide · Login, passwords and MFA
Logging in safely to TYPO3: Passwords, MFA and login protection
Most break-ins into a backend do not start with a clever vulnerability but with a weak or stolen password. On this page you learn how TYPO3 stores passwords, which rules apply to new passwords and how two-factor login works. After that it is about login attempts, "Forgot password" and sessions. As a running example, an agency looks after the TYPO3 14 website of a music school. Tom is the administrator there, Lea is an editor.
How TYPO3 stores passwords
TYPO3 never stores the passwords of backend and frontend users in plain text. It stores a hash, the result of a one-way function. The password cannot be calculated back from the hash. On login, TYPO3 hashes the entered password in the same way and compares the result with the stored hash.
A hash is not encryption. Encryption can be reversed with the matching key. That is why the TYPO3 encryptionKey plays no part in password hashing. Base64 is no protection either. It is only an encoding and can be reversed at once.
So that the same passwords do not result in the same hashes, TYPO3 adds a random salt before hashing. The salt is stored next to the hash. If Lea and a colleague happen to have the same password, their hashes still look completely different. Precomputed tables, so-called rainbow tables, become useless.
The default in TYPO3 14 is Argon2id, for backend and frontend. The method is deliberately expensive in computing time and memory. That slows down attacks with graphics cards. TYPO3 even raises the PHP defaults for it.
MD5 is unsuitable for passwords. It is very fast to compute, ready-made lookup tables exist for many values, and collisions are easy to create.
Changing the method
Every stored hash starts with a prefix that names its method, for example argon2id between two dollar signs. This is how TYPO3 recognises the method, and so it can process several methods side by side.
If an administrator changes the method, TYPO3 does not convert the existing hashes at once. For that it would need the plain text password, and TYPO3 only knows it at the moment someone logs in. So old hashes stay valid. On the next login, TYPO3 checks the password against the old hash and then stores a new hash with the current method.
It follows that accounts which never log in again keep their old hash forever. You had best delete such dead accounts, which also serves data minimisation.
Besides Argon2id, TYPO3 knows other methods. PBKDF2 is recommended by the IETF in RFC 8018. Argon2 does fix weaknesses of PBKDF2. But when FIPS-compliant storage is required, PBKDF2 can be the suitable choice. You should no longer use the methods blowfish and md5salt. They are only still included so that TYPO3 recognises old hashes and lifts them to a better method on login.
An administrator sees which method is active in the Install Tool in the preset "Password hashing settings". Technically it sits in the passwordHashing settings of the areas FE and BE, each with class name and options.
An extension that has to check a password itself uses the PasswordHashFactory. Based on the stored hash and the area frontend or backend, it returns the matching class. Its method checkPassword() then does the comparison.
$hashInstance = GeneralUtility::makeInstance(PasswordHashFactory::class)
->get($storedHash, 'FE');
$isValid = $hashInstance->checkPassword($password, $storedHash);A comparison with the equality operator fails, because every new hash gets a new salt. A plain string comparison with MD5 would be unsafe anyway.
Password policies
Because the hash alone does not save weak passwords, TYPO3 checks new passwords against a password policy. TYPO3 14 ships three policies:
- default applies to backend and frontend users.
- installTool applies to the Install Tool password.
- secretToken applies to secret token fields, for example for webhooks and reactions.
The policy default requires at least 8 characters. On top come an uppercase letter, a lowercase letter, a digit and a special character. In addition, the NotCurrentPasswordValidator checks that the new password differs from the current one. There is no expiry period after which you must change the password. By the way, the built-in password generator suggests 12 characters.
The policy applies in several places:
- When a user sets their password in the user settings.
- When a password is reset via "Forgot password".
- In the password fields of the tables be_users and fe_users.
- When the first user is created during installation.
It does not apply automatically to your own fields. If a plugin stores its own password field, you can assign a policy to the TCA field of type password. Without this assignment, TYPO3 does not check the rules for the field, even if it is called password.
The policies can be disabled with an empty value for passwordPolicy in the area BE and in the area FE. This is only meant for local development. On a production server it weakens security massively.