Problem/Motivation

#2966327: Limit what can be called by a callback in render arrays to reduce the risk of RCE adds a new security mechanism to prevent untrusted callbacks. In a typical flow this will be implemented by first deprecating and then throwing an exception. This allows for code to move with the times without breaking the world. So for example in Drupal 8.8.x all render callbacks must be trusted or a deprecation error will be triggered. This only affects tests and then in Drupal 9.0.0 this will be changed to throw an exception.

Proposed resolution

Some security team members want an additional per site switch to opt into throwing exceptions early.

To discuss:

  • Is the extra complexity worth it - vs the problems caused by modules declaring 8.x.x compatibility and then breaking a site with this enabled?
  • How general should the flag be named? I.e. $settings['security_harderned'] vs $settings['security_trustedcallback_exception']
  • What to do when new flag set to FALSE but the system is set to throw exceptions - ie. the flag should never make you less secure :)

Remaining tasks

User interface changes

None - likely a new setting in default.settings.php

API changes

None

Data model changes

None

Release notes snippet

@tbd

Comments

alexpott created an issue. See original summary.

dsnopek’s picture

Is the extra complexity worth it - vs the problems caused by modules declaring 8.x.x compatibility and then breaking a site with this enabled?

My vote is for "yes, it's worth it."

This is currently the easiest way to escalate an XSS vulnerability to RCE, when the XSS script is run as an admin user. We removed the 'php' module from core to prevent this same kind of escalation pattern. Without a way to make this throw an exception, we're stuck with similar workarounds from the D6/D7 days, like rm -rf'ing certain modules from core in your site build process. I think more people will add a line to settings.php, than will implement a build process.

How general should the flag be named? I.e. $settings['security_harderned'] vs $settings['security_trustedcallback_exception']

Between those two options, I'd prefer the more specific one ('security_trustedcallback_exception') because this will eventually become a no-op once D9 is always throwing an exception. We might want to use the more generic name ('security_hardened') for something else some day and don't want to conflict with some old code in settings.php.

What to do when new flag set to FALSE but the system is set to throw exceptions - ie. the flag should never make you less secure :)

In Drupal 9, I think we should just always throw an exception and ignore this setting.

dww’s picture

@alexpott: Thanks for opening this issue and for being willing to consider a setting to force exceptions for this.

FWIW, I totally +1 everything from @dsnopek in #2:
- Yes it's worth adding a flag for this in 8.8.x.
- Flag should be specific in name to avoid both conflicts and potential confusion (not that the specific name "security_trustedcallback_exception" is self-documenting for mere-mortals... we can perhaps bikeshed something more clear in this issue).
- Flag should be ignored in D9* and beyond once we always throw the exceptions.

Thanks,
-Derek

dsnopek’s picture

Status: Postponed » Active
xjm’s picture

Issue tags: +Drupal 9
xjm’s picture

Priority: Normal » Major
samuel.mortenson’s picture

Is making this configurable before D9 required to throw exceptions in D9? I'm wondering if a separate issue should be filed to remove the deprecation and throw an error in D9, since I think that should happen regardless of what happens in this issue.

alexpott’s picture

Is making this configurable before D9 required to throw exceptions in D9?

Nope it's not necessary - we're already promising to throw exceptions for this in Drupal in the deprecation message we're emitting.

I think we should leave this the discussion about making it configurable in Drupal 8 and have a new issue to ensure that we remember to make the change in Drupal 9.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

dww’s picture

I don’t think this is still relevant. 8.x is no longer supported, and 9.x already throws the exceptions. I believe “won’t fix” is the right status. Any objections?

Thanks,
-Derek

dww’s picture

Version: 9.5.x-dev » 9.0.x-dev
Status: Active » Closed (outdated)

I guess "outdated" is more accurate. This was only relevant for 8.x. Once 9.0.x was the minimum supported, this was no longer needed.

Thanks / sorry,
-Derek