#111250MFA: htmlspecialchars() on TOTP issuer produces an invalid otpauth URI
Description
Summary
Totp::getTotpAuthUrl() applies htmlspecialchars() to the issuer when building the issuer query parameter, but uses the raw issuer for the label part of the same URI. If $GLOBALS[‘TYPO3_CONF_VARS’][‘SYS’][‘sitename’] contains a character that htmlspecialchars() encodes (&, <, >, “, ‘), the label prefix and the issuer parameter no longer match, and the issuer parameter carries an HTML entity.
The Key Uri Format requires both values to be equal. Authenticator apps therefore reject the QR code or import an entry with a corrupted issuer, and users cannot complete the TOTP setup. The backend only reports the generic “Could not activate MFA provider Time-based one-time password. Please try again.”
Steps to reproduce
1. Set SYS/sitename to a value containing an ampersand, e.g. TYPO3 Test GmbH & Co. KG.
2. Log in to the backend and open User Settings → Account security → Setup multi-factor authentication → Time-based one-time password.
3. Inspect the generated otpauth URI by decoding the displayed QR code.
Actual result
otpauth://totp/TYPO3%20Test%20GmbH%20%26%20Co.%20KG%3Auser%40example.com?secret=XXXX&issuer=TYPO3%20Test%20GmbH%20%26amp%3B%20Co.%20KG
- Label prefix:
TYPO3 Test GmbH & Co. KG
- issuer parameter:
TYPO3 Test GmbH & Co. KG
Expected result
Both carry the same value:
otpauth://totp/TYPO3%20Test%20GmbH%20%26%20Co.%20KG%3Auser%40example.com?secret=XXXX&issuer=TYPO3%20Test%20GmbH%20%26%20Co.%20KG
Affected code
typo3/sysext/core/Classes/Authentication/Mfa/Provider/Totp.php
$parameters = [
'secret' => $this->secret,
'issuer' => htmlspecialchars($issuer),
];Reviews 2
History 13
-
Gerrit Code Review pushed patch set 1 for main to change 97179 status
NewUnder Review <span data-processor="relativetime" data-value="2026-10-27T20:40:56+00:00" > 10/27/26, 20:40 </span> -
Gerrit Code Review pushed patch set 1 for 14.3 to change 97181 <span data-processor="relativetime" data-value="2026-10-27T21:53:39+00:00" > 10/27/26, 21:53 </span>
-
Oliver Bartsch commented and changed status
Under ReviewResolved done0 %100 % <span data-processor="relativetime" data-value="2026-10-27T21:55:14+00:00" > 10/27/26, 21:55 </span>
Applied in changeset commit:1f97877e0077f91d2e08d024c069657f2d17750b.