Review main Merged Breaking

91589[!!!][TASK] Enforce explicit opt-in for TypoScript/TSconfig callables

Oliver Hader CR +2 V +2 Hard +615 −7 updated 12/01/25, 08:09

Commit message

This change implements security hardening by requiring explicit
declaration of methods that can be invoked through TypoScript
userFunc, constant comments, or TSconfig renderFunc configurations.

A new #[AsAllowedCallable] PHP attribute must be applied to any
method intended to be callable from TypoScript or TSconfig. This
security enhancement implements strong defaults via explicit
configuration, following the principle of least privilege.

Technical Implementation:
* introduces \TYPO3\CMS\Core\Attribute\AsAllowedCallable attribute
* adds \TYPO3\CMS\Core\Security\AllowedCallableException
* adds \TYPO3\CMS\Core\Security\AllowedCallableAssertion service
* adds \TYPO3\CMS\Core\Security\RawValue wrapper to untrusted callables
* adds \TYPO3\CMS\Core\DependencyInjection\AllowedCallablePass handler
* enhances GeneralUtility::callUserFunction() with optional validation
* enhances ContentObjectRenderer::callUserFunction() with validation
* updates TYPO3 core classes to declare #[AsAllowedCallable] where needed

Breaking Change:
Extensions providing custom userFunc/renderFunc methods must add the
attribute, invocation will fail with an AllowedCallableException.

Review

  • Code review CR +2 Done
    • Oliver Hader +2
    • Oli Bartsch +1
    • Garvin Hicking +1
    • Lina Wolf +1
    • Christian Kuhn +1
  • Verified V +2 Done
    • Oliver Hader +2
    • Oli Bartsch +1
    • Garvin Hicking +1
    • Lina Wolf +1
    • Christian Kuhn +1
    • core-ci +1 CI

Issues 1

Files 22

Show 2 more files

Review log 7485

Show 5060 earlier messages
  1. Oliver Hader uploaded patch set 1 11/12/25, 16:30

  2. core-ci voted on patch set 1 V +1 11/12/25, 16:41 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/89370

  3. Mathias Brodala commented on patch set 1 11/13/25, 07:43

    As this is rather generic, are there plans to extend usage of this to other areas? If not, then we should have the term "TypoScript" in here.
  4. Oliver Hader commented on patch set 1 11/13/25, 09:18

    Reply

    Currently there are no other plans than using that for ContentObjectRenderer and GeneralUtility::callUserFunction, currently triggered by TypoScript and TSconfig. Thus, having `TypoScript` in the name might be misleading as well. Can you please elaborate, why you think it is necessary? Thanks in advance!
  5. Mathias Brodala commented on patch set 1 CR -1 11/13/25, 09:25

    Reply

    Yeah, saw that now. In that case the previous "AsUserFunction" or "UserFunction" would give the developer a bit more context where this is used or why it may be necessary. A generic "Invokable" does not give any hints about its usage. Also it blocks this name in case a generic attribute like this is needed in the future.

    GeneralUtility.php:2704

    Invokable

    GeneralUtility.php:2704

    assertInvokable
  6. Oliver Hader uploaded patch set 2 CR -1 V +1 11/13/25, 12:04

  7. Oliver Hader commented on patch set 1 11/13/25, 12:05

    Reply

    I changed that to `AllowedUserFunction` now...

    GeneralUtility.php:2704 Reply

    Done

    GeneralUtility.php:2704 Reply

    Good catch! I did not spot that...
  8. Mathias Brodala commented on patch set 2 11/13/25, 12:13

    Breaking-108054-AllowedTypoScriptUserFuncItemsNeedToBeAllowedExplicitly.rst:58

    Also very common and should be mentioned explicitly: "itemsProcFunc"

    Breaking-108054-AllowedTypoScriptUserFuncItemsNeedToBeAllowedExplicitly.rst:90

    Is it possible to set the attribute on the class instead here?

    Breaking-108054-AllowedTypoScriptUserFuncItemsNeedToBeAllowedExplicitly.rst:93

    Can you add an example here?
  9. core-ci voted on patch set 2 V +1 11/13/25, 12:16 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/89487

  10. Helmut Hummel commented on patch set 2 11/13/25, 12:16

    GeneralUtility.php:2722

    same here. any reasons not using makeInstance directly?

    ContentObjectRenderer.php:4507

    Why this fallback and not using makeInstance directly? makeInstance checks for availability in container already
  11. Oliver Hader uploaded patch set 3 V +1 11/13/25, 12:52

  12. Oliver Hader commented on patch set 3 11/13/25, 12:54

    GeneralUtility.php:2722 Reply

    Done

    ContentObjectRenderer.php:4507 Reply

    Done
  13. core-ci voted on patch set 3 V +1 11/13/25, 13:01 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/89494

  14. Oliver Hader commented on patch set 3 11/13/25, 13:09

    Breaking-108054-AllowedTypoScriptUserFuncItemsNeedToBeAllowedExplicitly.rst:58 Reply

    That's something that has been adjusted recently in https://review.typo3.org/c/Packages/TYPO3.CMS/+/91285 and should be incorporated in this patch as well.

    Breaking-108054-AllowedTypoScriptUserFuncItemsNeedToBeAllowedExplicitly.rst:90 Reply

    Currently not, since it would make the patch and resolving more complicated. Do you see a strong demand for that?

    Breaking-108054-AllowedTypoScriptUserFuncItemsNeedToBeAllowedExplicitly.rst:93 Reply

    Probably the text is misleading... for PHP native functions, it would require a wrapper. For custom user functions in the global namespaces, the attribute should be possible (however, I did not test that, yet).
  15. Benni Mack commented on patch set 3 11/13/25, 13:33

    I think this is a really good solution. I suggest however to take this chance to finally get rid of the "UserFunction" - at least in the new attribute. "[AllowedCallable]" or "[AllowedTypoScriptCallable]" as a recommendation
  16. Oliver Hader uploaded patch set 4 V +1 11/13/25, 13:43

  17. Oliver Hader commented on patch set 4 11/13/25, 13:44

    Breaking-108054-AllowedTypoScriptUserFuncItemsNeedToBeAllowedExplicitly.rst:58 Reply

    Done

    Breaking-108054-AllowedTypoScriptUserFuncItemsNeedToBeAllowedExplicitly.rst:93 Reply

    Done
  18. Oliver Hader commented on patch set 4 11/13/25, 13:46

    Reply

    I'm fine with any variation here... @mbrodala@pagemachine.de Would be `AllowedCallable` fine for you? `AllowedTypoScriptCallable` is too strict from my POV, since it also considers TSconfig, and maybe(!) other configs in the future.
  19. core-ci voted on patch set 4 V -1 11/13/25, 14:00 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/89506

  20. Mathias Brodala commented on patch set 4 11/13/25, 14:19

    Reply

    Sounds OK for me!
  21. Oliver Hader commented on patch set 4 11/13/25, 15:21

    Breaking-108054-AllowedTypoScriptUserFuncItemsNeedToBeAllowedExplicitly.rst:58 Reply

    Not relevant for this patch, since only `$fieldTSconfig['itemsProcFunc.']` can be set via TSconfig, but not the `itemsProcFunc` directly (which stems from TCA then, which is fine).
  22. Oliver Hader uploaded patch set 5 V -1 11/13/25, 15:32

  23. core-ci voted on patch set 5 V +1 11/13/25, 15:43 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/89542

  24. Oliver Hader uploaded patch set 6 V +1 11/17/25, 10:42

  25. core-ci voted on patch set 6 V +1 11/17/25, 10:50 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/89931

  26. Lina Wolf commented on patch set 6 CR +1 V +1 11/17/25, 11:40

    I tried this out with t3docs/examples and the non Extbase Haiku List Plugin and it worked well. The code - as far as I understand it - looks good to me, I am no DI expert however.

    Breaking-108054-EnforceExplicitOpt-inForTypoScriptTSconfigCallables.rst:21

    I would maybe explicitely mention that this is also true for non-extbase plugins using `USER` / `USERINT` and for extbase plugins that were not yet switched to EXTBASEPLUGIN? Those are probably the most common use cases
  27. Christian Kuhn commented on patch set 6 CR -1 11/17/25, 12:30

    i would like to review this one in more detail and hope it is ok to attach a temp -1. i'll remove that if i don't manage to look at the change until tomorrow evening.
  28. Oliver Hader commented on patch set 7 CR +1 V +1 11/17/25, 12:31

    Published edit on patch set 6.
  29. Oliver Hader commented on patch set 7 11/17/25, 12:32

    Reply

    Sure, that's fine. Thanks in advance for reviewing the change ❤️

    Breaking-108054-EnforceExplicitOpt-inForTypoScriptTSconfigCallables.rst:21 Reply

    Acknowledged
  30. Oliver Hader commented on patch set 7 CR -1 11/17/25, 12:33

    Re-applying Lolli's `-1`
  31. core-ci voted on patch set 7 V +1 11/17/25, 12:38 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/89937

  32. Christian Kuhn uploaded patch set 8 CR -1 V +1 11/18/25, 17:23

  33. Christian Kuhn commented on patch set 8 11/18/25, 17:26

    rebased
  34. core-ci voted on patch set 8 V +1 11/18/25, 17:31 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/90065

  35. Christian Kuhn commented on patch set 8 11/18/25, 17:37

    we leave out tca userfuncs?

    AllowedCallableAssertion.php:77

    @oliver.hader@typo3.org could you create a TF issue for this and/or maybe push something already? would be great to get rid of this quickly.

    Services.php:101

    what's the impact? does core use __invoke on userFuncs? does ter search reveal many cases? the .rst file states __invoke() is fine. what am i missing?

    Bootstrap.php:129

    ah right, extbase is a case, too ...
  36. Oliver Hader commented on patch set 8 11/18/25, 17:57

    Reply

    Done

    AllowedCallableAssertion.php:77 Reply

    I did that already at https://github.com/ohader/testing-framework/commit/418738d456c5d845a13ffa4cc55a95b925f9657f It still uses the old attribute name, but identified the source locations of the TF.

    Services.php:101 Reply

    The `@todo` is about implementing a different approach for the Symfony handling of identifying the `AllowedCallable` items. Thus, static method references are not cached for the DI container, but they are evaluated during runtime in `AllowedCallableAssertion` using reflection. As an example, the following code is not "found" by the DI compiler-pass. ``` #[AllowedCallable] public static whatever(): void {} ``` Thus, the topic is a potential performance optimization. No blocker for this patch.

    Breaking-108054-AllowedTypoScriptUserFuncItemsNeedToBeAllowedExplicitly.rst:90 Reply

    Allowing the class can be added later as well, if necessary.
  37. Oliver Hader commented on patch set 8 11/18/25, 17:58

    Reply

    Done
  38. Oliver Hader commented on patch set 8 11/18/25, 17:59

    Reply

    Yes, since TCA userFunc references are declared "static" in PHP. This patch focusses on aspects that can be defined dynamically, e.g. in TypoScript.
  39. Oliver Hader commented on patch set 9 V +1 11/18/25, 18:02

    Published edit on patch set 8.
  40. Oliver Hader commented on patch set 9 11/18/25, 18:03

    Services.php:101 Reply

    I removed the `@todo` and just made it a regular comment.
  41. Christian Kuhn commented on patch set 9 CR +1 V +1 11/18/25, 18:08

    AllowedCallableAssertion.php:77 Reply

    great! just PR it and we'll take care to get it merged and raised.
  42. core-ci voted on patch set 9 V +1 11/18/25, 18:11 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/90069

  43. Benni Mack commented on patch set 9 11/18/25, 18:34

    I'm happy with the naming. How about we backport the JUST attributes into v12+v13 (with an Important.rst) so people can prepare starting now. I suggest this as an exception as this is a) security-related and b) we don't people to struggle with an update because of security "overhead".
  44. Benni Mack voted on patch set 9 CR +1 11/18/25, 18:34

  45. Benni Mack voted on patch set 9 V +1 11/18/25, 22:17

  46. Georg Ringer commented on patch set 9 11/18/25, 22:28

    AllowedCallablePass.php:2

    declare(strict_types=1);

    Breaking-108054-EnforceExplicitOpt-inForTypoScriptTSconfigCallables.rst:22

    should we also mention postUserFunc, preUserFunc? just so it is found in searches
  47. Christian Kuhn uploaded patch set 10 CR +1 V +1 11/19/25, 22:11

  48. Christian Kuhn commented on patch set 9 CR +1 V +1 11/19/25, 22:12

    AllowedCallablePass.php:2 Reply

    Done

    Breaking-108054-EnforceExplicitOpt-inForTypoScriptTSconfigCallables.rst:22 Reply

    yeah. good point. done.
  49. core-ci voted on patch set 10 V +1 11/19/25, 22:19 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/90208

  50. Georg Ringer voted on patch set 10 CR +1 V +1 11/19/25, 23:08

  51. Oliver Hader commented on patch set 10 11/20/25, 09:04

    Breaking-108054-EnforceExplicitOpt-inForTypoScriptTSconfigCallables.rst:22 Reply

    Thx!
  52. Oliver Hader commented on patch set 10 11/20/25, 09:08

    Reply

    Good idea, I added a ticket for that at https://forge.typo3.org/issues/108209
  53. Garvin Hicking voted on patch set 10 CR +1 V +1 11/20/25, 09:10

  54. Oli Bartsch commented on patch set 10 11/20/25, 09:16

    AllowedCallable.php:24

    Could we please stick to the "As*" naming "convention". I suggest "AsCallable".
  55. Oliver Hader commented on patch set 10 11/20/25, 09:38

    AllowedCallable.php:24 Reply

    I'd prefer to stick with `AllowedCallable`. I changed that a bunch of times already: * `AsUserFunction` → `Invokable` * `Invokable` → `AllowedUserFunction` * `AllowedUserFunction` → `AllowedCallable` (current state) * `AllowedCallable` → `AsCallable` (new suggestion) Each change requires to change all classes, handlers, variables and PHPdoc comments. In addition documentation and commit message has to be adjusted. tl;dr: I'd prefer to keep `AllowedCallable` since methods and functions are "callable" per default in PHP, `AsCallable` does not foster to the aspect of being allowed or disallowed to be called.
  56. Christian Kuhn commented on patch set 10 11/20/25, 09:42

    AllowedCallable.php:24 Reply

    agree to oliver hader: AsCallable has the drawback that methods are callable by nature and it omits the aspect this is about an additional restriction on top.
  57. Lina Wolf commented on patch set 10 11/20/25, 09:46

    AllowedCallable.php:24 Reply

    I agree with @oliver.hader@typo3.org, AllowedCallable describes the intention much more clearly than AsCallable. In Extbase we also don’t use As for attributes (e.g. #[Transient]), so sticking to a descriptive adjective fits better. The As prefix is usually just a fallback when no suitable adjective exists, combining As with a noun. Here, “allowed” communicates the purpose directly, so I’d keep AllowedCallable.
  58. Oli Bartsch commented on patch set 10 11/20/25, 09:49

    AllowedCallable.php:24 Reply

    I totally understand the argumentation regarding the necessity of the "Allowed" part. And I also understand that renaming might always be some effort. However, I was not involved and do not know why thee were already so many renamings, while none contained the `As*` prefix. Again, for consistency I strongly suggest to include this prefix. We even replaced an already released attribute to `AsController` for consistency in the past.
  59. Lina Wolf commented on patch set 10 11/20/25, 09:51

    AllowedCallable.php:24 Reply

    I get your point regarding consistency with the existing As* attributes, especially since TYPO3 switched to AsController for exactly that reason. However, from my perspective the As prefix is typically used when there is no clear adjective or behavioral description available and the attribute simply marks something as a certain role (e.g. controller, command, event listener). In this case we do have a meaningful adjective: Allowed. It expresses the actual intention of the attribute — whether a callable is permitted or not — which “AsCallable” doesn’t communicate. It would classify something as callable, but everything callable in PHP is callable by definition, so the semantics don’t really fit. For that reason I still support keeping AllowedCallable, as it makes the purpose clearer and aligns with how Extbase attributes like #[Transient] or #[Validate] also describe behavior or state rather than using the As prefix when not necessary.
  60. Garvin Hicking commented on patch set 10 11/20/25, 09:57

    AllowedCallable.php:24 Reply

    (I guess if we rename it, AsAllowedCallable would make most sense to satisfy both aspects. I can live with the current naming, but also ser that As... would be more consistent. Transient and Extbase are older than our attributes and were named for legacy reasons)
  1. Oli Bartsch commented on patch set 10 11/20/25, 10:01

    AllowedCallable.php:24 Reply

    Yes, that was my intention in my second comment. Keep Allowed and make it `AsAllowedCallable`. So "define this service AS an allowed callable"
  2. Oliver Hader commented on patch set 10 11/20/25, 10:01

    AllowedCallable.php:24 Reply

    Speaking about "consistency", I just want to share the list of attributes we have: - TYPO3\CMS\Backend\Attribute\AsController - TYPO3\CMS\Core\Attribute\AsEventListener - TYPO3\CMS\Core\Attribute\AsNonSchedulableCommand - TYPO3\CMS\Core\Attribute\WebhookMessage - TYPO3\CMS\Core\Log\Channel - TYPO3\CMS\Extbase\Attribute\FileUpload - TYPO3\CMS\Extbase\Attribute\IgnoreValidation - TYPO3\CMS\Extbase\Attribute\ORM\Cascade - TYPO3\CMS\Extbase\Attribute\ORM\Lazy - TYPO3\CMS\Extbase\Attribute\ORM\Transient - TYPO3\CMS\Extbase\Attribute\Validate - TYPO3\CMS\Install\Attribute\UpgradeWizard Seems like we are very inconsistent with using the `As...` prefix then.
  3. Lina Wolf commented on patch set 10 11/20/25, 10:02

    AllowedCallable.php:24 Reply

    Symfony's "As" attributes are almost only about service registration, like #[AsEventListener]. Other attributes like #[Lazy] or #[IsCsrfTokenValid] use action / attribute scheme. Also Doctrine doesnt use As prefix
  4. Oliver Hader commented on patch set 10 11/20/25, 10:04

    AllowedCallable.php:24 Reply

    Anyway, I personally just would like to see this feature being integrated in TYPO3. In the end, either name would be fine for me, `AllowedCallable`, `AsAllowedCallable`, `AsHurgaWurgaBojango`... all cool.
  5. Lina Wolf voted on patch set 10 CR +1 V +1 11/20/25, 10:05

  6. Christian Kuhn commented on patch set 10 11/20/25, 10:15

    AllowedCallable.php:24 Reply

    talked to oli bartsch: he'll push a change to go with `AsAllowedCallable`. i'm fine with that.
  7. Oli Bartsch uploaded patch set 11 CR +1 V +1 11/20/25, 10:23

  8. Oli Bartsch commented on patch set 11 CR +1 V +1 11/20/25, 10:24

    AllowedCallable.php:24 Reply

    Done
  9. Lina Wolf voted on patch set 11 CR +1 V +1 11/20/25, 10:24

  10. Christian Kuhn voted on patch set 11 CR +1 V +1 11/20/25, 10:28

  11. core-ci voted on patch set 11 V +1 11/20/25, 10:32 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/90256

  12. Garvin Hicking voted on patch set 11 CR +1 V +1 11/20/25, 10:38

  13. Oliver Hader commented on patch set 11 11/20/25, 10:48

    AsAllowedCallable.php:26

    Shouldn't the tag name be adjusted as well?

    AllowedCallablePass.php:24

    `AsAllowedCallablePass`?
  14. Oli Bartsch commented on patch set 11 11/20/25, 11:10

    AsAllowedCallable.php:26 Reply

    No, tag is fine. See other use cases like AsController => `backend.controller` tag. The attribute just reads "define this AS an allowed callable". No need to update the tag with this prefix.

    AllowedCallablePass.php:24 Reply

    No, the pass is to handle tagged services, no matter how they were tagged.
  15. Oliver Hader commented on patch set 11 11/20/25, 11:24

    Thx. Seems like we are finally done with finalizing this patch.
  16. Oliver Hader voted on patch set 11 CR +2 V +2 11/20/25, 11:24

  17. Oliver Hader merged patch set 12 11/20/25, 11:24

  18. Oliver Hader commented on patch set 12 11/20/25, 16:37

  19. Lina Wolf commented on patch set 12 11/30/25, 06:41

  20. Lina Wolf commented on patch set 12 11/30/25, 06:46

    GeneralUtility.php:2708

    This method is public API and mentioned in the docs (https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ApiOverview/DependencyInjection/Index.html#what-about-user-functions) Should we therefore mention the signature and behaviour changes in the Changelog?
  21. Lina Wolf commented on patch set 12 11/30/25, 06:49

    RawValue.php:19

    As this class is not internal (and at least to me) not self explaining, we should add a class comment what it is and should be used for.
  22. Lina Wolf commented on patch set 12 11/30/25, 06:53

    AllowedCallableAssertion.php:40

    In what situations would you get this error message, can we be more explicit on what is wrong and how to fix it?
  23. Lina Wolf commented on patch set 12 12/01/25, 05:15

    Reply

    Done
  24. Oliver Hader commented on patch set 12 12/01/25, 08:02

    AllowedCallableAssertion.php:40 Reply Unresolved

    That might happen, when e.g. calling `assertCallable([null, 1, 'two'])` or `assertCallable([])` - thus basically not providing a callable reference.

    GeneralUtility.php:2708 Reply Unresolved

    The references section is about dependency injection and class instances... Anyway, adding a suggestion for `callUserFunction()` to enforce `$assertAllowedCallable` when dealing with TypoScript (in terms of user-submitted function references) might make sense.
  25. Oliver Hader commented on patch set 12 12/01/25, 08:09

    RawValue.php:19 Reply Unresolved