Fixed
Project:
Drupal core
Version:
11.x-dev
Component:
render system
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
12 Sep 2019 at 22:26 UTC
Updated:
4 Oct 2026 at 06:45 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
samuel.mortensonComment #3
xjmComment #5
xjmBlast, didn't realize this was still outstanding.
Comment #6
dwwYup, fell off all of our collective radar. Whoops. Now what? Can we still do this?
Comment #7
dwwHrm, looking more closely at
core/lib/Drupal/Core/Security/DoTrustedCallbackTrait.php:Seems a bit more can-o-wormsy than I first suspected. Do we:
A) Completely remove the
$error_typeargument? That's gonna be trouble since$extra_trusted_interfacestill needs to exist, so callers will be confused if we remove that argument out from under them.B) Ignore the requested
$error_typeand always behave likeTHROW_EXCEPTIONwas passed?The good news is that grep appears to find this as the only live caller in the 9.0.x branch:
The only other hits are in
core/tests/Drupal/Tests/Core/Security/DoTrustedCallbackTraitTest.phpSo it looks like D9 is already setup to be throwing this exception. But changing the trait seems fraught with peril and BC implications.
Maybe option C) for "What now?" list should be "Close this as 'by design'" since D9 is already throwing exceptions, not trigger_error(), but ripping out all the plumbing that allowed for trigger_error is too much API change to be worth the trouble.
Not sure if/how to proceed, or if this is really still major.
Please advise.
Thanks!
-Derek
Comment #8
xjmSince it's a security hardening, I might still consider it during beta (depending on the specific patch). Probably not during RC though... =/
I really thought we'd already fixed this for D9 in #2966327: Limit what can be called by a callback in render arrays to reduce the risk of RCE. I'll try pinging Sam for clarification...
Comment #9
dwwIndeed, as I tried to explain in #7, we're already throwing an exception, not triggering an error, since the caller in core/lib/Drupal/Core/Render/Renderer.php is invoking this method with the
TrustedCallbackInterface::THROW_EXCEPTIONargument in the 9.0.x branch. The 8.9.x branch's copy of Renderer.php usesTrustedCallbackInterface::TRIGGER_SILENCED_DEPRECATION, instead.That's why I don't think this is major. I think a more accurate issue title might be:
"Remove technical debt and bloat from when
doTrustedCallback()could either trigger errors or throw exceptions"I don't think that's a panic-inducing blocker or anything. Yes, it'd be nice to clean up. Maybe there's still time before RC. But I think D9 is already security-hardened on this point.
Comment #10
dwwProbably won't fly, but here's a proof-of-concept for what I think the correct scope of this issue really is. D9 is already throwing exceptions. That happened at #3104307: Remove BC layers in various Drupal\Core components (woah, weird scope management there).
Comment #11
berdir(crosspost with above)
> Indeed, as I tried to explain in #7, we're already throwing an exception, not triggering an error, since the caller in core/lib/Drupal/Core/Render/Renderer.php is invoking this method with the TrustedCallbackInterface::THROW_EXCEPTION argument in the 9.0.x branch. The 8.9.x branch's copy of Renderer.php uses TrustedCallbackInterface::TRIGGER_SILENCED_DEPRECATION, instead.
Yes, I did change that in the respective issue to remove deprecated code, so agreed, this would be more about changing the default. I'm not sure it's that important or even required. Might still be useful to keep a way to do a deprecation? Maybe we missed a certain type of callback or want to use it for something else as well, so this could be useful again in the future.
I don't think this is major and can probably be 9.1+?
Comment #12
dwwWhoops, added a stray space in a comment in #10. This is better...
Comment #13
dwwwhoops! More x-post fun. ;)
Agreed this isn't major or a beta target or all that stuff. Could happen later. I'm not sure it makes sense to keep all the deprecation warning plumbing in place for this.
But perhaps it is, especially since we might use it for #2966711: Limit what can be called by a callback in form arrays. If we're going to scramble to work on anything, that probably makes more sense than this.
Comment #14
alexpottYeah I don't think we should be doing this until we've worked on #2966711: Limit what can be called by a callback in form arrays and possibly never. As potentially contrib might add a render element with it's own special callback and then decide to implement trusted callbacks and want to use the deprecation path.
I'd be in favour of postponing this issue at this point.
Comment #15
alexpottAlso the issue summary needed an update as 9.x was changed to throw exceptions by #3104307: Remove BC layers in various Drupal\Core components.
Comment #16
alexpottWhatever the status this certainly doesn't need to be done as part of 9.0.x.
Also in order to actually implement this in 9.1.x we'd need to deprecate calling this with the TrustedCallbackInterface::TRIGGER_SILENCED_DEPRECATION and TrustedCallbackInterface::TRIGGER_DEPRECATION :D - deprecate inception!
The above puts me in the won't fix camp for this issue.
Comment #17
longwaveI did consider whether we needed to remove this path when we were made the following change in #3104307: Remove BC layers in various Drupal\Core components
I thought along the same lines as #11 and #14 - that this might be useful in future deprecations of other callback types; we can use the silenced deprecation feature to start with and switch to the exception in the next major release, as we did with render callbacks. There is no security issue here at the moment because nothing in core uses TRIGGER_SILENCED_DEPRECATION except a test for the functionality itself.
Comment #18
dwwGreat. I agree all around. More accurate version and status. If something is pointing here in a 9.0.0-panic-list somewhere, we should remove it.
Thanks,
-Derek
p.s. I still think it's weird and poor form to have made the change described in the original summary here as a side effect of #3104307: Remove BC layers in various Drupal\Core components. That was seriously confusing scope management. The security hardening aspects of the diff in #17 have nothing to do with the title of #3104307. This wasn't a BC layer at all. It was an escalation of security hardening behavior. What's done is done, but as someone who's been regularly chastised for bad scope judgement, I feel compelled to complain about it. ;)
Comment #19
samuel.mortensonUpdated the issue summary with more of a D10 mindset
Comment #20
fathershawnIt seems to me that this also relates to what is proposed in #2982950: [meta] Standardize the approach for capturing and invoking callables across various subsystems
Comment #25
larowlanRebased this as an MR - we can unpostpone this now we're nearing D12
Getting late but would be good to get this in
Comment #26
alexpottLooking at https://search.tresbien.tech/search?q=doTrustedCallback%20-f%3Acore&num=... I think we need to deprecate the argument. I've done this.
For example https://git.drupalcode.org/project/twig_field_value/-/blob/0371644251620... will break if we just remove the code.
Comment #27
larowlanThanks @alexpott
I came to review with eye to RTBC but instead fixed the test failures - just a variable collision - $args already existed
Comment #28
longwaveAdded some nits and wrote some words in the change record.
Comment #29
alexpottThanks for the review @longwave
Comment #30
longwaveAll looks good to me, let's do it.
Comment #33
catchCommitted/pushed to main and 12.0.x, thanks!
This will need a backport MR for 11.x
Comment #35
alexpottI created the 11.x MR. The conflict was in the test due to #3562361: Add type hints to core/tests code via Rector - round 2
Comment #36
longwavePatches are identical other than a change to a test method signature.
Comment #38
catchCommitted/pushed the backport MR to 11.x, thanks!