Closed (fixed)
Project:
Drupal core
Version:
8.0.x-dev
Component:
file.module
Priority:
Critical
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
5 Jun 2011 at 19:09 UTC
Updated:
29 Jul 2014 at 19:37 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
David_Rothstein commentedRelated issue: #1179424: Color module security fixes from SA-CORE-2011-001 not yet applied
Comment #2
aspilicious commentedComment #3
aspilicious commentedComment #4
scor commentedRelated documentation issue #993082: file_get_file_references() @return doc totally wrong.
Are there any test that could be added to node.test (building on the existing node_access_test.module) to test for this vulnerability?
Comment #5
webchickI agree that tests here would be really welcome. We definitely dont' want to break this EVER again.
Comment #6
tstoecklerI tried to write a test but it isn't as easy as just enabling node_access_test.module and trying to view a private file, because that passes.
I read the code, which is affected by the patch. And the patch in itself seems to make a lot of sense, but I don't see how that is related to node access modules.
Comment #7
chx commentedTest is here. It's very weird that I am getting a 404 for logged out user instead of a 403. Very strange. Edit: I am running D7 and the patch above is applied.
Comment #9
chx commentedWell that just proves that the above patch is necessary -- tests passes for me but it's not committable because I do not see why I am getting a 404 vs a 403.
Comment #10
chx commentedOK figured it out. tl;dr: file module can't deny access because it has no idea the file is used by a file field.
Let's say we have
private://foo.txt. This file is used in one place, in a file field attach to one entity only, a node denied by thenode_accesstable to the current user.file_file_downloadchecks the URI in the database.file_get_file_references.EntityFieldQuery.node_query_entity_field_access_alterdoes its elaborate dance and completely hides the fact that the file is used by a node.EntityFieldQueryreturns empty handed and so with thearray_filter,file_get_file_referencesalso comes back empty handed.That's the end of the story. While a 404 is not as good as a 403 it's still a lot better than a 200 and so I kept
assertNonResponse(200)as we have nothing better. Patch attached is just the concat of #2 and #7.Comment #11
chx commentedI strongly recommend committing this and handle the 403-404 issue in separately. #1221214: file_download returns 404 instead of 403 filed.
Comment #12
catch#10 is fun.
One too many line breaks. And I think the test classes themselves need a docblock. Apart from that looks good.
Comment #13
xjmReroll with corrections suggested in #12.
Comment #14
tstoecklerTypo: ...and checkS access.
Also a nitpick, but I wonder if we shouldn't merge with func_get_args() here as well. I don't know if there are that many use-cases extending this class, but it seems somewhat best practice.
This seems leftover from copy-paste. Could maybe mention mention the node_access_test module, which is subtle but important here (right?).
Tentatively marking needs work, but this is really RTBC except docs, which could also be dealt with in a follow-up.
Comment #15
xjmYou mean for
parent::setUp('node_access_test');, right?I'll reroll it with these changes since I still have that clone set up.
Comment #16
xjmReroll with corrections from #14.
Comment #18
xjmAh, too many levels of array_merge. Are we using this pattern elsewhere for child classes?
Comment #19
xjmThere's a better pattern in
FieldUITestCasewe can probably use. However, considering that most child classes are not yet extended, I think maybe we should leave it as-is until there's the need to extend it? What do you think?Edit:
Comment #20
chx commentedfunc_get_args here is not necessary only on classes that will be extended (ie non-test classes, just helpers).
Comment #21
xjmReusing the pattern from field UI tests in the parent class, and dropping the unnecessary arg merge from the child.
Comment #22
tstoecklerRTBC if it comes back green.
Comment #23
tstoecklerAlso, the test should probably be backported.
Comment #24
chx commentedThe test is known to work with D7 -- I developed it on D7 so the commit is just that, patch -p1 the patch, the file.inc hunk will recognize it's been applied already it will ask "Assume -R" answer n and then apply anyways answer n.
Comment #25
chx commentedThere is no point in creating the field first then changing it. Speedier test, yay.
Edit: the interdiff is backwards. Bother.
Comment #27
chx commentedgit apply is very picky about what it accepts. patch licked this up.
Comment #28
tstoecklerJust noticed that: It seems like the $field variable is never used below.
Leaving at RTBC.
Comment #29
tstoecklerArgh. Dreditor...
Comment #30
webchickThat seems valid. Re-uploading with that line removed.
Comment #31
tstoecklerOut of things to complain. Definitely RTBC.
Comment #32
webchickCommitted and pushed #30 to 8.x, then manually removed the file.module hunk and committed and pushed to 7.x as well. Yay!