Issue Bug Resolved

#111250MFA: htmlspecialchars() on TOTP issuer produces an invalid otpauth URI

Felix Welberg 10/26/26, 15:41 updated 10/27/26, 21:55

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 &amp; 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

  1. Oliver Bartsch commented and changed status Under Review Resolved done 0 % 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.