ImageStyleDownloadController routes do not limit schemes served

Created on 20 July 2022, almost 2 years ago
Updated 17 June 2024, 9 days ago

Followup for Drupal CORE SA 2022-012

This issue was previously raised with the Drupal Security Team in SDO 1715391 NOTE: This is a private security tracker, only members of the Security Team and individuals who have been added will be able to access this link. Do not report Access Denied errors.

This solution was deferred in order to avoid route changes and cache refreshes in a Security Release.

The changes suggested in this modify routes and constructors which are NOT considered API by the Drupal compatibility policy and as such these changes should be eligible for resolution in existing branches, see Drupal 8 and 9 backwards compatibility and internal API policy. This issue also resolves a security issue and should be considered for the security-only branch of 9.3.x

Problem/Motivation

Drupal's ImageStyleDownloadController will serve content for schemes it is not responsible for as long as a valid itok is provided. For a core only deployment the only risk is increased server load. With contrib modules involved this can lead to an abuse of resources (DoS) and an Access Control bypass.

It is inefficient, fragile, and ultimately insecure to attempt to block this from contrib as it relies on detecting what routes that trace their heritage to ImageStyleDownloadController and register additional and unnecessary 'null' routes into the Drupal routing system to deny access. Additionally patching in Core will provide a more secure example for future contrib modules to model after.

Steps to reproduce

Upload an image to content (such as an Article) that will generate an ImageStyle derivative.
Assume the file is named public://2021-09/2020-11-20 18.09.12-1.jpg

Obtain the link to the ImageDerivative through the image.style_public route. Assuming this is for a 'large' derivative the link may be "sites/default/files/styles/large/public/2021-09/2020-11-20 18.09.12-1.jpg?itok=JzmJlrXt"

Attempt to access the file via the image.style_private route controller (assuming the example above) "system/files/styles/large/public/2021-09/2020-11-20 18.09.12-1.jpg?itok=JzmJlrXt"

Expected Result:
The content is not served
Current Result:
Drupal Streams the content to the requestor.

Proposed resolution

Prevent the routes from severing content for schemes they do not manage.

Remaining tasks

User interface changes

None

API changes

Non-api constructor changes.
Note: While the classes involved are NOT API we are aware of classes that extend these which could cause issues for contrib.

Data model changes

None

Release notes snippet

For security hardening, a backwards-compatibility break has been introduced in ImageStyleDownloadController. This change may affect modules that provide custom stream wrappers or extend ImageStyleDownloadController. Review the change record for information on how to update your routing entries for this change .

🐛 Bug report
Status

Fixed

Version

11.0 🔥

Component
Image system 

Last updated about 24 hours ago

Created by

🇺🇸United States cmlara

Live updates comments and jobs are added and updated live.
  • Security improvements

    It makes Drupal less vulnerable to abuse or misuse. Note, this is the preferred tag, though the Security tag has a large body of issues tagged to it. Do NOT publicly disclose security vulnerabilities; contact the security team instead. Anyone (whether security team or not) can apply this tag to security improvements that do not directly present a vulnerability e.g. hardening an API to add filtering to reduce a common mistake in contributed modules.

Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024