Fix file access control on batched export downloads - broken by recent commit#1
Open
amorsent wants to merge 1 commit intod6lts:6.x-3.xfrom
Open
Fix file access control on batched export downloads - broken by recent commit#1amorsent wants to merge 1 commit intod6lts:6.x-3.xfrom
amorsent wants to merge 1 commit intod6lts:6.x-3.xfrom
Conversation
Author
|
Taking another look, I'm realizing that this bug is also somewhat specific to my configuration. Aegir had configured my file_directory_temp = 'sites//private/temp', so this is what file_directory_temp() returns. If file_directory_temp is not configured, it works because file_directory_temp() also returns an absolute path. However, I don't think it's incorrect to use a relative path for file_directory_temp, so I think views_data_export is still a little wonky here. ¯_(ツ)_/¯ Hope someone finds this helpful. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The security fix b22a769 seems to always return access denied even when it should allow access.
The problem is that the $filepath passed to views_data_export_is_export_file() is an absolute system path and so the strpos check doesn't work.
Wrapping realpath() around file_directory_temp() seems to solve the issue, although I'm not sure if this is the right fix. For one thing it means that every call to hook_file_download() will need to compute the realpath of the temp dir just to compare it...
Is it even correct to pass absolute system paths to hook_file_download()? The record in the files table also contains the absolute path.
This all seems to originate here in views_data_export_plugin_display_export::outputfile_create()
$path = tempnam(realpath($dir), 'views_data');tempnam() returns an absolute path and this ends up as the filepath on the file record and we're always dealing with an absolute path from then on..
So maybe it's better to fix it there?