Breaking: #108054 - Enforce explicit opt-in for TypoScript/TSconfig callables
See forge#108054
Description
To strengthen TYPO3's security posture and implement defense-in-depth principles, a new hardening mechanism has been introduced that requires explicit opt-in for methods and functions that can be invoked through TypoScript configuration.
The new PHP attribute
# must be applied to
any method that should be callable via:
- TypoScript
userprocessing (including theFunc USERandUSER_content objects)INT - TypoScript
stdfunctionsWrap pre,User Func Int postandUser Func postUser Func Int - TypoScript constant comment user functions
- TSconfig
renderin suggest wizard configurationFunc
This security enhancement implements strong defaults through explicit configuration, following the principle of least privilege.
Implementation details:
- New
\TYPO3\PHP attributeCMS\ Core\ Attribute\ As Allowed Callable - New
\TYPO3\service for validationCMS\ Core\ Security\ Allowed Callable Assertion - Enhanced
\TYPO3\CMS\ Core\ Utility\ General Utility:: call User Function () - Enhanced
\TYPO3\CMS\ Frontend\ Content Object\ Content Object Renderer:: call User Function ()
Impact
Extension code that provides custom processing methods callable from
TypoScript or TSconfig will fail with a
\TYPO3\ if the target
method is not explicitly marked with the
#
attribute.
The error message will be:
Attribute TYPO3\CMS\Core\Attribute\AsAllowedCallable required for
callback reference: ["VendorName\\ExtensionName\\ClassName","methodName"]
Affected installations
Scenarios using:
- custom processing via TypoScript
userFunc - custom processing via TypoScript constant comments
- custom suggest wizard rendering via TSconfig
renderFunc
Migration
Add the
# attribute to all methods that should
be callable from TypoScript or TSconfig.
TypoScript userFunc example:
use TYPO3\CMS\Core\Attribute\AsAllowedCallable;
class CustomProcessor
{
#[AsAllowedCallable]
public function process(
string $content,
array $conf
): string {
return $content;
}
}
The attribute may be applied to:
- public instance methods
- public static methods
- public
__methodsinvoke () - custom functions in the global namespace
Native PHP functions in the global namespace must be wrapped explicitly.
Example for custom functions in the global namespace:
namespace {
use TYPO3\CMS\Core\Attribute\AsAllowedCallable;
#[AsAllowedCallable]
function customGlobalUserFunction(): string
{
return '...';
}
#[AsAllowedCallable]
function nativePhpHashWrapper(
string $algo,
string $data,
bool $binary = false
): string {
return \hash($algo, $data, $binary);
}
}